summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorchenjinsong <[email protected]>2018-10-26 11:08:18 +0800
committerchenjinsong <[email protected]>2018-10-26 11:08:18 +0800
commit0bec0e4071eb9b7efcf55c1cdd7d7ad626d4e207 (patch)
treebe668d72fffa6183f79c44fdc7dc6c9574942c81 /src
parentab59e338a154a1eca18fee247f8913f1ecb387f4 (diff)
修复上报功能的bug(时间区间不对)
Diffstat (limited to 'src')
-rw-r--r--src/com/nms/thread/NmsPortThread.java29
-rw-r--r--src/com/nms/thread/NmsRuleThread.java42
-rw-r--r--src/com/nms/thread/NmsStatusThread.java6
3 files changed, 43 insertions, 34 deletions
diff --git a/src/com/nms/thread/NmsPortThread.java b/src/com/nms/thread/NmsPortThread.java
index 6147090..0379df3 100644
--- a/src/com/nms/thread/NmsPortThread.java
+++ b/src/com/nms/thread/NmsPortThread.java
@@ -34,7 +34,7 @@ public class NmsPortThread implements Runnable {
try {
connection = ConnectionOracle.getConnection();
NmsReportService service = new NmsReportService(connection);
- ArrayList<Map<String, String>> nmsPortInfo = service.getNmsPortInfo(nowLong, nowLong-interval);
+ ArrayList<Map<String, String>> nmsPortInfo = service.getNmsPortInfo(nowLong, nowLong-interval*1000);
if (nmsPortInfo != null && nmsPortInfo.size() > 0) {
Map<String, List<Map<String, String>>> data = new HashMap<String, List<Map<String, String>>>();
@@ -42,18 +42,18 @@ public class NmsPortThread implements Runnable {
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"));
+ result.put("port", info.get("ifindex") == null ? "" : info.get("ifindex"));
+ result.put("nodeName", info.get("node_name") == null ? "" : info.get("node_name"));
+ result.put("nodeIp", info.get("node_ip") == null ? "" : info.get("node_ip"));
+ result.put("portDesc", info.get("IFDESCR") == null ? "" : info.get("IFDESCR"));
+ result.put("bandwidth", info.get("IFSPEED") == null ? "" : info.get("IFSPEED"));
+ result.put("inoctets", info.get("IFINOCTETS") == null ? "" : info.get("IFINOCTETS"));
+ result.put("outoctets", info.get("IFOUTOCTETS") == null ? "" : info.get("IFOUTOCTETS"));
+ result.put("inoctetsSpeed", info.get("INOCTETSSPEED") == null ? "" : info.get("INOCTETSSPEED"));
+ result.put("outoctetsSpeed", info.get("OUTOCTETSSPEED") == null ? "" : info.get("OUTOCTETSSPEED"));
+ result.put("inpktsSpeed", info.get("INPKTSSPEED") == null ? "" : info.get("INPKTSSPEED"));
+ result.put("outpktsSpeed", info.get("OUTPKTSSPEED") == null ? "" : info.get("OUTPKTSSPEED"));
+ result.put("recvTime", info.get("DATA_CHECK_TIME") == null ? "" : info.get("DATA_CHECK_TIME"));
results.add(result);
}
data.put("trafficNetflowPortInfoList", results);
@@ -61,6 +61,9 @@ public class NmsPortThread implements Runnable {
JSONObject fromObject = JSONObject.fromObject(data);
httpUtil.post(BaseAction.rb.getString("nms.port.url"), fromObject.toString());
+ logger.info("port上报完毕");
+ } else {
+ logger.info("暂无可上报的port数据");
}
} catch (Exception e) {
logger.error(e);
diff --git a/src/com/nms/thread/NmsRuleThread.java b/src/com/nms/thread/NmsRuleThread.java
index 6dd5fa6..5dd505a 100644
--- a/src/com/nms/thread/NmsRuleThread.java
+++ b/src/com/nms/thread/NmsRuleThread.java
@@ -35,7 +35,7 @@ public class NmsRuleThread implements Runnable {
try {
connection = ConnectionOracle.getConnection();
NmsReportService service = new NmsReportService(connection);
- ArrayList<Map<String, String>> nmsRuleInfo = service.getNmsRuleInfo(nowLong, nowLong-interval);
+ ArrayList<Map<String, String>> nmsRuleInfo = service.getNmsRuleInfo(nowLong, nowLong-interval*1000);
if (nmsRuleInfo != null && nmsRuleInfo.size() > 0) {
Map<String, List<Map<String, String>>> data = new HashMap<String, List<Map<String, String>>>();
@@ -43,31 +43,35 @@ public class NmsRuleThread implements Runnable {
for (Map<String, String> info : nmsRuleInfo) {
Map<String, String> result = new HashMap<String, String>();
- result.put("detectionInfoId", info.get("detection_info_id"));
- result.put("serviceIndex", info.get("ServiceIndex"));
- result.put("serviceCode", info.get("ServiceCode"));
- result.put("serviceDesc", info.get("ServiceDesc"));
- result.put("agedTime", info.get("agedTime"));
- result.put("clientNum", info.get("ClientNum"));
- result.put("refluxPort", info.get("RefluxPort"));
- result.put("ruleNumber", info.get("RuleNumber"));
- result.put("usedRuleNum", info.get("usedRuleNum"));
- result.put("leftRuleNum", info.get("leftRuleNum"));
- result.put("hitTotalNum", info.get("HitTotalNum"));
- result.put("detectionedState", info.get("DETECTIONED_STATE"));
- result.put("seqId", info.get("SEQ_ID"));
- result.put("detectionSetInfoId", info.get("DETECTION_SET_INFO_ID"));
- result.put("dataCheckTime", info.get("data_check_time"));
- result.put("dataArriveTime", info.get("data_arrive_time"));
- result.put("dataCheckTimeDigital", info.get("data_check_time_digital"));
- result.put("dataArriveTimeDigital", info.get("data_arrive_time_digital"));
+ result.put("detectionInfoId", info.get("detection_info_id") == null ? "" : info.get("detection_info_id"));
+ result.put("serviceIndex", info.get("ServiceIndex") == null ? "" : info.get("ServiceIndex"));
+ result.put("serviceCode", info.get("ServiceCode") == null ? "" : info.get("ServiceCode"));
+ result.put("serviceDesc", info.get("ServiceDesc") == null ? "" : info.get("ServiceDesc"));
+ result.put("agedTime", info.get("agedTime") == null ? "" : info.get("agedTime"));
+ result.put("clientNum", info.get("ClientNum") == null ? "" : info.get("ClientNum"));
+ result.put("refluxPort", info.get("RefluxPort") == null ? "" : info.get("RefluxPort"));
+ result.put("ruleNumber", info.get("RuleNumber") == null ? "" : info.get("RuleNumber"));
+ result.put("usedRuleNum", info.get("usedRuleNum") == null ? "" : info.get("usedRuleNum"));
+ result.put("leftRuleNum", info.get("leftRuleNum") == null ? "" : info.get("leftRuleNum"));
+ result.put("hitTotalNum", info.get("HitTotalNum") == null ? "" : info.get("HitTotalNum"));
+ result.put("detectionedState", info.get("DETECTIONED_STATE") == null ? "" : info.get("DETECTIONED_STATE"));
+ result.put("seqId", info.get("SEQ_ID") == null ? "" : info.get("SEQ_ID"));
+ result.put("detectionSetInfoId", info.get("DETECTION_SET_INFO_ID") == null ? "" : info.get("DETECTION_SET_INFO_ID"));
+ result.put("dataCheckTime", info.get("data_check_time") == null ? "" : info.get("data_check_time"));
+ result.put("dataArriveTime", info.get("data_arrive_time") == null ? "" : info.get("data_arrive_time"));
+ result.put("dataCheckTimeDigital", info.get("data_check_time_digital") == null ? "" : info.get("data_check_time_digital"));
+ result.put("dataArriveTimeDigital", info.get("data_arrive_time_digital") == null ? "" : info.get("data_arrive_time_digital"));
results.add(result);
}
data.put("nmsDiRuleList", results);
HttpClientUtil httpUtil = new HttpClientUtil();
JSONObject fromObject = JSONObject.fromObject(data);
+ logger.info(BaseAction.rb.getString("nms.rule.url"));
httpUtil.post(BaseAction.rb.getString("nms.rule.url"), fromObject.toString());
+ logger.info("rule上报完毕");
+ } else {
+ logger.info("暂无可上报的rule数据");
}
} catch (Exception e) {
logger.error(e);
diff --git a/src/com/nms/thread/NmsStatusThread.java b/src/com/nms/thread/NmsStatusThread.java
index 8e9da8a..89e7e53 100644
--- a/src/com/nms/thread/NmsStatusThread.java
+++ b/src/com/nms/thread/NmsStatusThread.java
@@ -70,8 +70,8 @@ public class NmsStatusThread implements Runnable {
normal++;
} else {
Map<String, String> abnormal = new HashMap<String, String>();
- abnormal.put("hostName", m.get("host_name"));
- abnormal.put("ip", m.get("node_ip"));
+ abnormal.put("hostName", m.get("host_name") == null ? "" : m.get("host_name"));
+ abnormal.put("ip", m.get("node_ip") == null ? "" : m.get("node_ip"));
abnormalList.add(abnormal);
}
}
@@ -90,7 +90,9 @@ public class NmsStatusThread implements Runnable {
HttpClientUtil httpUtil = new HttpClientUtil();
JSONObject fromObject = JSONObject.fromObject(map);
+ logger.info(BaseAction.rb.getString("nms.status.url"));
httpUtil.post(BaseAction.rb.getString("nms.status.url"), fromObject.toString());
+ logger.info("status上报完毕");
} catch (Exception e) {
logger.error(e);
} finally {