1.增加上报开关,从配置文件里配置

2.port、rule上报任务
This commit is contained in:
chenjinsong
2018-10-09 18:11:38 +08:00
parent e0b516d3dd
commit 3a8a20de7b
6 changed files with 119 additions and 23 deletions

View File

@@ -2,10 +2,14 @@ package com.nms.thread;
import java.util.ArrayList;
import java.util.Date;
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;
@@ -30,7 +34,34 @@ public class NmsPortThread implements Runnable {
try {
connection = ConnectionOracle.getConnection();
NmsReportService service = new NmsReportService(connection);
//ArrayList<Map<String, String>> nmsRuleInfo = service.getNmsPortInfo(nowLong, nowLong-interval);
ArrayList<Map<String, String>> nmsPortInfo = service.getNmsPortInfo(nowLong, nowLong-interval);
if (nmsPortInfo != null && nmsPortInfo.size() > 0) {
Map<String, List<Map<String, String>>> data = new HashMap<String, List<Map<String, String>>>();
List<Map<String, String>> results = 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"));
result.put("nodeName", info.get("node_name"));
result.put("nodeIp", info.get("node_ip"));
result.put("portDesc", info.get("IFDESCR"));
result.put("bandwidth", info.get("IFSPEED"));
result.put("inoctets", info.get("IFINOCTETS"));
result.put("outoctets", info.get("IFOUTOCTETS"));
result.put("inoctetsSpeed", info.get("INOCTETSSPEED"));
result.put("outoctetsSpeed", info.get("OUTOCTETSSPEED"));
result.put("inpktsSpeed", info.get("INPKTSSPEED"));
result.put("outpktsSpeed", info.get("OUTPKTSSPEED"));
result.put("recvTime", info.get("DATA_CHECK_TIME"));
results.add(result);
}
data.put("trafficNetflowPortInfoList", results);
HttpClientUtil httpUtil = new HttpClientUtil();
JSONObject fromObject = JSONObject.fromObject(data);
httpUtil.post(BaseAction.rb.getString("nms.port.url"), fromObject.toString());
}
} catch (Exception e) {
logger.error(e);
} finally {