告警设置、告警上报
This commit is contained in:
@@ -7,6 +7,7 @@ import com.alibaba.fastjson2.TypeReference;
|
||||
import com.tongran.agent.client.core.config.GlobalConfig;
|
||||
import com.tongran.agent.client.core.enums.MsgEnum;
|
||||
import com.tongran.agent.client.core.eo.AgentVersionUpdateEO;
|
||||
import com.tongran.agent.client.core.eo.AlarmEO;
|
||||
import com.tongran.agent.client.core.eo.ScriptPolicyEO;
|
||||
import com.tongran.agent.client.netty.annotation.AgentDispatcher;
|
||||
import com.tongran.agent.client.netty.basics.AgentHandler;
|
||||
@@ -19,6 +20,7 @@ import com.tongran.agent.client.scheduler.service.Java8FileDownloader;
|
||||
import com.tongran.agent.client.scheduler.task.SpecificTimeRequest;
|
||||
import com.tongran.agent.client.scheduler.task.SpecificTimeTaskService;
|
||||
import com.tongran.agent.client.service.AgentService;
|
||||
import com.tongran.agent.client.utils.AgentDataUtil;
|
||||
import com.tongran.agent.client.utils.AgentUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -201,63 +203,24 @@ public class AgentEndpoint {
|
||||
public class AlarmSetHandler implements AgentHandler {
|
||||
@Override
|
||||
public UpMsgResponse upHandle(String data, String clientId) {
|
||||
// //更改全局变量
|
||||
// JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
// if(jsonObject.containsKey("switchBoard")){
|
||||
// String switchBoard = jsonObject.getString("switchBoard");
|
||||
// jsonObject = JSONObject.parseObject(switchBoard);
|
||||
// if(jsonObject.containsKey("community")){
|
||||
// GlobalConfig.SWITCH_COMMUNITY = jsonObject.getString("community");
|
||||
// }
|
||||
// if(jsonObject.containsKey("ip")){
|
||||
// GlobalConfig.SWITCH_IP = jsonObject.getString("ip");
|
||||
// }
|
||||
// if(jsonObject.containsKey("port")){
|
||||
// GlobalConfig.SWITCH_PORT = jsonObject.getInteger("port");
|
||||
// }
|
||||
// if(jsonObject.containsKey("netOID")){
|
||||
// String netOID = jsonObject.getString("netOID");
|
||||
// LinkedHashMap<String, String> map = JSON.parseObject(netOID, new TypeReference<LinkedHashMap<String, String>>() {});
|
||||
// GlobalConfig.SWITCH_NET_OID = map;
|
||||
// }
|
||||
// if(jsonObject.containsKey("moduleOID")){
|
||||
// String moduleOID = jsonObject.getString("moduleOID");
|
||||
// LinkedHashMap<String, String> map = JSON.parseObject(moduleOID, new TypeReference<LinkedHashMap<String, String>>() {});
|
||||
// GlobalConfig.SWITCH_MODULE_OID = map;
|
||||
// }
|
||||
// if(jsonObject.containsKey("mpuOID")){
|
||||
// String mpuOID = jsonObject.getString("mpuOID");
|
||||
// LinkedHashMap<String, String> map = JSON.parseObject(mpuOID, new TypeReference<LinkedHashMap<String, String>>() {});
|
||||
// GlobalConfig.SWITCH_MPU_OID = map;
|
||||
// }
|
||||
// if(jsonObject.containsKey("pwrOID")){
|
||||
// String pwrOID = jsonObject.getString("pwrOID");
|
||||
// LinkedHashMap<String, String> map = JSON.parseObject(pwrOID, new TypeReference<LinkedHashMap<String, String>>() {});
|
||||
// GlobalConfig.SWITCH_PWR_OID = map;
|
||||
// }
|
||||
// if(jsonObject.containsKey("fanOID")){
|
||||
// String fanOID = jsonObject.getString("fanOID");
|
||||
// LinkedHashMap<String, String> map = JSON.parseObject(fanOID, new TypeReference<LinkedHashMap<String, String>>() {});
|
||||
// GlobalConfig.SWITCH_FAN_OID = map;
|
||||
// }
|
||||
// if(jsonObject.containsKey("otherOID")){
|
||||
// String otherOID = jsonObject.getString("otherOID");
|
||||
// LinkedHashMap<String, String> map = JSON.parseObject(otherOID, new TypeReference<LinkedHashMap<String, String>>() {});
|
||||
// GlobalConfig.SWITCH_OTHER_OID = map;
|
||||
// }
|
||||
// }
|
||||
// GlobalConfig.isCollect = true;
|
||||
// GlobalConfig.CLIENT_ID = clientId;
|
||||
// //调用采集任务
|
||||
// try {
|
||||
// appInitializer.run();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// JSONObject json = new JSONObject();
|
||||
// json.put("resCode",1);
|
||||
//更改全局变量
|
||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
if(jsonObject.containsKey("alarms")){
|
||||
String alarms = jsonObject.getString("alarms");
|
||||
GlobalConfig.ALARM_LIST = JSON.parseObject(alarms, new TypeReference<List<AlarmEO>>() {});
|
||||
if(CollectionUtil.isNotEmpty(GlobalConfig.ALARM_LIST)){
|
||||
GlobalConfig.IS_ALARM = AgentDataUtil.hasAnyActiveAlarm(GlobalConfig.ALARM_LIST);
|
||||
}
|
||||
}
|
||||
agentService.alarmMonitor();
|
||||
long timestamp = System.currentTimeMillis();
|
||||
timestamp = Math.round(timestamp / 1000.0);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("resCode",1);
|
||||
json.put("resMag","");
|
||||
json.put("timestamp",timestamp);
|
||||
return UpMsgResponse.builder().clientId(clientId).dataType(MsgEnum.告警设置应答.getValue())
|
||||
.content("").build();
|
||||
.content(json.toString()).build();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user