1、新增串联设备端口状态与配置不一致告警推送接口
This commit is contained in:
@@ -6,17 +6,16 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
import nis.nms.util.BaseAction;
|
||||
import nis.nms.util.ConnectionOracle;
|
||||
import nis.nms.util.HttpClientUtil;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.json.JsonFormat;
|
||||
|
||||
import com.nms.thread.service.NmsReportService;
|
||||
|
||||
import nis.nms.util.BaseAction;
|
||||
import nis.nms.util.ConnectionOracle;
|
||||
import nis.nms.util.HttpClientUtil;
|
||||
|
||||
public class NmsPortThread implements Runnable {
|
||||
|
||||
private static Logger logger = Logger.getLogger(NmsPortThread.class);
|
||||
@@ -40,10 +39,15 @@ public class NmsPortThread implements Runnable {
|
||||
NmsReportService service = new NmsReportService(connection);
|
||||
ArrayList<Map<String, String>> nmsPortInfo = service.getNmsPortInfo(nowLong, nowLong-interval*1000);
|
||||
if (nmsPortInfo != null && nmsPortInfo.size() > 0) {
|
||||
ArrayList<Map<String,String>> portStatusInfo = service.getPortStatusInfo();//串联设备端口配置状态
|
||||
Map<String,String> portStatusInfoMap = new HashMap<String,String>();
|
||||
for(Map<String,String> map : portStatusInfo){
|
||||
portStatusInfoMap.put(map.get("seqid")+map.get("name_flag"), map.get("port_set_state"));
|
||||
}
|
||||
logger.debug(String.format("查询数量:%s", nmsPortInfo.size()));
|
||||
Map<String, List<Map<String, String>>> data = new HashMap<String, List<Map<String, String>>>();
|
||||
List<Map<String, String>> results = new ArrayList<Map<String, String>>();
|
||||
|
||||
List<Map<String, String>> portStatusWarn = new ArrayList<Map<String, String>>();
|
||||
for (Map<String, String> info : nmsPortInfo) {
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
result.put("port", info.get("ifindex") == null ? "" : info.get("ifindex"));
|
||||
@@ -60,12 +64,31 @@ public class NmsPortThread implements Runnable {
|
||||
result.put("recvTime", info.get("DATA_CHECK_TIME") == null ? "" : info.get("DATA_CHECK_TIME"));
|
||||
result.put("entranceId", info.get("ADDR") == null ? "" : info.get("ADDR"));
|
||||
results.add(result);
|
||||
//整理端口状态告警推送
|
||||
String seqId = info.get("seq_id");
|
||||
String portName = info.get("IFDESCR");
|
||||
String adminStatus = info.get("IFADMINSTATUS");
|
||||
String setStatus = portStatusInfoMap.get(seqId + portName);//配置状态
|
||||
if(setStatus != null && !setStatus.equals(adminStatus)){
|
||||
Map<String,String> sw = new HashMap<String,String>();
|
||||
sw.put("area", info.get("ADDR"));
|
||||
sw.put("port", portName);
|
||||
sw.put("status", adminStatus);
|
||||
sw.put("commitTime", info.get("DATA_CHECK_TIME"));
|
||||
portStatusWarn.add(sw);
|
||||
}
|
||||
}
|
||||
data.put("trafficNetflowPortInfoList", results);
|
||||
HttpClientUtil httpUtil = new HttpClientUtil();
|
||||
String dataStr = Json.toJson(data,JsonFormat.tidy());
|
||||
logger.debug("url:" +BaseAction.rb.getString("nms.port.url") + ",data :" + dataStr);
|
||||
httpUtil.post(BaseAction.rb.getString("nms.port.url"), dataStr);
|
||||
String url = BaseAction.rb.getString("nms.port.url");
|
||||
httpUtil.post(url, dataStr);
|
||||
//推送端口状态告警
|
||||
data.clear();
|
||||
data.put("trafficSeriesDevicePortInfoList", portStatusWarn);
|
||||
dataStr = Json.toJson(data,JsonFormat.tidy());
|
||||
url = BaseAction.rb.getString("nms.port.warn.url");
|
||||
httpUtil.post(url, dataStr);
|
||||
logger.info("port上报完毕");
|
||||
} else {
|
||||
logger.info("暂无可上报的port数据");
|
||||
|
||||
@@ -86,6 +86,7 @@ public class NmsReportService {
|
||||
//end=1539073220004l,start=1539064699984l
|
||||
//只查询 网元类型为 特种设备:1的端口信息
|
||||
String sql = "SELECT DISTINCT nt.node_ip, nt.node_name, ds.ifindex, ds.IFDESCR, ds.IFSPEED, ds.IFINOCTETS, ds.IFOUTOCTETS,ds.INOCTETSSPEED,ds.INPKTSSPEED,ds.OUTOCTETSSPEED, ds.OUTPKTSSPEED, ds.DATA_CHECK_TIME,st.ADDR "
|
||||
+ " ds.IFADMINSTATUS ,nt.seq_id"
|
||||
+ "FROM di_switchport ds "
|
||||
+ "LEFT JOIN node_table nt ON nt.seq_id=ds.seq_id "
|
||||
+ " left join system_table st on st.system_id = nt.system_id "
|
||||
@@ -104,6 +105,8 @@ public class NmsReportService {
|
||||
fields.add("OUTPKTSSPEED");
|
||||
fields.add("DATA_CHECK_TIME");
|
||||
fields.add("ADDR");
|
||||
fields.add("IFADMINSTATUS");
|
||||
fields.add("seq_id");
|
||||
|
||||
try {
|
||||
ArrayList<Map<String, String>> dbSelect = dao.dbSelect(sql, fields);
|
||||
@@ -113,4 +116,30 @@ public class NmsReportService {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取 端口状态配置信息
|
||||
* @return
|
||||
*/
|
||||
public ArrayList<Map<String, String>> getPortStatusInfo() {
|
||||
//end=1539073220004l,start=1539064699984l
|
||||
//只查询 网元类型为 特种设备:1的端口信息
|
||||
StringBuffer sql = new StringBuffer();
|
||||
sql.append(" select t.seqid, t.name_flag,(case when port_set_state is null then 1 else port_set_state end) state from node_figure_info t ");
|
||||
sql.append(" where ");
|
||||
sql.append(" t.name_flag is not null and t.is_leaf = 1 ");
|
||||
ArrayList<String> fields = new ArrayList<String>();
|
||||
fields.add("seqid");
|
||||
fields.add("name_flag");
|
||||
fields.add("state");
|
||||
try {
|
||||
ArrayList<Map<String, String>> dbSelect = dao.dbSelect(sql.toString(), fields);
|
||||
return dbSelect;
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@ nms.status.setId=7
|
||||
nms.status.url=http://10.0.7.21/galaxy-service//service/nms/v1/saveServerStatus
|
||||
nms.port.url=http://10.0.7.21/galaxy-service/service/nms/v1/trafficNetflowPortInfo
|
||||
nms.rule.url=http://10.0.7.21/galaxy-service/service/nms/v1/saveNmsDiRule
|
||||
nms.port.warn.url=http://192.168.11.209:8080/galaxy-service/service/nms/v1/trafficSeriesDevicePortInfo
|
||||
#默认节点组id
|
||||
default.nodeGroupId=100000
|
||||
prefabricate.view=100000,100003,100004,100005,100006,100007,100033,100035,100037
|
||||
|
||||
Reference in New Issue
Block a user