|
@@ -6,9 +6,9 @@ import com.monitor.cmdb.service.IMObjectInfoService; |
|
@@ -6,9 +6,9 @@ import com.monitor.cmdb.service.IMObjectInfoService; |
6
|
import com.monitor.cmdb.service.ITypeInfoService;
|
6
|
import com.monitor.cmdb.service.ITypeInfoService;
|
7
|
import com.monitor.common.config.SnsMobileConfig;
|
7
|
import com.monitor.common.config.SnsMobileConfig;
|
8
|
import com.monitor.common.service.AlarmMsgService;
|
8
|
import com.monitor.common.service.AlarmMsgService;
|
|
|
9
|
+import com.monitor.common.util.DateTimeUtil;
|
9
|
import com.monitor.middleware.memcached.constant.MemConstants;
|
10
|
import com.monitor.middleware.memcached.constant.MemConstants;
|
10
|
import com.monitor.middleware.memcached.model.MemcachedInfo;
|
11
|
import com.monitor.middleware.memcached.model.MemcachedInfo;
|
11
|
-import lombok.Getter;
|
|
|
12
|
import net.rubyeye.xmemcached.MemcachedClient;
|
12
|
import net.rubyeye.xmemcached.MemcachedClient;
|
13
|
import net.rubyeye.xmemcached.XMemcachedClient;
|
13
|
import net.rubyeye.xmemcached.XMemcachedClient;
|
14
|
import net.rubyeye.xmemcached.exception.MemcachedException;
|
14
|
import net.rubyeye.xmemcached.exception.MemcachedException;
|
|
@@ -29,6 +29,8 @@ import java.text.DecimalFormat; |
|
@@ -29,6 +29,8 @@ import java.text.DecimalFormat; |
29
|
import java.util.*;
|
29
|
import java.util.*;
|
30
|
import java.util.concurrent.TimeoutException;
|
30
|
import java.util.concurrent.TimeoutException;
|
31
|
|
31
|
|
|
|
32
|
+import static com.monitor.middleware.memcached.constant.MemConstants.MEMCACHED_UPDATE_TIME;
|
|
|
33
|
+
|
32
|
/**
|
34
|
/**
|
33
|
* Created by yoho on 2016/10/11.
|
35
|
* Created by yoho on 2016/10/11.
|
34
|
*/
|
36
|
*/
|
|
@@ -88,6 +90,11 @@ public class MemcachedMonitorImpl { |
|
@@ -88,6 +90,11 @@ public class MemcachedMonitorImpl { |
88
|
result = client.getStats();
|
90
|
result = client.getStats();
|
89
|
LOGGER.debug("MemcachedMonitorImpl.doMonitor:get memcached status is {}", result);
|
91
|
LOGGER.debug("MemcachedMonitorImpl.doMonitor:get memcached status is {}", result);
|
90
|
client.shutdown();
|
92
|
client.shutdown();
|
|
|
93
|
+
|
|
|
94
|
+ //校验是否所有memcached都返回状态,对未返回状态的memcached短信告警
|
|
|
95
|
+ checkAllStatus(monitorUrl.toString().trim(), result);
|
|
|
96
|
+
|
|
|
97
|
+ processAllStatus(result);
|
91
|
} catch (IOException e) {
|
98
|
} catch (IOException e) {
|
92
|
LOGGER.error("MemcachedMonitorImpl.doMonitor:creatr/shutdown memcached client occurs Exception: ", e.getMessage());
|
99
|
LOGGER.error("MemcachedMonitorImpl.doMonitor:creatr/shutdown memcached client occurs Exception: ", e.getMessage());
|
93
|
alarmMsgService.sendSms("Memcached", "Can not connect to Memcached " + monitorUrl.toString() + " .", snsMobileConfig.getBaseMobile());
|
100
|
alarmMsgService.sendSms("Memcached", "Can not connect to Memcached " + monitorUrl.toString() + " .", snsMobileConfig.getBaseMobile());
|
|
@@ -100,11 +107,10 @@ public class MemcachedMonitorImpl { |
|
@@ -100,11 +107,10 @@ public class MemcachedMonitorImpl { |
100
|
} catch (TimeoutException e) {
|
107
|
} catch (TimeoutException e) {
|
101
|
LOGGER.error("MemcachedMonitorImpl.doMonitor:get memcached status occurs Exception: ", e.getMessage());
|
108
|
LOGGER.error("MemcachedMonitorImpl.doMonitor:get memcached status occurs Exception: ", e.getMessage());
|
102
|
alarmMsgService.sendSms("Memcached", "Can not get Memcached status" + monitorUrl.toString() + " .", snsMobileConfig.getBaseMobile());
|
109
|
alarmMsgService.sendSms("Memcached", "Can not get Memcached status" + monitorUrl.toString() + " .", snsMobileConfig.getBaseMobile());
|
|
|
110
|
+ }catch(Exception e){
|
|
|
111
|
+ LOGGER.error("MemcachedMonitorImpl.doMonitor:occurs Exception: ", e.getMessage());
|
103
|
}
|
112
|
}
|
104
|
- //校验是否所有memcached都返回状态,对未返回状态的memcached短信告警
|
|
|
105
|
- checkAllStatus(monitorUrl.toString().trim(), result);
|
|
|
106
|
|
113
|
|
107
|
- processAllStatus(result);
|
|
|
108
|
}
|
114
|
}
|
109
|
|
115
|
|
110
|
/**
|
116
|
/**
|
|
@@ -149,6 +155,7 @@ public class MemcachedMonitorImpl { |
|
@@ -149,6 +155,7 @@ public class MemcachedMonitorImpl { |
149
|
info.setUpTime(uptime / (60 * 60 * 24) + " Days");
|
155
|
info.setUpTime(uptime / (60 * 60 * 24) + " Days");
|
150
|
info.setUseMemory(new DecimalFormat("0.00").format(bytes * 1.0 / 1024 / 1024 / 1024) + " G");
|
156
|
info.setUseMemory(new DecimalFormat("0.00").format(bytes * 1.0 / 1024 / 1024 / 1024) + " G");
|
151
|
MemConstants.MEMCACHED_INFO_MAP.put(url, info);
|
157
|
MemConstants.MEMCACHED_INFO_MAP.put(url, info);
|
|
|
158
|
+ MemConstants.MEMCACHED_UPDATE_TIME.put("memcachedUpdateTime",DateTimeUtil.unix2time(System.currentTimeMillis()));
|
152
|
LOGGER.info("MemConstants.MEMCACHED_INFO_MAP all key is {}",MemConstants.MEMCACHED_INFO_MAP.keySet());
|
159
|
LOGGER.info("MemConstants.MEMCACHED_INFO_MAP all key is {}",MemConstants.MEMCACHED_INFO_MAP.keySet());
|
153
|
}
|
160
|
}
|
154
|
}
|
161
|
}
|