Authored by jack

Merge branch 'dev_memcache'

... ... @@ -146,6 +146,7 @@ public class MemcachedCtrl {
temp.setCpu(temp.getCpu() + "\r\n" + vo.getCpu());
temp.setMem(temp.getMem() + "\r\n" + vo.getMem());
temp.setNet(temp.getNet() + "\r\n" + vo.getNet());
temp.setDiff(temp.getDiff()+"\r\n"+vo.getDiff());
}
return temp;
}
... ... @@ -171,7 +172,7 @@ public class MemcachedCtrl {
}
vo.setUpTime(info.getUpTime());
vo.setDiff(info.getDiff()+"ms");
vo.setCurItems(info.getCurItems());
vo.setMaxMemory(info.getMaxMemory());
vo.setCurConnections(info.getCurConnections());
... ... @@ -180,6 +181,7 @@ public class MemcachedCtrl {
vo.setUrl(key);
vo.setName(MemConstants.MEMCACHED_NAME_MAP.get(key));
//增加twemproxy的内存、cpu、网卡
ZabbixTaskService zabbixTaskService = SpringContextUtils.getBeanByClass(ZabbixTaskService.class);
... ...
... ... @@ -27,4 +27,6 @@ public class MemcachedInfo {
private Long oldSet; //前一次监控的set数
private Long diff;
}
... ...
... ... @@ -32,4 +32,7 @@ public class MemcachedVo {
private String mem = "- / -";
private String net = "- / -";
//get、set操作时间差
private String diff;
}
... ...
... ... @@ -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());
}
... ...