...
|
...
|
@@ -12,7 +12,9 @@ import com.monitor.middleware.memcached.constant.MemConstants; |
|
|
import com.monitor.middleware.memcached.model.MemcachedInfo;
|
|
|
import com.monitor.zabbix.comp.InfluxdbComp;
|
|
|
import net.rubyeye.xmemcached.MemcachedClient;
|
|
|
import net.rubyeye.xmemcached.MemcachedClientBuilder;
|
|
|
import net.rubyeye.xmemcached.XMemcachedClient;
|
|
|
import net.rubyeye.xmemcached.XMemcachedClientBuilder;
|
|
|
import net.rubyeye.xmemcached.exception.MemcachedException;
|
|
|
import net.rubyeye.xmemcached.utils.AddrUtil;
|
|
|
import org.apache.commons.lang.StringUtils;
|
...
|
...
|
@@ -181,6 +183,19 @@ public class MemcachedMonitorImpl { |
|
|
info.setMaxMemory(new DecimalFormat("0.00").format(limit_maxbytes * 1.0 / 1024 / 1024 / 1024) + " G");
|
|
|
info.setUpTime(uptime / (60 * 60 * 24) + " Days");
|
|
|
info.setUseMemory(new DecimalFormat("0.00").format(bytes * 1.0 / 1024 / 1024 / 1024) + " G");
|
|
|
MemcachedClientBuilder builder = new XMemcachedClientBuilder(AddrUtil.getAddresses(url));
|
|
|
try {
|
|
|
MemcachedClient client = builder.build();
|
|
|
long setTime = System.currentTimeMillis();
|
|
|
client.set("hello",3,"Hello");
|
|
|
client.get("hello");
|
|
|
long diff = System.currentTimeMillis()-setTime;
|
|
|
info.setDiff(diff);
|
|
|
client.shutdown();
|
|
|
} catch (Exception e) {
|
|
|
LOGGER.error("memcached get set occurs Exception"+e.getMessage());
|
|
|
}
|
|
|
|
|
|
MemConstants.MEMCACHED_INFO_MAP.put(url, info);
|
|
|
LOGGER.info("MemConstants.MEMCACHED_INFO_MAP all key is {}", MemConstants.MEMCACHED_INFO_MAP.keySet());
|
|
|
}
|
...
|
...
|
|