...
|
...
|
@@ -46,9 +46,9 @@ public class ResourcesSimplePiceAlarm { |
|
|
private RestTemplate restTemplate;
|
|
|
|
|
|
/**
|
|
|
* 十分钟监控一次
|
|
|
* 3分钟监控一次
|
|
|
*/
|
|
|
@Scheduled(cron = "0 2/10 * * * ?")
|
|
|
@Scheduled(cron = "0 2/3 * * * ?")
|
|
|
public void alarm() {
|
|
|
//发送拦截短信
|
|
|
String mobile_user = "13770338135";//耿超的电话//getUsersInfoUtil.getMobileByAlarmGroup(AlarmGroupContants.GROUP_NAME_USER_LOGIN);
|
...
|
...
|
@@ -56,16 +56,21 @@ public class ResourcesSimplePiceAlarm { |
|
|
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(WATCH_URL);
|
|
|
//WATCH_URL 包含了特殊字符,但不需要编码转义:build(true)
|
|
|
URI uri = builder.build(true).encode().toUri();
|
|
|
|
|
|
int failTimes=0;
|
|
|
for(int i=0;i<15;i++){
|
|
|
String alarmData = restTemplate.getForObject(uri, String.class);
|
|
|
|
|
|
if(alarmData==null||alarmData.length()==0){
|
|
|
alarm("RESOURCES.SIMPLE.PICE接口访问异常:接口返回值为null异常",mobile_user);
|
|
|
failTimes++;
|
|
|
//alarm("RESOURCES.SIMPLE.PICE接口访问异常:接口返回值为null异常",mobile_user);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
JSONObject jsonObject=JSON.parseObject(alarmData);
|
|
|
if(jsonObject.get("code")==null||200!=(Integer)jsonObject.get("code")){
|
|
|
alarm("RESOURCES.SIMPLE.PICE接口访问异常:code="+(String) jsonObject.get("code"),mobile_user);
|
|
|
failTimes++;
|
|
|
//alarm("RESOURCES.SIMPLE.PICE接口访问异常:code="+(String) jsonObject.get("code"),mobile_user);
|
|
|
return;
|
|
|
}
|
|
|
boolean correctData=false;
|
...
|
...
|
@@ -79,10 +84,15 @@ public class ResourcesSimplePiceAlarm { |
|
|
}
|
|
|
}
|
|
|
if(!correctData){
|
|
|
alarm("RESOURCES.SIMPLE.PICE接口访问异常:data="+dataJO,mobile_user);
|
|
|
failTimes++;
|
|
|
//alarm("RESOURCES.SIMPLE.PICE接口访问异常:data="+dataJO,mobile_user);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(failTimes>=10){
|
|
|
alarm("RESOURCES.SIMPLE.PICE接口访问异常",mobile_user);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
logger.error("ResourcesSimplePiceAlarm watchurl RESOURCES.SIMPLE.PICE error",e);
|
|
|
alarm("RESOURCES.SIMPLE.PICE接口访问异常,探测异常",mobile_user);
|
...
|
...
|
|