...
|
...
|
@@ -7,6 +7,7 @@ import com.monitor.common.config.SnsMobileConfig; |
|
|
import com.monitor.common.service.AlarmMsgService;
|
|
|
import com.monitor.javaserver.common.JavaApiStatics;
|
|
|
import com.monitor.javaserver.handle.IJavaApiHadnler;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
...
|
...
|
@@ -36,31 +37,36 @@ public class MsgJavaApiHandler extends IJavaApiHadnler { |
|
|
|
|
|
@Override
|
|
|
public void handler(JavaApiStatics javaApiStatics) {
|
|
|
String key = buildKey(javaApiStatics);
|
|
|
//开关关闭、告警次数未设置、无错
|
|
|
if (javaApiStatics.getJavaApiInfo().getApiToggle() == 0 ||
|
|
|
javaApiStatics.getJavaApiInfo().getApiWarnTrigger() <= 0 ||
|
|
|
javaApiStatics.isHasException() == false) {
|
|
|
if (mapStatics.containsKey(key)) {
|
|
|
mapStatics.remove(key);
|
|
|
try {
|
|
|
String key = buildKey(javaApiStatics);
|
|
|
//开关关闭、告警次数未设置、无错
|
|
|
if (javaApiStatics.getJavaApiInfo().getApiToggle() == 0 ||
|
|
|
javaApiStatics.getJavaApiInfo().getApiWarnTrigger() <= 0 ||
|
|
|
javaApiStatics.isHasException() == false) {
|
|
|
if (mapStatics.containsKey(key)) {
|
|
|
mapStatics.remove(key);
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
int num = 0;
|
|
|
mapStatics.putIfAbsent(key, new AtomicInteger(0));
|
|
|
num = mapStatics.get(key).incrementAndGet();
|
|
|
|
|
|
JavaApiInfo javaApiInfo = javaApiStatics.getJavaApiInfo();
|
|
|
if (javaApiInfo.getApiWarnTrigger() > 0 &&
|
|
|
num >= javaApiInfo.getApiWarnTrigger() &&
|
|
|
javaApiInfo.getApiToggle() == 1) {
|
|
|
//告警
|
|
|
String msg = buildErrMsg(num, javaApiStatics);
|
|
|
log.info("send error msg : {} .", msg);
|
|
|
alarmMsgService.sendSms("java_api", msg, snsMobileConfig.getBaseMobile());
|
|
|
int num = 0;
|
|
|
mapStatics.putIfAbsent(key, new AtomicInteger(0));
|
|
|
num = mapStatics.get(key).incrementAndGet();
|
|
|
|
|
|
JavaApiInfo javaApiInfo = javaApiStatics.getJavaApiInfo();
|
|
|
if (javaApiInfo.getApiWarnTrigger() > 0 &&
|
|
|
num >= javaApiInfo.getApiWarnTrigger() &&
|
|
|
javaApiInfo.getApiToggle() == 1) {
|
|
|
//告警
|
|
|
String msg = buildErrMsg(num, javaApiStatics);
|
|
|
log.info("send error msg : {} .", msg);
|
|
|
alarmMsgService.sendSms("java_api", msg, snsMobileConfig.getBaseMobile());
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.error("Failed to handle {} send msg , error {} ", javaApiStatics, e);
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
...
|
...
|
@@ -87,7 +93,11 @@ public class MsgJavaApiHandler extends IJavaApiHadnler { |
|
|
.append("TYPE:" + javaApiInfo.getServiceType()).append(" , ");
|
|
|
|
|
|
if (javaApiInfo.getApiUrlCustom() != null && javaApiInfo.getApiUrlCustom() == 1) {
|
|
|
msgBuilder.append("URL:" + javaApiInfo.getApiUrl().substring(0, javaApiInfo.getApiUrl().indexOf("?") - 1)).append(" . ");
|
|
|
if (StringUtils.contains(javaApiInfo.getApiUrl(), "?")) {
|
|
|
msgBuilder.append("URL:" + javaApiInfo.getApiUrl().substring(0, javaApiInfo.getApiUrl().indexOf("?") - 1)).append(" . ");
|
|
|
} else {
|
|
|
msgBuilder.append("URL:" + javaApiInfo.getApiUrl());
|
|
|
}
|
|
|
} else {
|
|
|
msgBuilder.append("IP:" + mObjectInfo.getMoHostIp()).append(" .");
|
|
|
}
|
...
|
...
|
|