使用cpu_user,防止cpu被耗尽,idle_cpu误报为0
Showing
1 changed file
with
3 additions
and
5 deletions
@@ -255,9 +255,7 @@ public class ZabbixAlarm { | @@ -255,9 +255,7 @@ public class ZabbixAlarm { | ||
255 | return; | 255 | return; |
256 | } | 256 | } |
257 | 257 | ||
258 | - Double idleCpu = PointBuilder.findValueByKey(SystemCpuEnum.CPU_UTIL_IDLE.key(), itemInfos, historyList); | ||
259 | - | ||
260 | - idleCpu = (0 == idleCpu) ? 100 : idleCpu; | 258 | + Double userCpu = PointBuilder.findValueByKey(SystemCpuEnum.CPU_UTIL_USER.key(), itemInfos, historyList); |
261 | 259 | ||
262 | Double avMem = PointBuilder.findValueByKey(VmMemoryEnum.MEMORY_SIZE_AVAILABLE.key(), itemInfos, historyList); | 260 | Double avMem = PointBuilder.findValueByKey(VmMemoryEnum.MEMORY_SIZE_AVAILABLE.key(), itemInfos, historyList); |
263 | 261 | ||
@@ -271,11 +269,11 @@ public class ZabbixAlarm { | @@ -271,11 +269,11 @@ public class ZabbixAlarm { | ||
271 | 269 | ||
272 | //|| zabbixMemAlarm > memPer | 270 | //|| zabbixMemAlarm > memPer |
273 | 271 | ||
274 | - if ((zabbixCpuAlarm > idleCpu || zabbixNetAlarm < inNet || zabbixNetAlarm < outNet) && queryErrorMap(ip)) { | 272 | + if ((zabbixCpuAlarm < userCpu || zabbixNetAlarm < inNet || zabbixNetAlarm < outNet) && queryErrorMap(ip)) { |
275 | 273 | ||
276 | String nowTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); | 274 | String nowTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); |
277 | 275 | ||
278 | - String alarmInfo = String.format(ALARMTEMPLATE, nowTime, ip, tags, 100 - idleCpu, String.valueOf(avMem) + " / " + String.valueOf(toMem), inNet, outNet); | 276 | + String alarmInfo = String.format(ALARMTEMPLATE, nowTime, ip, tags, userCpu, String.valueOf(avMem) + " / " + String.valueOf(toMem), inNet, outNet); |
279 | 277 | ||
280 | DEBUG.info("3m 3times ,send alarm vm info {}", alarmInfo); | 278 | DEBUG.info("3m 3times ,send alarm vm info {}", alarmInfo); |
281 | 279 |
-
Please register or login to post a comment