Authored by qinchao

zabbixalarm报警排除ip主机:10.67.2.46

... ... @@ -46,7 +46,6 @@ import java.util.concurrent.ThreadFactory;
@EnableScheduling
public class ZabbixAlarm {
//private static String ALARMTEMPLATE = "时间:%s,IP:%s,标签:%s,CPU使用率:%.2f%%,可用内存/总内存(MB):%s,输入/输出带宽(Mbps):%.2f / %.2f";
private static String ALARMTEMPLATE = "报警时间:%s,性能指标响应时间:%s,IP:%s,标签:%s,CPU使用率:%.2f%%,可用内存/总内存(MB):%s,输入/输出带宽(Mbps):%.2f / %.2f";
public static final Logger DEBUG = LoggerFactory.getLogger(ZabbixAlarm.class);
... ... @@ -264,15 +263,17 @@ public class ZabbixAlarm {
Double toMem = PointBuilder.findValueByKey(VmMemoryEnum.MEMORY_SIZE_TOTAL.key(), itemInfos, historyList);
Double memPer = (0 == toMem) ? 1 : (avMem / toMem);
Double outNet = PointBuilder.findValueByKey(NetIfEnum.NET_IF_OUT.key(), itemInfos, historyList);
//网卡进出流量 大于 300m
//网卡进出流量 大于 500m
if (zabbixNetAlarm < inNet || zabbixNetAlarm < outNet) {
String nowTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
String alarmInfo = String.format(ALARMTEMPLATE, nowTime, inNetTime, ip, tags, userCpu, String.valueOf(avMem) + " / " + String.valueOf(toMem), inNet, outNet);
DEBUG.info("send alarm vm info {}", alarmInfo);
DEBUG.info("net Index is too high,the timestamp is:" + inNetTimeStamp);
Constants.ERRORMAP.remove(ip);
//vm 带宽告警
alarmMsgService.sendSms("vm-per-net", alarmInfo, mobile_yunwei);
if(!"10.67.2.46".equals(ip)){
String nowTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
String alarmInfo = String.format(ALARMTEMPLATE, nowTime, inNetTime, ip, tags, userCpu, String.valueOf(avMem) + " / " + String.valueOf(toMem), inNet, outNet);
DEBUG.info("send alarm vm info {}", alarmInfo);
DEBUG.info("net Index is too high,the timestamp is:" + inNetTimeStamp);
Constants.ERRORMAP.remove(ip);
//vm 带宽告警
alarmMsgService.sendSms("vm-per-net", alarmInfo, mobile_yunwei);
}
}
//cpu 大于 90%
if (zabbixCpuAlarm < userCpu) {
... ...