Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7e60e54a5 | ||
|
|
bd3ab7b608 | ||
|
|
1eacc059de | ||
|
|
3013ef7484 | ||
|
|
725dc8ad84 | ||
|
|
fc5f49a016 | ||
|
|
25f7bc1c6b | ||
|
|
238b257634 | ||
|
|
dcb7995f88 | ||
|
|
e0737f8a42 | ||
|
|
ba1c9599dc | ||
|
|
f39f23aced | ||
|
|
d94384184b | ||
|
|
ba43f4203d | ||
|
|
74c3c0b303 | ||
|
|
8c21fd7620 | ||
|
|
f779ad6886 | ||
|
|
c1742aa790 | ||
|
|
b3c3befea2 | ||
|
|
ddc5ea685a | ||
|
|
32a1746aaa | ||
|
|
6850bf8980 | ||
|
|
f7aaec06f6 | ||
|
|
aee6676d0d | ||
|
|
5caffbd2c5 | ||
|
|
7e4b6cc905 | ||
|
|
3d031c3811 | ||
|
|
e10049894b | ||
|
|
f37c137903 |
73
.classpath
73
.classpath
@@ -1,36 +1,37 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.7.0_45"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
<classpathentry kind="lib" path="lib/commons-beanutils-1.7.jar"/>
|
<classpathentry kind="lib" path="lib/commons-beanutils-1.7.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/commons-collections.jar"/>
|
<classpathentry kind="lib" path="lib/commons-collections.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/commons-io.jar"/>
|
<classpathentry kind="lib" path="lib/commons-io.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/commons-lang.jar"/>
|
<classpathentry kind="lib" path="lib/commons-lang.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/commons-logging.jar"/>
|
<classpathentry kind="lib" path="lib/commons-logging.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/commons-net-ftp-2.0.jar"/>
|
<classpathentry kind="lib" path="lib/commons-net-ftp-2.0.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/ezmorph-1.0.4.jar"/>
|
<classpathentry kind="lib" path="lib/ezmorph-1.0.4.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/jpcap.jar"/>
|
<classpathentry kind="lib" path="lib/jpcap.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/json-lib-2.2.2-jdk15.jar"/>
|
<classpathentry kind="lib" path="lib/json-lib-2.2.2-jdk15.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/junit.jar"/>
|
<classpathentry kind="lib" path="lib/junit.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/ojdbc14.jar"/>
|
<classpathentry kind="lib" path="lib/ojdbc14.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/mail.jar"/>
|
<classpathentry kind="lib" path="lib/mail.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/ostermillerutils_1_07_00.jar"/>
|
<classpathentry kind="lib" path="lib/ostermillerutils_1_07_00.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/sigar.jar"/>
|
<classpathentry kind="lib" path="lib/sigar.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/ObjectSNMP.jar"/>
|
<classpathentry kind="lib" path="lib/ObjectSNMP.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/fileComment.jar"/>
|
<classpathentry kind="lib" path="lib/fileComment.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/snmp4j-2.0.3.jar"/>
|
<classpathentry kind="lib" path="lib/snmp4j-2.0.3.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/ant.jar"/>
|
<classpathentry kind="lib" path="lib/ant.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
|
<classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/ganymed-ssh2-build210.jar"/>
|
<classpathentry kind="lib" path="lib/ganymed-ssh2-build210.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/bonecp/bonecp-0.8.0-rc2.jar"/>
|
<classpathentry kind="lib" path="lib/bonecp/bonecp-0.8.0-rc2.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/bonecp/guava-14.0-rc3.jar"/>
|
<classpathentry kind="lib" path="lib/bonecp/guava-14.0-rc3.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/bonecp/slf4j-api-1.6.1.jar"/>
|
<classpathentry kind="lib" path="lib/bonecp/slf4j-api-1.6.1.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/bonecp/slf4j-log4j12-1.6.1.jar"/>
|
<classpathentry kind="lib" path="lib/bonecp/slf4j-log4j12-1.6.1.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/mysql-connector-java-5.1.0-bin.jar"/>
|
<classpathentry kind="lib" path="lib/mysql-connector-java-5.1.0-bin.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/tools-1.8.0.jar"/>
|
<classpathentry kind="lib" path="lib/tools-1.8.0.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/jconsole-1.8.0.jar"/>
|
<classpathentry kind="lib" path="lib/jconsole-1.8.0.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/druid-1.1.10.jar"/>
|
<classpathentry kind="lib" path="lib/druid-1.1.10.jar" sourcepath="C:/Users/ThinkPad/.m2/repository/com/alibaba/druid/1.1.10/druid-1.1.10-sources.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/FUtil-0.5.jar"/>
|
<classpathentry kind="lib" path="lib/FUtil-0.5.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/netty-all-4.1.28.Final.jar" sourcepath="lib/netty-all-4.1.28.Final-sources.jar"/>
|
<classpathentry kind="lib" path="lib/netty-all-4.1.28.Final.jar" sourcepath="lib/netty-all-4.1.28.Final-sources.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="lib" path="lib/nutz-1.r.66.jar"/>
|
||||||
</classpath>
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
||||||
|
|||||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/bin/
|
||||||
BIN
lib/nutz-1.r.66.jar
Normal file
BIN
lib/nutz-1.r.66.jar
Normal file
Binary file not shown.
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
DEFAULT_DATA_DIR="/home/nms/nmsdata"
|
DEFAULT_DATA_DIR="/home/ceiec/nms/nmsdata"
|
||||||
DEFAULT_INSTALL_DIR="/home/nms/datacontroller"
|
DEFAULT_INSTALL_DIR="/home/ceiec/nms/datacontroller"
|
||||||
|
|
||||||
# --- set install dir
|
# --- set install dir
|
||||||
PRG="$0"
|
PRG="$0"
|
||||||
@@ -54,10 +54,10 @@ fi
|
|||||||
# --- install jdk
|
# --- install jdk
|
||||||
cd "$INSTALL_DIR"/..
|
cd "$INSTALL_DIR"/..
|
||||||
NMS_JDK="$(pwd)/nmsjdk"
|
NMS_JDK="$(pwd)/nmsjdk"
|
||||||
JDK_DIR="$(pwd)/jdk1.7.0_80"
|
JDK_DIR="$(pwd)/jre1.7.0_80"
|
||||||
JDK_BIN_FILE=$CUR_PRGDIR"/jre_install/jdk-7u80-linux-i586.tar.gz"
|
JDK_BIN_FILE=$CUR_PRGDIR"/jre_install/jre-7u80-linux-i586.tar.gz"
|
||||||
if [ "`uname -i`" = "x86_64" ];then
|
if [ "`uname -i`" = "x86_64" ];then
|
||||||
JDK_BIN_FILE=$CUR_PRGDIR"/jre_install/jdk-7u80-linux-x64.tar.gz"
|
JDK_BIN_FILE=$CUR_PRGDIR"/jre_install/jre-7u80-linux-x64.tar.gz"
|
||||||
fi
|
fi
|
||||||
if [ $install_jdk = 1 ]
|
if [ $install_jdk = 1 ]
|
||||||
then
|
then
|
||||||
@@ -223,7 +223,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#-----------db url
|
#-----------db url
|
||||||
db_url="jdbc:mysql://"${db_host}":"${db_port}"/nms?useUnicode=true&characterEncoding=utf-8&useOldAliasMetadataBehavior=true&rewriteBatchedStatements=true"
|
db_url="jdbc:mysql://"${db_host}":"${db_port}"/nms?useUnicode=true\&characterEncoding=utf-8\&useOldAliasMetadataBehavior=true\&rewriteBatchedStatements=true"
|
||||||
|
|
||||||
#-------------db username
|
#-------------db username
|
||||||
echo -n "enter database username: "
|
echo -n "enter database username: "
|
||||||
|
|||||||
@@ -134,7 +134,18 @@ elif [ "$1" = "stop" ]; then
|
|||||||
echo "$name kill ok !!!!!!!!!!!!!"
|
echo "$name kill ok !!!!!!!!!!!!!"
|
||||||
else
|
else
|
||||||
echo "$name is not start!!!!!!!!!!!"
|
echo "$name is not start!!!!!!!!!!!"
|
||||||
fi
|
fi
|
||||||
|
elif [ "$1" = "boot-up" ]; then
|
||||||
|
#设置开机自启动
|
||||||
|
if [ -z "$(cat /etc/rc.local|grep -E "^\s*$DATACONTROLLER_HOME/shell/startup.sh")" ]
|
||||||
|
then
|
||||||
|
echo "">> /etc/rc.local
|
||||||
|
echo "########## datacontroller开机启动 ###########" >> /etc/rc.local
|
||||||
|
echo $DATACONTROLLER_HOME"/shell/startup.sh" >> /etc/rc.local
|
||||||
|
echo "Boot-up settings complete!"
|
||||||
|
else
|
||||||
|
echo "Boot-up has been set up without modification."
|
||||||
|
fi
|
||||||
elif [ "$1" = "restart" ] ; then
|
elif [ "$1" = "restart" ] ; then
|
||||||
getPid
|
getPid
|
||||||
if [ -n "$proc_id" ]
|
if [ -n "$proc_id" ]
|
||||||
|
|||||||
@@ -3,15 +3,18 @@ package com.nms.server.bean;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
import com.fang.U;
|
import com.fang.U;
|
||||||
import com.nms.server.common.Common;
|
import com.nms.server.common.Common;
|
||||||
import com.nms.server.common.Config;
|
|
||||||
import com.nms.server.dao.OracleToMysql;
|
import com.nms.server.dao.OracleToMysql;
|
||||||
|
|
||||||
public class DetectInfo {
|
public class DetectInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数组大小
|
||||||
|
*/
|
||||||
|
public static final int DETEC_ARR_SIZE = 34;
|
||||||
|
|
||||||
public static final int SEQID = 0; //seqId
|
public static final int SEQID = 0; //seqId
|
||||||
public static final int SETINFOID = 1; //监测设置ID
|
public static final int SETINFOID = 1; //监测设置ID
|
||||||
public static final int CHECKTYPE = 2; //监测类别
|
public static final int CHECKTYPE = 2; //监测类别
|
||||||
@@ -55,6 +58,10 @@ public class DetectInfo {
|
|||||||
public static final int SHOWNUMLIST = 30;
|
public static final int SHOWNUMLIST = 30;
|
||||||
public static final int PLEVELLIST = 31;
|
public static final int PLEVELLIST = 31;
|
||||||
public static final int ALARMLIST = 32;
|
public static final int ALARMLIST = 32;
|
||||||
|
/**
|
||||||
|
* 告警恢复标识
|
||||||
|
*/
|
||||||
|
public static final int WARN_2_OK = 33;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* detect_queue 的 key
|
* detect_queue 的 key
|
||||||
@@ -314,7 +321,7 @@ public class DetectInfo {
|
|||||||
*/
|
*/
|
||||||
public static String getInsertWarningSql(){
|
public static String getInsertWarningSql(){
|
||||||
//插入warning表
|
//插入warning表
|
||||||
String insertWaringSql = "INSERT INTO DETECTION_INFO_WARNING (ID, DETECTION_SET_INFO_ID, DETECTION_STATE_INFO, " +
|
String insertWaringSql = "INSERT INTO DETECTION_INFO_WARNING (DETECTION_INFO_ID, DETECTION_SET_INFO_ID, DETECTION_STATE_INFO, " +
|
||||||
"PERFORMACE_DATA, CURRENT_TIMES, START_TIME, DELAY_TIME, NEXT_CHECK_TIME, " +
|
"PERFORMACE_DATA, CURRENT_TIMES, START_TIME, DELAY_TIME, NEXT_CHECK_TIME, " +
|
||||||
"POLICE_LEVEL, DATA_CHECK_TIME, DATA_ARRIVE_TIME, DETECTIONED_STATE, " +
|
"POLICE_LEVEL, DATA_CHECK_TIME, DATA_ARRIVE_TIME, DETECTIONED_STATE, " +
|
||||||
"DATA_CHECK_TIME_DIGITAL, DATA_ARRIVE_TIME_DIGITAL, SEQ_ID, POLICE_EMERGENT)"
|
"DATA_CHECK_TIME_DIGITAL, DATA_ARRIVE_TIME_DIGITAL, SEQ_ID, POLICE_EMERGENT)"
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import java.sql.Statement;
|
|||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -35,6 +36,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.nutz.json.Json;
|
||||||
|
import org.nutz.json.JsonFormat;
|
||||||
import org.snmp4j.Snmp;
|
import org.snmp4j.Snmp;
|
||||||
|
|
||||||
import com.fang.U;
|
import com.fang.U;
|
||||||
@@ -51,7 +54,6 @@ import com.nms.server.bean.SetInfo;
|
|||||||
import com.nms.server.bean.SimpleNode;
|
import com.nms.server.bean.SimpleNode;
|
||||||
import com.nms.server.bean.TableColumnsModel;
|
import com.nms.server.bean.TableColumnsModel;
|
||||||
import com.nms.server.bean.TableModel;
|
import com.nms.server.bean.TableModel;
|
||||||
import com.nms.server.dao.CommonDao;
|
|
||||||
import com.nms.server.thread.alarmData.AlarmDataResoveThread;
|
import com.nms.server.thread.alarmData.AlarmDataResoveThread;
|
||||||
import com.nms.server.thread.detecData.NewDetecDataResoveThread;
|
import com.nms.server.thread.detecData.NewDetecDataResoveThread;
|
||||||
import com.nms.server.thread.detectDataHandler.DataInsertManagerThread;
|
import com.nms.server.thread.detectDataHandler.DataInsertManagerThread;
|
||||||
@@ -206,6 +208,12 @@ public class Common {
|
|||||||
private static final Semaphore missionSemaphore = new Semaphore(Constants.MISSION_RELEASE_SEMAPHORE_MAX,true); //任务通信线程最大并发数
|
private static final Semaphore missionSemaphore = new Semaphore(Constants.MISSION_RELEASE_SEMAPHORE_MAX,true); //任务通信线程最大并发数
|
||||||
private static final Semaphore monitorSemaphore = new Semaphore(Constants.DETEC_RELEASE_SEMAPHORE_MAX,true); //主动监测线程最大并发数
|
private static final Semaphore monitorSemaphore = new Semaphore(Constants.DETEC_RELEASE_SEMAPHORE_MAX,true); //主动监测线程最大并发数
|
||||||
private static final Semaphore changeSemaphore = new Semaphore(Constants.CHANGE_RELEASE_SEMAPHORE_MAX,true); //主动监测线程最大并发数
|
private static final Semaphore changeSemaphore = new Semaphore(Constants.CHANGE_RELEASE_SEMAPHORE_MAX,true); //主动监测线程最大并发数
|
||||||
|
/**
|
||||||
|
* socket server 并发连接 信号量
|
||||||
|
*/
|
||||||
|
private static final Semaphore SERVER_ACCEPT_SEMAPHORE = new Semaphore(Constants.SERVER_ACCEPT_SEMAPHORE_MAX,true); //
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// #---任务结果数据集合
|
// #---任务结果数据集合
|
||||||
private static final LinkedList<MissionResult2> missionResult2List1 = new LinkedList<MissionResult2>();
|
private static final LinkedList<MissionResult2> missionResult2List1 = new LinkedList<MissionResult2>();
|
||||||
@@ -308,6 +316,7 @@ public class Common {
|
|||||||
logger.debug("缓存中任务并发剩余许可:"+(missionSemaphore.availablePermits()));
|
logger.debug("缓存中任务并发剩余许可:"+(missionSemaphore.availablePermits()));
|
||||||
logger.debug("缓存中监测并发剩余许可:"+(monitorSemaphore.availablePermits()));
|
logger.debug("缓存中监测并发剩余许可:"+(monitorSemaphore.availablePermits()));
|
||||||
logger.debug("缓存中变更并发剩余许可:"+(changeSemaphore.availablePermits()));
|
logger.debug("缓存中变更并发剩余许可:"+(changeSemaphore.availablePermits()));
|
||||||
|
logger.debug("缓存中server并发剩余许可:"+(SERVER_ACCEPT_SEMAPHORE.availablePermits()));
|
||||||
|
|
||||||
// logger.debug("基本线程池用量:"+(service.));
|
// logger.debug("基本线程池用量:"+(service.));
|
||||||
// logger.debug("定时线程池用量:"+(scheduled));
|
// logger.debug("定时线程池用量:"+(scheduled));
|
||||||
@@ -493,8 +502,13 @@ public class Common {
|
|||||||
logger.debug("监测数据 添加到 集合2");
|
logger.debug("监测数据 添加到 集合2");
|
||||||
deteDataList2.add(dsb); }
|
deteDataList2.add(dsb); }
|
||||||
}*/
|
}*/
|
||||||
logger.debug(new String(dsb));
|
if(Constants.DEBUG_COMMON_ADDDETEDATA) {
|
||||||
DETE_DATA_QUEUE.add(dsb);
|
logger.debug(new String(dsb));
|
||||||
|
}
|
||||||
|
boolean add = DETE_DATA_QUEUE.add(dsb);
|
||||||
|
if(!add) {
|
||||||
|
logger.warn("监测数据添加失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//无监测数据列表增加删除的同步操作
|
//无监测数据列表增加删除的同步操作
|
||||||
@@ -939,7 +953,7 @@ public class Common {
|
|||||||
datas[5] = System.currentTimeMillis()+"";
|
datas[5] = System.currentTimeMillis()+"";
|
||||||
datas[6] = level+"";
|
datas[6] = level+"";
|
||||||
datas[7] = state+"";//正常、异常
|
datas[7] = state+"";//正常、异常
|
||||||
datas[8] = exInfo==null?"":exInfo.length()>250?exInfo.substring(0, 250):exInfo;
|
datas[8] = exInfo==null?"":exInfo;
|
||||||
return datas;
|
return datas;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1016,6 +1030,30 @@ public class Common {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取server 信号
|
||||||
|
* @throws InterruptedException
|
||||||
|
*/
|
||||||
|
public static void acquireServerSemaphore() throws InterruptedException {
|
||||||
|
if(Constants.SERVER_ACCEPT_SEMAPHORE_FLAG){//开启client 连接数限制
|
||||||
|
SERVER_ACCEPT_SEMAPHORE.acquire();
|
||||||
|
logger.debug("Server Semaphore 已申请 剩余可用许可:> "+SERVER_ACCEPT_SEMAPHORE.availablePermits());
|
||||||
|
}else{
|
||||||
|
logger.debug("禁用 Server Semaphore ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 释放 server 信号
|
||||||
|
*/
|
||||||
|
public static void releaseServerSemaphore() {
|
||||||
|
if(Constants.SERVER_ACCEPT_SEMAPHORE_FLAG){//开启client 连接数限制
|
||||||
|
SERVER_ACCEPT_SEMAPHORE.release();
|
||||||
|
logger.debug("Server Semaphore 已释放 当前可用许可:> "+SERVER_ACCEPT_SEMAPHORE.availablePermits());
|
||||||
|
}else{
|
||||||
|
logger.debug("禁用 Server Semaphore ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将任务结果存放到任务结果集合中
|
* 将任务结果存放到任务结果集合中
|
||||||
@@ -1505,11 +1543,10 @@ public class Common {
|
|||||||
//获得当前的报警设置信息,与相应字段值比较
|
//获得当前的报警设置信息,与相应字段值比较
|
||||||
public static String[] getAlarmState(List<AlarmInfo> alarmInfos, String[] sysData) throws Exception{
|
public static String[] getAlarmState(List<AlarmInfo> alarmInfos, String[] sysData) throws Exception{
|
||||||
String[] strs = null;
|
String[] strs = null;
|
||||||
// logger.debug("!!you gaojing o "+(alarmInfos==null?null:alarmInfos.size()));
|
logger.debug("alarm Infos : "+(alarmInfos==null?null:Json.toJson(alarmInfos,JsonFormat.tidy())));
|
||||||
if(alarmInfos!=null){
|
if(alarmInfos!=null){
|
||||||
strs = new String[]{"", "", ""};
|
strs = new String[]{"", "", ""};
|
||||||
for(AlarmInfo alarm : alarmInfos){
|
for(AlarmInfo alarm : alarmInfos){
|
||||||
// logger.debug("!!you gaojing o "+alarm.getPoliceValue());
|
|
||||||
if(sysData.length>=alarm.getShowNum()){
|
if(sysData.length>=alarm.getShowNum()){
|
||||||
if(sysData[alarm.getShowNum()-1]==null){
|
if(sysData[alarm.getShowNum()-1]==null){
|
||||||
logger.error("Monitoring data is empty and can not do alarm verification");
|
logger.error("Monitoring data is empty and can not do alarm verification");
|
||||||
@@ -2472,6 +2509,188 @@ public class Common {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 告警判断
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Object alarmJudgement(List<List<String>> data) {
|
||||||
|
if(data != null) {
|
||||||
|
List<String> pubData = data.get(0);
|
||||||
|
if(pubData.size() > 12){//旧格式 解析
|
||||||
|
logger.debug("旧格式数据,暂不实现");
|
||||||
|
}else if(pubData.size() <12){
|
||||||
|
logger.debug( "基本数据解析长度:"+pubData.size()+" 小于最小解析标准,不予解析;");
|
||||||
|
}else{//新格式 解析
|
||||||
|
/**
|
||||||
|
* 公共部分解析格式:
|
||||||
|
* seqId,
|
||||||
|
* 监测设置ID,
|
||||||
|
* 监测类别,
|
||||||
|
* 进程名称(监测类别设置名称),
|
||||||
|
* 监测服务启动时间,
|
||||||
|
* 检测时延(秒),
|
||||||
|
* 本次检测时间,
|
||||||
|
* 尝试次数,
|
||||||
|
* 下次计划监测时间,
|
||||||
|
* 执行状态是否成功是否正常,
|
||||||
|
* 状态信息(描述信息),
|
||||||
|
* 性能数据
|
||||||
|
**/
|
||||||
|
logger.debug(String.format("告警判断-新格式数据:%s", Arrays.toString(pubData.toArray())));
|
||||||
|
String seqId = pubData.get(0);//seqId
|
||||||
|
String setInfoId = pubData.get(1);//监测设置id
|
||||||
|
String checkType = pubData.get(2);// 监测类别
|
||||||
|
String detectIden = pubData.get(3);//进程名称(监测类别设置名称)
|
||||||
|
StringBuilder infoSb = new StringBuilder();
|
||||||
|
int detectStatus = Integer.valueOf(pubData.get(9));//状态
|
||||||
|
List<AlarmInfo> alarmInfoList = Common.getAlarmInfoMap().get(setInfoId);
|
||||||
|
if(data.size() < 3) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
for(int i = 2 ;i< data.size();i++) {
|
||||||
|
List<String> detailList = data.get(i);//每一行的监测数据
|
||||||
|
if(detailList != null && detailList.size() > 0) {
|
||||||
|
int maxAlarmLevel = 99;
|
||||||
|
String maxShowNum = "" ;
|
||||||
|
detailList.add(0, "");//告警序号
|
||||||
|
detailList.add(1, "");//告警级别
|
||||||
|
detailList.add(2, "");//告警值
|
||||||
|
if(alarmInfoList != null && alarmInfoList.size() > 0) {
|
||||||
|
for(AlarmInfo alarm : alarmInfoList) {
|
||||||
|
if (detailList.size() < alarm.getShowNum()) {// 得到的数据个数和告警列数比较
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String value = detailList.get(alarm.getShowNum() -1+3);
|
||||||
|
boolean alarmFlag = false;
|
||||||
|
/**
|
||||||
|
* 过滤标识判断
|
||||||
|
* 1.指定了特定的标识:
|
||||||
|
* (1).当前标识非空:不在指定标识内,则不做告警判断;在,则做告警判断
|
||||||
|
* (2).当前标识为空:空不在指定标识内,不做告警判断
|
||||||
|
* 2.未指定特定的标识:所有标识都进行告警判断
|
||||||
|
*/
|
||||||
|
String marker = alarm.getMarker();
|
||||||
|
Integer markerShowNum = alarm.getMarkerFiledShowNum();
|
||||||
|
String markerCurVal = "";
|
||||||
|
//若未指定标识字段,则从DC传递到NC的json字符串中markerShowNum的值为0
|
||||||
|
if(markerShowNum!=null && markerShowNum>0 && StringUtils.isNotBlank(marker)) {
|
||||||
|
markerCurVal = detailList.get(markerShowNum -1+3);//当前条详细监测数据的标识符
|
||||||
|
String sperator = Config.getString("alarm.set.marker.separator", "|");
|
||||||
|
if(StringUtils.isNotBlank(markerCurVal)) {
|
||||||
|
if(!(sperator+marker.trim()+sperator).toLowerCase().contains((sperator+markerCurVal.trim()+sperator).toLowerCase())) {//当前标识不在指定的标识里
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("equals".equalsIgnoreCase(alarm.getPoliceSysmbols())) {//相同
|
||||||
|
if(value.equals(alarm.getPoliceValue())){
|
||||||
|
alarmFlag = true;
|
||||||
|
}
|
||||||
|
} else if ("include".equalsIgnoreCase(alarm.getPoliceSysmbols())) {//包含告警值内容
|
||||||
|
if(value.contains(alarm.getPoliceValue())){
|
||||||
|
alarmFlag = true;
|
||||||
|
}
|
||||||
|
} else if ("exclude".equalsIgnoreCase(alarm.getPoliceSysmbols())) {//不包含告警值内容
|
||||||
|
if(!value.contains(alarm.getPoliceValue())){
|
||||||
|
alarmFlag = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
double result = Double.parseDouble(value) - Double.parseDouble(alarm.getPoliceValue());
|
||||||
|
if ((">".equals(alarm.getPoliceSysmbols()) && result > 0)
|
||||||
|
|| ("<".equals(alarm.getPoliceSysmbols()) && result < 0)
|
||||||
|
|| ("=".equals(alarm.getPoliceSysmbols()) && result == 0)
|
||||||
|
|| (">=".equals(alarm.getPoliceSysmbols()) && result >= 0)
|
||||||
|
|| ("<=".equals(alarm.getPoliceSysmbols()) && result <=0) ) {
|
||||||
|
alarmFlag = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String sysmbol = getAlarmSymbol(alarm.getPoliceSysmbols(), alarmFlag);
|
||||||
|
if(alarmFlag){
|
||||||
|
detectStatus = 0;
|
||||||
|
//性能信息
|
||||||
|
if(StringUtils.isNotBlank(markerCurVal)) {
|
||||||
|
infoSb.append("</br> [").append(markerCurVal).append("]");
|
||||||
|
}
|
||||||
|
infoSb.append(alarm.getFiledCommonts()).append(":")
|
||||||
|
.append(detailList.get(alarm.getShowNum()-1+3))
|
||||||
|
.append("(").append(alarm.getPoliceUnit()).append(") ")
|
||||||
|
.append(sysmbol).append("i18n_client.GetInfoRun.warningValue_n81i")
|
||||||
|
.append(alarm.getPoliceValue()).append("(").append(alarm.getPoliceUnit()).append(") ")
|
||||||
|
.append(" i18n_client.GetInfoRun.abnormal_n81i;");
|
||||||
|
if (maxAlarmLevel > alarm.getPoliceLevel()) {// 保留本次最高告警级别,值越小级别越高
|
||||||
|
maxAlarmLevel = alarm.getPoliceLevel();
|
||||||
|
maxShowNum = alarm.getShowNum()+"";
|
||||||
|
}
|
||||||
|
detailList.set(0, maxShowNum);//告警序号
|
||||||
|
detailList.set(1, maxAlarmLevel+"");//告警级别
|
||||||
|
detailList.set(2, alarm.getPoliceValue());//告警值
|
||||||
|
}
|
||||||
|
}//for end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pubData.set(9, detectStatus+"");
|
||||||
|
if(infoSb.length()>0) {//状态信息
|
||||||
|
String perform = pubData.get(11);
|
||||||
|
if(StringUtils.isNotBlank(perform)) {
|
||||||
|
infoSb.insert(0, perform);
|
||||||
|
}else {
|
||||||
|
infoSb.delete(0, 5);
|
||||||
|
}
|
||||||
|
pubData.set(10, infoSb.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(logger.isDebugEnabled()) {
|
||||||
|
logger.debug("告警判断-结果: " + Json.toJson(data, JsonFormat.tidy()));
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String getAlarmSymbol(String oldSymbol, boolean alarmFlag){
|
||||||
|
String symbol = "";
|
||||||
|
if(alarmFlag){
|
||||||
|
if(">".equals(oldSymbol)){
|
||||||
|
symbol = "i18n_client.GetInfoRun.gt_n81i";
|
||||||
|
}else if(">=".equals(oldSymbol)){
|
||||||
|
symbol = "i18n_client.GetInfoRun.out_n81i";
|
||||||
|
}else if("<".equals(oldSymbol)){
|
||||||
|
symbol = "i18n_client.GetInfoRun.lt_n81i";
|
||||||
|
}else if("<=".equals(oldSymbol)){
|
||||||
|
symbol = "i18n_client.GetInfoRun.in_n81i";
|
||||||
|
}else if("=".equals(oldSymbol)){
|
||||||
|
symbol = "i18n_client.GetInfoRun.eq_n81i";
|
||||||
|
}else{
|
||||||
|
symbol = oldSymbol;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if(">".equals(oldSymbol)){
|
||||||
|
symbol = "i18n_client.GetInfoRun.in_n81i";
|
||||||
|
}else if(">=".equals(oldSymbol)){
|
||||||
|
symbol = "i18n_client.GetInfoRun.lt_n81i";
|
||||||
|
}else if("<".equals(oldSymbol)){
|
||||||
|
symbol = "i18n_client.GetInfoRun.out_n81i";
|
||||||
|
}else if("<=".equals(oldSymbol)){
|
||||||
|
symbol = "i18n_client.GetInfoRun.gt_n81i";
|
||||||
|
}else if("=".equals(oldSymbol)){
|
||||||
|
symbol = "i18n_client.GetInfoRun.notEquels_n81i";
|
||||||
|
}else if("equals".equalsIgnoreCase(oldSymbol)){
|
||||||
|
symbol = "not equals";
|
||||||
|
}else if("include".equalsIgnoreCase(oldSymbol)){
|
||||||
|
symbol = "exclude";
|
||||||
|
}else if("exclude".equalsIgnoreCase(oldSymbol)){
|
||||||
|
symbol = "include";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return symbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void main(String [] args){
|
public static void main(String [] args){
|
||||||
|
|
||||||
@@ -2651,8 +2870,9 @@ public class Common {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 2018年7月30日 修改监测数据存放位置,改为保存到队列 中
|
* 2018年7月30日 修改监测数据存放位置,改为保存到队列 中
|
||||||
|
* 2019年4月2日14:30:19 初始化默认大小 20000
|
||||||
*/
|
*/
|
||||||
private static final LinkedBlockingDeque<byte[]> DETE_DATA_QUEUE = new LinkedBlockingDeque<byte[]>();
|
private static final LinkedBlockingDeque<byte[]> DETE_DATA_QUEUE = new LinkedBlockingDeque<byte[]>(Constants.DETE_DATA_QUEUE_CAPACITY);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存监测数据到缓存队列
|
* 保存监测数据到缓存队列
|
||||||
|
|||||||
@@ -411,6 +411,8 @@ public class Constants {
|
|||||||
// public static final Integer TEST_COMPUTER;
|
// public static final Integer TEST_COMPUTER;
|
||||||
// public static final Integer TEST_SWITCH;
|
// public static final Integer TEST_SWITCH;
|
||||||
//static final 自变量的初始化
|
//static final 自变量的初始化
|
||||||
|
//当前业务系统id
|
||||||
|
public static final String MISSION_SINGLE;
|
||||||
|
|
||||||
public static final String DB_TYPE;
|
public static final String DB_TYPE;
|
||||||
public static final boolean IS_MYSQL;
|
public static final boolean IS_MYSQL;
|
||||||
@@ -468,7 +470,38 @@ public class Constants {
|
|||||||
|
|
||||||
public static final Long HANDSHANK_DELAY_TIME;
|
public static final Long HANDSHANK_DELAY_TIME;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务 文件 下载 ip 获取方式,true:配置文件中的 web.socket.ip;false:system_table表中的 server_ip
|
||||||
|
*/
|
||||||
|
public static final boolean FILE_DOWNLOAD_FROM_COMMUNICATE_WEB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* druid 连接池 获取连接最大等待时间
|
||||||
|
*/
|
||||||
|
public static final Long DRUID_MAXWAIT_MILLIS;
|
||||||
|
/**
|
||||||
|
* server 同时可以并发接收多少 client 请求连接
|
||||||
|
*/
|
||||||
|
public static final int SERVER_ACCEPT_SEMAPHORE_MAX;
|
||||||
|
/**
|
||||||
|
* 是否开启 client 请求连接限制,默认 true
|
||||||
|
*/
|
||||||
|
public static final boolean SERVER_ACCEPT_SEMAPHORE_FLAG;
|
||||||
|
|
||||||
|
public static final boolean DEBUG_COMMON_ADDDETEDATA;
|
||||||
|
public static final boolean DEBUG_MESSAGEDECODER_DECODE;
|
||||||
|
public static final boolean DEBUG_DETECTINFOINSERTTHREAD_ADDRECORDTOSTATEMENT;
|
||||||
|
public static final boolean DEBUG_DETECTDETAILINSERTTHREAD_SAVETODB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 端口监测 流量为 0 告警
|
||||||
|
*/
|
||||||
|
public static final boolean PORT_ZERO_WARNING_FLAG;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测数据队列最大容量,防止nc长时间连接不上儿造成的dc短时间接收大量监测数据
|
||||||
|
*/
|
||||||
|
public static final Integer DETE_DATA_QUEUE_CAPACITY;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
||||||
@@ -776,6 +809,9 @@ public class Constants {
|
|||||||
/**
|
/**
|
||||||
* 是否是 mysql 数据库
|
* 是否是 mysql 数据库
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
MISSION_SINGLE = Config.getString("mission.single", "0");
|
||||||
|
|
||||||
IS_MYSQL = "mysql".equalsIgnoreCase(DB_TYPE);
|
IS_MYSQL = "mysql".equalsIgnoreCase(DB_TYPE);
|
||||||
/**
|
/**
|
||||||
* //dc监测数据入库模式,1:由web 主控控制入库,2:自己主动入库
|
* //dc监测数据入库模式,1:由web 主控控制入库,2:自己主动入库
|
||||||
@@ -827,6 +863,36 @@ public class Constants {
|
|||||||
CURRVAL_FUNCTION_NAME = Config.getString("currval_function_name", "currval");
|
CURRVAL_FUNCTION_NAME = Config.getString("currval_function_name", "currval");
|
||||||
HANDSHANK_DELAY_TIME = Long.parseLong(Config.getString("handshank.delay.time", 15000+""));
|
HANDSHANK_DELAY_TIME = Long.parseLong(Config.getString("handshank.delay.time", 15000+""));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 任务 文件 下载 ip 获取方式,true:配置文件中的 web.socket.ip;false:system_table表中的 server_ip
|
||||||
|
*/
|
||||||
|
FILE_DOWNLOAD_FROM_COMMUNICATE_WEB = Config.getBoolan("file.download.from.communicate.web", true);
|
||||||
|
/*
|
||||||
|
* 默认值:10s
|
||||||
|
*/
|
||||||
|
DRUID_MAXWAIT_MILLIS = Long.valueOf(Config.getString("druid.maxwait.millis", "10000"));
|
||||||
|
/*
|
||||||
|
* socket server 可以并发接收 client 连接数
|
||||||
|
*/
|
||||||
|
SERVER_ACCEPT_SEMAPHORE_MAX = Config.getInteger("server.accept.semaphore.max", 10);
|
||||||
|
/*
|
||||||
|
* 是否开启 client 连接数限制
|
||||||
|
*/
|
||||||
|
SERVER_ACCEPT_SEMAPHORE_FLAG = Config.getBoolan("server.accept.semaphore.flag", true);
|
||||||
|
|
||||||
|
|
||||||
|
//是否开启debug日志输出
|
||||||
|
DEBUG_COMMON_ADDDETEDATA = Config.getBoolan("DEBUG_COMMON_ADDDETEDATA", false);
|
||||||
|
DEBUG_MESSAGEDECODER_DECODE = Config.getBoolan("DEBUG_MESSAGEDECODER_DECODE", false);
|
||||||
|
DEBUG_DETECTINFOINSERTTHREAD_ADDRECORDTOSTATEMENT = Config.getBoolan("DEBUG_DETECTINFOINSERTTHREAD_ADDRECORDTOSTATEMENT", false);
|
||||||
|
DEBUG_DETECTDETAILINSERTTHREAD_SAVETODB = Config.getBoolan("DEBUG_DETECTDETAILINSERTTHREAD_SAVETODB", false);
|
||||||
|
|
||||||
|
// 端口流量为 0 告警 功能
|
||||||
|
PORT_ZERO_WARNING_FLAG = Config.getBoolan("port.zero.warning.flag", false);
|
||||||
|
|
||||||
|
//监测数据缓存队列容量
|
||||||
|
DETE_DATA_QUEUE_CAPACITY = Config.getInteger("dete.data.queue.capacity", 20000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//文件传输 临时文件命名后缀
|
//文件传输 临时文件命名后缀
|
||||||
|
|||||||
@@ -1449,7 +1449,8 @@ public class CommonService {
|
|||||||
" left join mission_parameter_table6 para" +
|
" left join mission_parameter_table6 para" +
|
||||||
" on para.mission_id=t.mission_id" +
|
" on para.mission_id=t.mission_id" +
|
||||||
" where t.mission_type = 6" +
|
" where t.mission_type = 6" +
|
||||||
" and greatest(t.create_time,ifnull(para.start_time,t.create_time))>date_add(now() ,interval -"+timeStandard+ "*24*3600 second)";
|
// " and greatest(t.create_time,ifnull(para.start_time,t.create_time))>date_add(now() ,interval -"+timeStandard+ "*24*3600 second)";
|
||||||
|
" and greatest(t.create_time,ifnull(para.start_time,t.create_time))<date_add(now() ,interval -"+timeStandard+ " second)";
|
||||||
task6SucSql = "select info.ip,info.mission_id as taskIds" +
|
task6SucSql = "select info.ip,info.mission_id as taskIds" +
|
||||||
" from (" +
|
" from (" +
|
||||||
" select distinct node.node_ip as ip,rlt.mission_id as mission_id" +
|
" select distinct node.node_ip as ip,rlt.mission_id as mission_id" +
|
||||||
@@ -1465,7 +1466,8 @@ public class CommonService {
|
|||||||
" where t.mission_type = 6" +
|
" where t.mission_type = 6" +
|
||||||
/* " and (sysdate-greatest(t.create_time,nvl(para.start_time,t.create_time)))*24*3600>" + timeStandard +
|
/* " and (sysdate-greatest(t.create_time,nvl(para.start_time,t.create_time)))*24*3600>" + timeStandard +
|
||||||
" )" +*/
|
" )" +*/
|
||||||
" and greatest(t.create_time,ifnull(para.start_time,t.create_time))>date_add(now() ,interval -"+timeStandard+ "*24*3600 second))"+
|
// " and greatest(t.create_time,ifnull(para.start_time,t.create_time))>date_add(now() ,interval -"+timeStandard+ "*24*3600 second))"+
|
||||||
|
" and greatest(t.create_time,ifnull(para.start_time,t.create_time))<date_add(now() ,interval -"+timeStandard+ " second))"+
|
||||||
" )info " ;
|
" )info " ;
|
||||||
}else{
|
}else{
|
||||||
task6AllSql = "select distinct t.mission_id,para.node_groups_id,para.node_ips_id, " +
|
task6AllSql = "select distinct t.mission_id,para.node_groups_id,para.node_ips_id, " +
|
||||||
@@ -1475,7 +1477,8 @@ public class CommonService {
|
|||||||
" left join mission_parameter_table6 para" +
|
" left join mission_parameter_table6 para" +
|
||||||
" on para.mission_id=t.mission_id" +
|
" on para.mission_id=t.mission_id" +
|
||||||
" where t.mission_type = 6" +
|
" where t.mission_type = 6" +
|
||||||
" and (sysdate-greatest(t.create_time,nvl(para.start_time,t.create_time)))*24*3600>"+timeStandard;
|
// " and (sysdate-greatest(t.create_time,nvl(para.start_time,t.create_time)))*24*3600>"+timeStandard;
|
||||||
|
" and (sysdate-greatest(t.create_time,nvl(para.start_time,t.create_time)))>"+timeStandard;
|
||||||
task6SucSql = "select info.ip,info.mission_id as taskIds" +
|
task6SucSql = "select info.ip,info.mission_id as taskIds" +
|
||||||
" from (" +
|
" from (" +
|
||||||
" select distinct node.node_ip as ip,rlt.mission_id as mission_id" +
|
" select distinct node.node_ip as ip,rlt.mission_id as mission_id" +
|
||||||
@@ -1489,11 +1492,13 @@ public class CommonService {
|
|||||||
" left join mission_parameter_table6 para" +
|
" left join mission_parameter_table6 para" +
|
||||||
" on para.mission_id=t.mission_id" +
|
" on para.mission_id=t.mission_id" +
|
||||||
" where t.mission_type = 6" +
|
" where t.mission_type = 6" +
|
||||||
" and (sysdate-greatest(t.create_time,nvl(para.start_time,t.create_time)))*24*3600>" + timeStandard +
|
// " and (sysdate-greatest(t.create_time,nvl(para.start_time,t.create_time)))*24*3600>" + timeStandard +
|
||||||
|
" and (sysdate-greatest(t.create_time,nvl(para.start_time,t.create_time)))>" + timeStandard +
|
||||||
" )" +
|
" )" +
|
||||||
" )info " ;
|
" )info " ;
|
||||||
}
|
}
|
||||||
|
logger.debug("重新手机任务结果sql(task6AllSql)-->"+task6AllSql);
|
||||||
|
logger.debug("重新手机任务结果sql(task6SucSql)-->"+task6SucSql);
|
||||||
return getNonRltIpTaskMap(task6AllSql,task6SucSql);
|
return getNonRltIpTaskMap(task6AllSql,task6SucSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3701,7 +3706,7 @@ public class CommonService {
|
|||||||
//-- 获取ID
|
//-- 获取ID
|
||||||
fields.clear();
|
fields.clear();
|
||||||
|
|
||||||
String id = DetectInfo.computeId(checkTime, seqId, setInfoId);
|
String id = DetectInfo.computeId(alarms[5], seqId, setInfoId);
|
||||||
|
|
||||||
/*String searchIdSql = "select seq_detection_info.nextval id from dual";
|
/*String searchIdSql = "select seq_detection_info.nextval id from dual";
|
||||||
fields.add("id");
|
fields.add("id");
|
||||||
@@ -4077,7 +4082,8 @@ public class CommonService {
|
|||||||
String ifAdminStatus = detailsArr0[9];//showNum=7,1:up,2:down
|
String ifAdminStatus = detailsArr0[9];//showNum=7,1:up,2:down
|
||||||
if("2".equals(ifAdminStatus)) {
|
if("2".equals(ifAdminStatus)) {
|
||||||
state = 0;//监测公共信息的状态
|
state = 0;//监测公共信息的状态
|
||||||
dsinfo += "$@$端口"+ifDescr+"异常(配置状态与实际状态不符)";
|
// dsinfo += "$@$端口"+ifDescr+"异常(配置状态与实际状态不符)";
|
||||||
|
dsinfo += "i18n_server.CommonService.dsinfo1_n81i"+ifDescr+"i18n_server.CommonService.dsinfo1.exception_n81i";
|
||||||
detailDetectionState = "0";//当前端口的状态
|
detailDetectionState = "0";//当前端口的状态
|
||||||
pLevel = Constants.PORT_ALARM_LEVEL;//非界面设置,默认为5级
|
pLevel = Constants.PORT_ALARM_LEVEL;//非界面设置,默认为5级
|
||||||
}
|
}
|
||||||
@@ -4088,7 +4094,8 @@ public class CommonService {
|
|||||||
logger.info("test:port:inOctetsSpeed="+inOctetsSpeed+";outOctetsSpeed="+outOctetsSpeed);
|
logger.info("test:port:inOctetsSpeed="+inOctetsSpeed+";outOctetsSpeed="+outOctetsSpeed);
|
||||||
if((inOctetsSpeed+outOctetsSpeed)<=0) {
|
if((inOctetsSpeed+outOctetsSpeed)<=0) {
|
||||||
state = 0;//监测公共信息的状态
|
state = 0;//监测公共信息的状态
|
||||||
dsinfo += "$@$端口"+ifDescr+"异常(流量为0),inOctetsSpeed="+inOctetsSpeed+",outOctetsSpeed="+outOctetsSpeed+",sum="+(inOctetsSpeed+outOctetsSpeed);
|
// dsinfo += "$@$端口"+ifDescr+"异常(流量为0),inOctetsSpeed="+inOctetsSpeed+",outOctetsSpeed="+outOctetsSpeed+",sum="+(inOctetsSpeed+outOctetsSpeed);
|
||||||
|
dsinfo += "i18n_server.CommonService.dsinfo1_n81i"+ifDescr+"i18n_server.CommonService.dsinfo2.exception_n81i,inOctetsSpeed="+inOctetsSpeed+",outOctetsSpeed="+outOctetsSpeed+",sum="+(inOctetsSpeed+outOctetsSpeed);
|
||||||
detailDetectionState = "0";//当前端口的状态
|
detailDetectionState = "0";//当前端口的状态
|
||||||
pLevel = Constants.PORT_ALARM_LEVEL;//非界面设置,默认为5级
|
pLevel = Constants.PORT_ALARM_LEVEL;//非界面设置,默认为5级
|
||||||
}
|
}
|
||||||
@@ -4151,9 +4158,10 @@ public class CommonService {
|
|||||||
filedComments = tm==null?"":tm.getFiledComments();
|
filedComments = tm==null?"":tm.getFiledComments();
|
||||||
}
|
}
|
||||||
cpInfo += " "+(StringUtils.isEmpty(elem.getFiledCommonts())?filedName:elem.getFiledCommonts());
|
cpInfo += " "+(StringUtils.isEmpty(elem.getFiledCommonts())?filedName:elem.getFiledCommonts());
|
||||||
cpInfo += " 为:"+detail.get(filedName);
|
cpInfo += " i18n_server.CommonService.for_n81i:"+detail.get(filedName);
|
||||||
cpInfo += (elem.getPoliceUnit()==null ? "" : "null".equals(elem.getPoliceUnit()) ? "" : elem.getPoliceUnit());
|
cpInfo += (elem.getPoliceUnit()==null ? "" : "null".equals(elem.getPoliceUnit()) ? "" : elem.getPoliceUnit());
|
||||||
cpInfo += " 报警级别:"+pLevel;
|
// cpInfo += " 报警级别:"+pLevel;
|
||||||
|
cpInfo += " i18n_server.CommonService.policyLevel_n81i:"+pLevel;
|
||||||
cpInfo += " \n";
|
cpInfo += " \n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.nms.server.bean.LoopMissionRoundInfo;
|
|||||||
import com.nms.server.bean.MissionResult;
|
import com.nms.server.bean.MissionResult;
|
||||||
import com.nms.server.bean.MissionResult2;
|
import com.nms.server.bean.MissionResult2;
|
||||||
import com.nms.server.bean.MissionStateTable;
|
import com.nms.server.bean.MissionStateTable;
|
||||||
|
import com.nms.server.bean.ServerIpSegment;
|
||||||
import com.nms.server.bean.Task1;
|
import com.nms.server.bean.Task1;
|
||||||
import com.nms.server.bean.Task4;
|
import com.nms.server.bean.Task4;
|
||||||
import com.nms.server.bean.Task6;
|
import com.nms.server.bean.Task6;
|
||||||
@@ -71,9 +72,9 @@ public class UpgradeService extends CommonService{
|
|||||||
// searchSQL.append("and (mst.end_time>sysdate or mst.end_time is null) ");// 周期任务(未过时) or 非周期任务
|
// searchSQL.append("and (mst.end_time>sysdate or mst.end_time is null) ");// 周期任务(未过时) or 非周期任务
|
||||||
if (missionId!=null && missionId.longValue() !=0l) {
|
if (missionId!=null && missionId.longValue() !=0l) {
|
||||||
searchSQL.append("and mst.mission_id = '"+missionId.longValue()+"' ");
|
searchSQL.append("and mst.mission_id = '"+missionId.longValue()+"' ");
|
||||||
}else{
|
|
||||||
searchSQL.append("and mst.mission_state in (1,5) "); //以创建任务 准备撤销任务 均作为新任务周期性载入
|
|
||||||
}
|
}
|
||||||
|
searchSQL.append("and mst.mission_state in (1,5) "); //以创建任务 准备撤销任务 均作为新任务周期性载入
|
||||||
|
|
||||||
searchSQL.append("order by mst.create_time,mst.mission_id asc ");
|
searchSQL.append("order by mst.create_time,mst.mission_id asc ");
|
||||||
ArrayList<String> fields = new ArrayList<String>();
|
ArrayList<String> fields = new ArrayList<String>();
|
||||||
fields.add("mission_id");
|
fields.add("mission_id");
|
||||||
@@ -90,19 +91,106 @@ public class UpgradeService extends CommonService{
|
|||||||
try {
|
try {
|
||||||
rs = dao.dbSelect(searchSQL.toString(), fields);
|
rs = dao.dbSelect(searchSQL.toString(), fields);
|
||||||
if(rs!=null && rs.size()>0){
|
if(rs!=null && rs.size()>0){
|
||||||
|
Long serverId = Common.getServerTable().getId();
|
||||||
|
boolean missionSingle = Constants.MISSION_SINGLE.equals("1") ? true : false;
|
||||||
|
logger.info("开始加载新任务...过滤当前dc范围内的任务:" + (missionSingle ? "是" : "否"));
|
||||||
|
//获取当前dc范围
|
||||||
|
List<ServerIpSegment> ipSegList = Common.getServerTable().getIpSegList();
|
||||||
for(Map<String, String> maps : rs){
|
for(Map<String, String> maps : rs){
|
||||||
MissionStateTable mission = new MissionStateTable();
|
//是否加载任务
|
||||||
// mission.setMissionName(maps.get("mission_name"));
|
boolean flag = false;
|
||||||
mission.setMissionId(StringUtils.isEmpty(maps.get("mission_id"))?null:Long.parseLong(maps.get("mission_id")));
|
//第一步,判断是否过滤dc范围外节点
|
||||||
mission.setMissionType(StringUtils.isEmpty(maps.get("mission_type"))?null:Long.parseLong(maps.get("mission_type")) );
|
if (missionSingle) {
|
||||||
mission.setMissionState(StringUtils.isEmpty(maps.get("mission_state"))?null:Long.parseLong(maps.get("mission_state")));
|
logger.info("当前dc的server_id:" + serverId);
|
||||||
mission.setSystemId(StringUtils.isEmpty(maps.get("system_id"))?null:Long.parseLong(maps.get("system_id")));
|
|
||||||
mission.setGroupId(StringUtils.isEmpty(maps.get("group_id"))?null:Long.parseLong(maps.get("group_id")));
|
//第二步,获取每个任务下发的所有节点,判断是否在dc范围内,若一个在范围内的都没有就把任务状态改为失败
|
||||||
mission.setStartTime(StringUtils.isEmpty(maps.get("start_time"))?null:format.parse(maps.get("start_time")));
|
//----查询任务下发的节点组ids/节点ids
|
||||||
mission.setEndTime(StringUtils.isEmpty(maps.get("end_time"))?null:format.parse(maps.get("end_time")));
|
String messionType = maps.get("mission_type");
|
||||||
mission.setLoopFlag(StringUtils.isEmpty(maps.get("is_loop"))?null:Long.parseLong(maps.get("is_loop")));
|
StringBuffer mnSql = new StringBuffer();
|
||||||
mission.setLoopDelay(StringUtils.isEmpty(maps.get("loop_delay"))?null:Long.parseLong(maps.get("loop_delay")));
|
mnSql.append("SELECT mpt.node_ips_id, mpt.node_groups_id ");
|
||||||
mstList.add(mission);
|
mnSql.append("FROM mission_state_table mst ");
|
||||||
|
mnSql.append("LEFT JOIN mission_parameter_table" + messionType + " mpt ON mpt.mission_id=mst.mission_id ");
|
||||||
|
mnSql.append("where mst.mission_id=" + maps.get("mission_id"));
|
||||||
|
ArrayList<String> mnFields = new ArrayList<String>();
|
||||||
|
mnFields.add("node_ips_id");
|
||||||
|
mnFields.add("node_groups_id");
|
||||||
|
ArrayList<Map<String, String>> mns = dao.dbSelect(mnSql.toString(), mnFields);
|
||||||
|
|
||||||
|
if (mns != null && mns.size() > 0) {
|
||||||
|
for (Map<String, String> mn : mns) {
|
||||||
|
//----根据节点组ids/节点ids查出seq_id
|
||||||
|
StringBuffer nodeSQL = new StringBuffer();
|
||||||
|
nodeSQL.append("select distinct nt.seq_id,nt.node_type ");
|
||||||
|
nodeSQL.append("from node_table nt ");
|
||||||
|
nodeSQL.append("where 1 = 1 ");
|
||||||
|
nodeSQL.append(" and nvl(nt.seq_id,-1)<> -1 ");
|
||||||
|
nodeSQL.append(" and nt.node_state = 0 ");
|
||||||
|
ArrayList<String> nodeFields = new ArrayList<String>();
|
||||||
|
nodeFields.add("seq_id");
|
||||||
|
nodeFields.add("node_type");
|
||||||
|
if(StringUtils.isNotBlank(mn.get("node_ips_id"))){
|
||||||
|
nodeSQL.append(" and nt.NODE_ID in(" + mn.get("node_ips_id") + ") ");
|
||||||
|
}else{
|
||||||
|
if(StringUtils.isNotBlank(mn.get("node_groups_id"))){
|
||||||
|
String startWithConnectBy = dao.startWithConnectBy("select nt.group_id from NODEGROUP_TABLE nt where nt.leaf_group = 1 ", " nt.group_id in (" + mn.get("node_groups_id") + ") ", "group_id", "parent_group_id");
|
||||||
|
nodeSQL.append(" and nt.node_group_id in( " + startWithConnectBy + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ArrayList<Map<String, String>> nodeMapList = dao.dbSelect(nodeSQL.toString(), nodeFields);
|
||||||
|
//----拼写uuid串,用于校验管理范围外IP
|
||||||
|
StringBuffer uuidStr = new StringBuffer("0");
|
||||||
|
if (nodeMapList != null && nodeMapList.size() > 0) {
|
||||||
|
for(Map<String, String> map : nodeMapList){
|
||||||
|
if(StringUtils.isNotEmpty(map.get("seq_id"))){
|
||||||
|
uuidStr.append("," + map.get("seq_id"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.info("mission_id:" + maps.get("mission_id") + ",seq_id范围:" + uuidStr.toString());
|
||||||
|
|
||||||
|
StringBuffer omNodeSql = new StringBuffer("select distinct nt.seq_id from node_table nt where 1=1 ");
|
||||||
|
if(ipSegList!=null && ipSegList.size() > 0){
|
||||||
|
for(ServerIpSegment map : ipSegList){
|
||||||
|
omNodeSql.append(" and (ipn < '" + map.getStartIpn() + "' or ipn > '" + map.getEndIpn() + "')");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
omNodeSql.append("and nt.seq_id in (" + uuidStr + ")");
|
||||||
|
ArrayList<String> omNodeFields = new ArrayList<String>();
|
||||||
|
omNodeFields.add("seq_id");
|
||||||
|
ArrayList<Map<String, String>> omNodeMapList = dao.dbSelect(omNodeSql.toString(), omNodeFields);
|
||||||
|
|
||||||
|
if (omNodeMapList != null && nodeMapList != null) {
|
||||||
|
if (omNodeMapList.size() < nodeMapList.size()) {
|
||||||
|
flag = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//任务范围含有dc范围内节点则加载任务,否则直接将任务状态改为未能执行
|
||||||
|
if (flag) {
|
||||||
|
logger.info("任务节点在dc范围内,开始加载...");
|
||||||
|
MissionStateTable mission = new MissionStateTable();
|
||||||
|
// mission.setMissionName(maps.get("mission_name"));
|
||||||
|
mission.setMissionId(StringUtils.isEmpty(maps.get("mission_id"))?null:Long.parseLong(maps.get("mission_id")));
|
||||||
|
mission.setMissionType(StringUtils.isEmpty(maps.get("mission_type"))?null:Long.parseLong(maps.get("mission_type")) );
|
||||||
|
mission.setMissionState(StringUtils.isEmpty(maps.get("mission_state"))?null:Long.parseLong(maps.get("mission_state")));
|
||||||
|
mission.setSystemId(StringUtils.isEmpty(maps.get("system_id"))?null:Long.parseLong(maps.get("system_id")));
|
||||||
|
mission.setGroupId(StringUtils.isEmpty(maps.get("group_id"))?null:Long.parseLong(maps.get("group_id")));
|
||||||
|
mission.setStartTime(StringUtils.isEmpty(maps.get("start_time"))?null:format.parse(maps.get("start_time")));
|
||||||
|
mission.setEndTime(StringUtils.isEmpty(maps.get("end_time"))?null:format.parse(maps.get("end_time")));
|
||||||
|
mission.setLoopFlag(StringUtils.isEmpty(maps.get("is_loop"))?null:Long.parseLong(maps.get("is_loop")));
|
||||||
|
mission.setLoopDelay(StringUtils.isEmpty(maps.get("loop_delay"))?null:Long.parseLong(maps.get("loop_delay")));
|
||||||
|
mstList.add(mission);
|
||||||
|
} else {
|
||||||
|
String cancelSql = "update mission_state_table set mission_state=-1 where mission_id=" + maps.get("mission_id");
|
||||||
|
dao.dbUpdate(cancelSql);
|
||||||
|
logger.info("任务节点不在dc范围内,已取消");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mstList;
|
return mstList;
|
||||||
@@ -237,7 +325,12 @@ public class UpgradeService extends CommonService{
|
|||||||
searchSql.append("and t.is_loop =0 "); //非周期任务
|
searchSql.append("and t.is_loop =0 "); //非周期任务
|
||||||
// searchSql.append("and mpt4.node_group_id in( "+groupsIdsSQL+") ");
|
// searchSql.append("and mpt4.node_group_id in( "+groupsIdsSQL+") ");
|
||||||
searchSql.append("and mpt4.mission_id in( "+missionSql4+") ");
|
searchSql.append("and mpt4.mission_id in( "+missionSql4+") ");
|
||||||
searchSql.append("and mrt4.result >= 40 ");
|
/*
|
||||||
|
* 2018年10月12日18:10:49
|
||||||
|
* nc 重启获取 未下发的任务
|
||||||
|
*/
|
||||||
|
// searchSql.append("and mrt4.result >=40 ");
|
||||||
|
searchSql.append("and mrt4.result = 3 ");//3:任务下发中
|
||||||
searchSql.append("and mrt4.seq_id ="+uuid+" ");
|
searchSql.append("and mrt4.seq_id ="+uuid+" ");
|
||||||
searchSql.append("order by t.create_time asc ");
|
searchSql.append("order by t.create_time asc ");
|
||||||
mapsList = dao.dbSelect(searchSql.toString(), fields);
|
mapsList = dao.dbSelect(searchSql.toString(), fields);
|
||||||
@@ -303,7 +396,12 @@ public class UpgradeService extends CommonService{
|
|||||||
// searchSql.append("and mpt4.node_group_id in( "+groupsIdsSQL+") ");
|
// searchSql.append("and mpt4.node_group_id in( "+groupsIdsSQL+") ");
|
||||||
searchSql.append("and mpt4.mission_id in( "+missionSql4+") ");
|
searchSql.append("and mpt4.mission_id in( "+missionSql4+") ");
|
||||||
// searchSql.append("and nt.seq_id = "+uuid.longValue()+" ");
|
// searchSql.append("and nt.seq_id = "+uuid.longValue()+" ");
|
||||||
searchSql.append("and mrt4.result >= 40 ");
|
/*
|
||||||
|
* 2018年10月12日18:10:49
|
||||||
|
* nc 重启获取 未下发的任务
|
||||||
|
*/
|
||||||
|
// searchSql.append("and mrt4.result >=40 ");
|
||||||
|
searchSql.append("and mrt4.result = 3 ");//3:任务下发中
|
||||||
searchSql.append("and mrt4.seq_id ="+uuid+" ");
|
searchSql.append("and mrt4.seq_id ="+uuid+" ");
|
||||||
searchSql.append("order by t.create_time asc ");
|
searchSql.append("order by t.create_time asc ");
|
||||||
mapsList = dao.dbSelect(searchSql.toString(), fields);
|
mapsList = dao.dbSelect(searchSql.toString(), fields);
|
||||||
@@ -370,7 +468,12 @@ public class UpgradeService extends CommonService{
|
|||||||
// searchSql.append("and mpt6.node_group_id in( "+groupsIdsSQL+") ");
|
// searchSql.append("and mpt6.node_group_id in( "+groupsIdsSQL+") ");
|
||||||
searchSql.append("and mpt6.mission_id in( "+missionSql6+") ");
|
searchSql.append("and mpt6.mission_id in( "+missionSql6+") ");
|
||||||
// searchSql.append("and nt.seq_id = "+uuid.longValue()+" ");
|
// searchSql.append("and nt.seq_id = "+uuid.longValue()+" ");
|
||||||
searchSql.append("and mrt6.result >= 40 ");
|
/*
|
||||||
|
* 2018年10月12日18:10:49
|
||||||
|
* nc 重启获取 未下发的任务
|
||||||
|
*/
|
||||||
|
// searchSql.append("and mrt6.result >=40 ");
|
||||||
|
searchSql.append("and mrt6.result = 3 ");//3:任务下发中
|
||||||
searchSql.append("and mrt6.seq_id ="+uuid+" ");
|
searchSql.append("and mrt6.seq_id ="+uuid+" ");
|
||||||
searchSql.append("order by t.create_time asc ");
|
searchSql.append("order by t.create_time asc ");
|
||||||
mapsList = dao.dbSelect(searchSql.toString(), fields);
|
mapsList = dao.dbSelect(searchSql.toString(), fields);
|
||||||
@@ -751,8 +854,19 @@ public class UpgradeService extends CommonService{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//查询任务下发节点sql-管理范围外节点
|
//查询任务下发节点sql-管理范围外节点
|
||||||
|
//是否限制为当前dc范围
|
||||||
|
boolean missionSingle = Constants.MISSION_SINGLE.equals("1") ? true : false;
|
||||||
|
StringBuffer msSql = new StringBuffer("");
|
||||||
|
if (missionSingle) {
|
||||||
|
Long serverId = Common.getServerTable().getId();
|
||||||
|
msSql.append("and sis.server_id=");
|
||||||
|
msSql.append(serverId);
|
||||||
|
msSql.append(" ");
|
||||||
|
}
|
||||||
ArrayList<String> ipnSegmentFields = new ArrayList<String>();
|
ArrayList<String> ipnSegmentFields = new ArrayList<String>();
|
||||||
StringBuffer ipnSegmentSQL = new StringBuffer("select sis.start_ipn,sis.end_ipn from server_ip_segment sis left join server_table st on st.id = sis.server_id where st.server_state='0' and nvl(sis.segment_state,0) <>-1");
|
StringBuffer ipnSegmentSQL = new StringBuffer("select sis.start_ipn,sis.end_ipn from server_ip_segment sis left join server_table st on st.id = sis.server_id where st.server_state='0' and nvl(sis.segment_state,0) <>-1 ");
|
||||||
|
ipnSegmentSQL.append(msSql);
|
||||||
|
|
||||||
ipnSegmentFields.add("start_ipn");
|
ipnSegmentFields.add("start_ipn");
|
||||||
ipnSegmentFields.add("end_ipn");
|
ipnSegmentFields.add("end_ipn");
|
||||||
ArrayList<Map<String, String>> omNodeMapList = dao.dbSelect(ipnSegmentSQL.toString(), ipnSegmentFields);
|
ArrayList<Map<String, String>> omNodeMapList = dao.dbSelect(ipnSegmentSQL.toString(), ipnSegmentFields);
|
||||||
@@ -776,7 +890,7 @@ public class UpgradeService extends CommonService{
|
|||||||
if(omNodeMapList!= null && omNodeMapList.size()>0){
|
if(omNodeMapList!= null && omNodeMapList.size()>0){
|
||||||
omNode:for(Map<String, String> map : omNodeMapList){
|
omNode:for(Map<String, String> map : omNodeMapList){
|
||||||
if(nodeMap.get("seq_id").equals(map.get("seq_id"))){//管理范围外节点失败结果
|
if(nodeMap.get("seq_id").equals(map.get("seq_id"))){//管理范围外节点失败结果
|
||||||
params.add(new String[]{missionId.longValue()+"",nodeMap.get("seq_id")+"","1",MissionConstants.ERROR_RESULT_UN_MANAGEMENT_NODE});
|
//params.add(new String[]{missionId.longValue()+"",nodeMap.get("seq_id")+"","1",MissionConstants.ERROR_RESULT_UN_MANAGEMENT_NODE});
|
||||||
continue node;
|
continue node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -876,8 +990,19 @@ public class UpgradeService extends CommonService{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//查询任务下发节点sql-管理范围外节点
|
//查询任务下发节点sql-管理范围外节点
|
||||||
|
boolean missionSingle = Constants.MISSION_SINGLE.equals("1") ? true : false;
|
||||||
|
StringBuffer msSql = new StringBuffer("");
|
||||||
|
if (missionSingle) {
|
||||||
|
Long serverId = Common.getServerTable().getId();
|
||||||
|
msSql.append("and sis.server_id=");
|
||||||
|
msSql.append(serverId);
|
||||||
|
msSql.append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
ArrayList<String> ipnSegmentFields = new ArrayList<String>();
|
ArrayList<String> ipnSegmentFields = new ArrayList<String>();
|
||||||
StringBuffer ipnSegmentSQL = new StringBuffer("select sis.start_ipn,sis.end_ipn from server_ip_segment sis left join server_table st on st.id = sis.server_id where st.server_state='0' and nvl(sis.segment_state,0) <>-1");
|
StringBuffer ipnSegmentSQL = new StringBuffer("select sis.start_ipn,sis.end_ipn from server_ip_segment sis left join server_table st on st.id = sis.server_id where st.server_state='0' and nvl(sis.segment_state,0) <>-1 ");
|
||||||
|
ipnSegmentSQL.append(msSql);
|
||||||
|
|
||||||
ipnSegmentFields.add("start_ipn");
|
ipnSegmentFields.add("start_ipn");
|
||||||
ipnSegmentFields.add("end_ipn");
|
ipnSegmentFields.add("end_ipn");
|
||||||
ArrayList<Map<String, String>> omNodeMapList = dao.dbSelect(ipnSegmentSQL.toString(), ipnSegmentFields);
|
ArrayList<Map<String, String>> omNodeMapList = dao.dbSelect(ipnSegmentSQL.toString(), ipnSegmentFields);
|
||||||
@@ -926,7 +1051,7 @@ public class UpgradeService extends CommonService{
|
|||||||
if(omNodeMapList!= null && omNodeMapList.size()>0){
|
if(omNodeMapList!= null && omNodeMapList.size()>0){
|
||||||
omNode:for(Map<String, String> map : omNodeMapList){
|
omNode:for(Map<String, String> map : omNodeMapList){
|
||||||
if(seqIdTmp.equals(map.get("seq_id"))){//管理范围外节点失败结果
|
if(seqIdTmp.equals(map.get("seq_id"))){//管理范围外节点失败结果
|
||||||
params.add(new String[]{curMissionId.longValue()+"",seqIdTmp,"1",MissionConstants.ERROR_RESULT_UN_MANAGEMENT_NODE});
|
//params.add(new String[]{curMissionId.longValue()+"",seqIdTmp,"1",MissionConstants.ERROR_RESULT_UN_MANAGEMENT_NODE});
|
||||||
continue node;
|
continue node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package com.nms.server.snmp.trap;
|
package com.nms.server.snmp.trap;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.nutz.json.Json;
|
||||||
|
import org.nutz.json.JsonFormat;
|
||||||
import org.snmp4j.CommandResponder;
|
import org.snmp4j.CommandResponder;
|
||||||
import org.snmp4j.CommandResponderEvent;
|
import org.snmp4j.CommandResponderEvent;
|
||||||
import org.snmp4j.MessageDispatcherImpl;
|
import org.snmp4j.MessageDispatcherImpl;
|
||||||
@@ -48,40 +48,43 @@ import com.nms.server.dao.CommonDao;
|
|||||||
import com.nms.server.service.CommonService;
|
import com.nms.server.service.CommonService;
|
||||||
import com.nms.server.util.SNMP4JUtils;
|
import com.nms.server.util.SNMP4JUtils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本类用于监听代理进程的Trap信息
|
* 本类用于监听代理进程的Trap信息
|
||||||
*
|
*
|
||||||
* @author YJS
|
* @author YJS
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TrapServer /**extends Service*/
|
public class TrapServer /** extends Service */
|
||||||
implements CommandResponder{// implements CommandResponder, extends Service
|
implements CommandResponder {// implements CommandResponder, extends
|
||||||
|
// Service
|
||||||
private static Logger logger = Logger.getLogger(TrapServer.class);
|
private static Logger logger = Logger.getLogger(TrapServer.class);
|
||||||
private static TrapServer ts = null;
|
private static TrapServer ts = null;
|
||||||
public static TrapServer getInstance() throws IOException{
|
|
||||||
if(ts == null){
|
public static TrapServer getInstance() throws IOException {
|
||||||
|
if (ts == null) {
|
||||||
ts = new TrapServer();
|
ts = new TrapServer();
|
||||||
logger.info("SNMP Trap Server 启动成功");
|
logger.info("SNMP Trap Server 启动成功");
|
||||||
}else{
|
} else {
|
||||||
logger.info("SNMP TrapServer 已启动");
|
logger.info("SNMP TrapServer 已启动");
|
||||||
}
|
}
|
||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TrapServer() throws IOException{
|
private TrapServer() throws IOException {
|
||||||
ThreadPool threadPool = ThreadPool.create("Trap", Constants.SNMP_TRAP_THREAD_POOL_SIZE);
|
ThreadPool threadPool = ThreadPool.create("Trap", Constants.SNMP_TRAP_THREAD_POOL_SIZE);
|
||||||
MultiThreadedMessageDispatcher dispatcher = new MultiThreadedMessageDispatcher(threadPool, new MessageDispatcherImpl());
|
MultiThreadedMessageDispatcher dispatcher = new MultiThreadedMessageDispatcher(threadPool,
|
||||||
Address listenAddress = GenericAddress.parse(System.getProperty("snmp4j.listenAddress", "udp:" + Common.getLocalIp() + "/" + Constants.SNMP_TRAP_PORT)); // 本地IP与监听端口
|
new MessageDispatcherImpl());
|
||||||
|
Address listenAddress = GenericAddress.parse(System.getProperty("snmp4j.listenAddress",
|
||||||
|
"udp:" + Common.getLocalIp() + "/" + Constants.SNMP_TRAP_PORT)); // 本地IP与监听端口
|
||||||
TransportMapping transport = null;
|
TransportMapping transport = null;
|
||||||
|
|
||||||
// 对TCP与UDP协议进行处理
|
// 对TCP与UDP协议进行处理
|
||||||
if (listenAddress instanceof UdpAddress) {
|
if (listenAddress instanceof UdpAddress) {
|
||||||
transport = new DefaultUdpTransportMapping((UdpAddress) listenAddress);
|
transport = new DefaultUdpTransportMapping((UdpAddress) listenAddress);
|
||||||
} else {
|
} else {
|
||||||
transport = new DefaultTcpTransportMapping((TcpAddress) listenAddress);
|
transport = new DefaultTcpTransportMapping((TcpAddress) listenAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
Snmp snmp = new Snmp(dispatcher, transport);
|
Snmp snmp = new Snmp(dispatcher, transport);
|
||||||
snmp.getMessageDispatcher().addMessageProcessingModel(new MPv1());
|
snmp.getMessageDispatcher().addMessageProcessingModel(new MPv1());
|
||||||
snmp.getMessageDispatcher().addMessageProcessingModel(new MPv2c());
|
snmp.getMessageDispatcher().addMessageProcessingModel(new MPv2c());
|
||||||
@@ -90,56 +93,44 @@ implements CommandResponder{// implements CommandResponder, extends Service
|
|||||||
SecurityModels.getInstance().addSecurityModel(usm);
|
SecurityModels.getInstance().addSecurityModel(usm);
|
||||||
snmp.listen();
|
snmp.listen();
|
||||||
snmp.addCommandResponder(this);
|
snmp.addCommandResponder(this);
|
||||||
// OID authProtocol = getAuthProtocol(Constants.SNMP_V3_AUTH_PROTOCOL); //认证协议
|
|
||||||
// OID privProtocol = getPrivProtocol(Constants.SNMP_V3_PRIV_PROTOCOL); //加密协议
|
|
||||||
// OctetString securityName = new OctetString(Constants.SNMP_V3_SECURITY_NAME); //认证用户
|
|
||||||
// OctetString authPassphrase = new OctetString(Constants.SNMP_V3_AUTH_PASSPHRASE); //认证密码明文
|
|
||||||
// OctetString privPassphrase = new OctetString(Constants.SNMP_V3_PRIV_PASSPHRASE); //加密密码明文
|
|
||||||
// snmp.getUSM().addUser(securityName, new UsmUser(securityName, authProtocol, authPassphrase,privProtocol, privPassphrase));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private OID getAuthProtocol(String auth){
|
|
||||||
if (auth.equals("MD5")) {
|
|
||||||
return AuthMD5.ID;
|
|
||||||
} else if (auth.equals("SHA")) {
|
|
||||||
return AuthSHA.ID;
|
|
||||||
}else{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private OID getPrivProtocol(String priv){
|
|
||||||
if (priv.equals("DES")) {
|
|
||||||
return PrivDES.ID;
|
|
||||||
} else if ((priv.equals("AES128"))
|
|
||||||
|| (priv.equals("AES"))) {
|
|
||||||
return PrivAES128.ID;
|
|
||||||
} else if (priv.equals("AES192")) {
|
|
||||||
return PrivAES192.ID;
|
|
||||||
} else if (priv.equals("AES256")) {
|
|
||||||
return PrivAES256.ID;
|
|
||||||
}else{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private OID getAuthProtocol(String auth) {
|
||||||
|
if (auth.equals("MD5")) {
|
||||||
|
return AuthMD5.ID;
|
||||||
|
} else if (auth.equals("SHA")) {
|
||||||
|
return AuthSHA.ID;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private OID getPrivProtocol(String priv) {
|
||||||
|
if (priv.equals("DES")) {
|
||||||
|
return PrivDES.ID;
|
||||||
|
} else if ((priv.equals("AES128")) || (priv.equals("AES"))) {
|
||||||
|
return PrivAES128.ID;
|
||||||
|
} else if (priv.equals("AES192")) {
|
||||||
|
return PrivAES192.ID;
|
||||||
|
} else if (priv.equals("AES256")) {
|
||||||
|
return PrivAES256.ID;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 实现CommandResponder的processPdu方法, 用于处理传入的请求、PDU等信息 当接收到trap时,会自动进入这个方法
|
* 实现CommandResponder的processPdu方法, 用于处理传入的请求、PDU等信息 当接收到trap时,会自动进入这个方法
|
||||||
*
|
*
|
||||||
* @param respEvnt
|
* @param respEvnt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void processPdu(CommandResponderEvent commandresponderevent)
|
public void processPdu(CommandResponderEvent commandresponderevent) {
|
||||||
{
|
|
||||||
CommonDao dao = null;
|
CommonDao dao = null;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
dao = new CommonDao();
|
dao = new CommonDao();
|
||||||
logger.debug((new StringBuilder("接收到snmp event:")).append(commandresponderevent.getPDU()).toString());
|
logger.debug((new StringBuilder("接收到snmp event:")).append(commandresponderevent.getPDU()).toString());
|
||||||
UdpAddress udpaddress = (UdpAddress)commandresponderevent.getPeerAddress();
|
UdpAddress udpaddress = (UdpAddress) commandresponderevent.getPeerAddress();
|
||||||
String s = udpaddress.getInetAddress().getHostAddress();
|
String s = udpaddress.getInetAddress().getHostAddress();
|
||||||
PDU pdu = commandresponderevent.getPDU();
|
PDU pdu = commandresponderevent.getPDU();
|
||||||
logger.debug((new StringBuilder("接收到TRap:")).append(pdu).toString());
|
logger.debug((new StringBuilder("接收到TRap:")).append(pdu).toString());
|
||||||
@@ -148,9 +139,8 @@ implements CommandResponder{// implements CommandResponder, extends Service
|
|||||||
setOIDList(trapmessageinfo, pdu);
|
setOIDList(trapmessageinfo, pdu);
|
||||||
setValueList(trapmessageinfo, pdu);
|
setValueList(trapmessageinfo, pdu);
|
||||||
trapmessageinfo.setOriginalPDU(pdu);
|
trapmessageinfo.setOriginalPDU(pdu);
|
||||||
if (pdu instanceof PDUv1)
|
if (pdu instanceof PDUv1) {
|
||||||
{
|
PDUv1 pduv1 = (PDUv1) pdu;
|
||||||
PDUv1 pduv1 = (PDUv1)pdu;
|
|
||||||
trapmessageinfo.setTrapVersion(1);
|
trapmessageinfo.setTrapVersion(1);
|
||||||
String s1 = pduv1.getEnterprise().toString();
|
String s1 = pduv1.getEnterprise().toString();
|
||||||
trapmessageinfo.setTrapOID(s1);
|
trapmessageinfo.setTrapOID(s1);
|
||||||
@@ -159,154 +149,136 @@ implements CommandResponder{// implements CommandResponder, extends Service
|
|||||||
trapmessageinfo.setTrapV1SpecificType(pduv1.getSpecificTrap());
|
trapmessageinfo.setTrapV1SpecificType(pduv1.getSpecificTrap());
|
||||||
trapmessageinfo.setTrapV1GenericType(pduv1.getGenericTrap());
|
trapmessageinfo.setTrapV1GenericType(pduv1.getGenericTrap());
|
||||||
trapmessageinfo.setTrapName(trapmessageinfo.getTrapOID());
|
trapmessageinfo.setTrapName(trapmessageinfo.getTrapOID());
|
||||||
switch (pduv1.getGenericTrap())
|
switch (pduv1.getGenericTrap()) {
|
||||||
{
|
|
||||||
case 0: // '\0'
|
case 0: // '\0'
|
||||||
// trapmessageinfo.setTrapName("设备冷启动");
|
// trapmessageinfo.setTrapName("设备冷启动");
|
||||||
// trapmessageinfo.setTrapName("Device Cold Start");
|
|
||||||
trapmessageinfo.setTrapName("i18n_server.UpgradeService.coldStart_n81i");
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.coldStart_n81i");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: // '\001'
|
case 1: // '\001'
|
||||||
// trapmessageinfo.setTrapName("设备热启动");
|
// trapmessageinfo.setTrapName("设备热启动");
|
||||||
// trapmessageinfo.setTrapName("Device Hot Start");
|
|
||||||
trapmessageinfo.setTrapName("i18n_server.UpgradeService.hotStart_n81i");
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.hotStart_n81i");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: // '\002'
|
case 2: // '\002'
|
||||||
// trapmessageinfo.setTrapName("接口关闭");
|
// trapmessageinfo.setTrapName("接口关闭");
|
||||||
// trapmessageinfo.setTrapName("The Interface Is Closed");
|
|
||||||
trapmessageinfo.setTrapName("i18n_server.UpgradeService.interClose_n81i");
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.interClose_n81i");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: // '\003'
|
case 3: // '\003'
|
||||||
// trapmessageinfo.setTrapName("接口启用");
|
// trapmessageinfo.setTrapName("接口启用");
|
||||||
// trapmessageinfo.setTrapName("Interface Enabled");
|
|
||||||
trapmessageinfo.setTrapName("i18n_server.UpgradeService.interUsed_n81i");
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.interUsed_n81i");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4: // '\004'
|
case 4: // '\004'
|
||||||
// trapmessageinfo.setTrapName("SNMP认证失败");
|
// trapmessageinfo.setTrapName("SNMP认证失败");
|
||||||
// trapmessageinfo.setTrapName("SNMP Authentication Failed");
|
|
||||||
trapmessageinfo.setTrapName("i18n_server.UpgradeService.snmp_n81i");
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.snmp_n81i");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5: // '\005'
|
case 5: // '\005'
|
||||||
// trapmessageinfo.setTrapName("EGP邻居丢失");
|
// trapmessageinfo.setTrapName("EGP邻居丢失");
|
||||||
// trapmessageinfo.setTrapName("EGP Neighbor Lost");
|
|
||||||
trapmessageinfo.setTrapName("i18n_server.UpgradeService.egp_n81i");
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.egp_n81i");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
trapmessageinfo.setTrapVersion(2);
|
trapmessageinfo.setTrapVersion(2);
|
||||||
Variable variable = trapmessageinfo.getOIDValue(SnmpConstants.snmpTrapAddress.toString());
|
Variable variable = trapmessageinfo.getOIDValue(SnmpConstants.snmpTrapAddress.toString());
|
||||||
logger.debug("pdu.snmpTrapAddress() =-=-= "+variable);
|
logger.debug("pdu.snmpTrapAddress() =-=-= " + variable);
|
||||||
if (variable != null)
|
if (variable != null) {
|
||||||
trapmessageinfo.setPduAgentIP(variable.toString());
|
trapmessageinfo.setPduAgentIP(variable.toString());
|
||||||
|
}
|
||||||
Variable variable1 = trapmessageinfo.getOIDValue(SnmpConstants.snmpTrapOID.toString());
|
Variable variable1 = trapmessageinfo.getOIDValue(SnmpConstants.snmpTrapOID.toString());
|
||||||
if (variable1 != null)
|
if (variable1 != null) {
|
||||||
trapmessageinfo.setTrapOID(variable1.toString());
|
trapmessageinfo.setTrapOID(variable1.toString());
|
||||||
|
}
|
||||||
trapmessageinfo.setTrapName(trapmessageinfo.getTrapOID());
|
trapmessageinfo.setTrapName(trapmessageinfo.getTrapOID());
|
||||||
if (variable1 != null)
|
if (variable1 != null){
|
||||||
if (variable1.equals(SnmpConstants.coldStart))
|
if (variable1.equals(SnmpConstants.coldStart)) {
|
||||||
// trapmessageinfo.setTrapName("设备冷启动");
|
// trapmessageinfo.setTrapName("设备冷启动");
|
||||||
// trapmessageinfo.setTrapName("Device Cold Start");
|
|
||||||
trapmessageinfo.setTrapName("i18n_server.UpgradeService.coldStart_n81i");
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.coldStart_n81i");
|
||||||
else
|
} else if (variable1.equals(SnmpConstants.warmStart)) {
|
||||||
if (variable1.equals(SnmpConstants.warmStart))
|
// trapmessageinfo.setTrapName("设备热启动");
|
||||||
// trapmessageinfo.setTrapName("设备热启动");
|
|
||||||
trapmessageinfo.setTrapName("i18n_server.UpgradeService.hotStart_n81i");
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.hotStart_n81i");
|
||||||
else
|
} else if (variable1.equals(SnmpConstants.linkDown)) {
|
||||||
if (variable1.equals(SnmpConstants.linkDown))
|
// trapmessageinfo.setTrapName("接口关闭");
|
||||||
// trapmessageinfo.setTrapName("接口关闭");
|
|
||||||
// trapmessageinfo.setTrapName("The Interface Is Closed");
|
|
||||||
trapmessageinfo.setTrapName("i18n_server.UpgradeService.interClose_n81i");
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.interClose_n81i");
|
||||||
else
|
} else if (variable1.equals(SnmpConstants.linkUp)) {
|
||||||
if (variable1.equals(SnmpConstants.linkUp))
|
// trapmessageinfo.setTrapName("接口启用");
|
||||||
// trapmessageinfo.setTrapName("接口启用");
|
|
||||||
// trapmessageinfo.setTrapName("Interface Enabled");
|
|
||||||
trapmessageinfo.setTrapName("i18n_server.UpgradeService.interUsed_n81i");
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.interUsed_n81i");
|
||||||
else
|
} else if (variable1.equals(SnmpConstants.authenticationFailure)) {
|
||||||
if (variable1.equals(SnmpConstants.authenticationFailure))
|
// trapmessageinfo.setTrapName("SNMP认证失败");
|
||||||
// trapmessageinfo.setTrapName("SNMP认证失败");
|
|
||||||
// trapmessageinfo.setTrapName("SNMP Authentication Failed");
|
|
||||||
trapmessageinfo.setTrapName("i18n_server.UpgradeService.snmp_n81i");
|
trapmessageinfo.setTrapName("i18n_server.UpgradeService.snmp_n81i");
|
||||||
else //系统默认的类别不能匹配时,再使用自定义的trap信息库。是否需要分别自定义snmpV1和snmpValue2的trap信息库(定义到文件或者定义到数据库,必须体统重新加载的界面接口)
|
} else if (getTrapName(variable1) != null && !variable1.equals("")) {
|
||||||
if(getTrapName(variable1)!=null &&!variable1.equals("")){
|
// 系统默认的类别不能匹配时,再使用自定义的trap信息库。是否需要分别自定义snmpV1和snmpValue2的trap信息库(定义到文件或者定义到数据库,必须体统重新加载的界面接口)
|
||||||
trapmessageinfo.setTrapName(getTrapName(variable1));
|
trapmessageinfo.setTrapName(getTrapName(variable1));
|
||||||
}else{
|
} else {
|
||||||
// throw new Exception("未被定义的SNMPTRAP类型!");
|
|
||||||
throw new Exception("Undefined SNMPTRAP type!");
|
throw new Exception("Undefined SNMPTRAP type!");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
StringBuffer trapInfo = new StringBuffer();
|
StringBuffer trapInfo = new StringBuffer();
|
||||||
trapInfo.append("trapmessageinfo.getTrapName():"+trapmessageinfo.getTrapName());
|
if(!trapmessageinfo.getTrapName().equals(trapmessageinfo.getTrapOID())){
|
||||||
trapInfo.append(";trapmessageinfo.getAgentSendIP():"+trapmessageinfo.getAgentSendIP());
|
trapInfo.append("TrapName:" + trapmessageinfo.getTrapName());
|
||||||
trapInfo.append(";trapmessageinfo.getOriginalPDU():"+trapmessageinfo.getOriginalPDU());
|
trapInfo.append(Constants.COMMON_DATA_POINT);
|
||||||
trapInfo.append(";trapmessageinfo.getTrapVersion():"+trapmessageinfo.getTrapVersion());
|
}
|
||||||
trapInfo.append(";trapmessageinfo.getTrapOID():"+trapmessageinfo.getTrapOID());
|
trapInfo.append(" AgentSendIP:" + trapmessageinfo.getAgentSendIP());
|
||||||
trapInfo.append(";trapmessageinfo.getPduAgentIP():"+trapmessageinfo.getPduAgentIP());
|
trapInfo.append(Constants.COMMON_DATA_POINT);
|
||||||
trapInfo.append(";trapmessageinfo.getTrapV1GenericType():"+trapmessageinfo.getTrapV1GenericType());
|
trapInfo.append(" OriginalPDU:" + trapmessageinfo.getOriginalPDU());
|
||||||
trapInfo.append(";trapmessageinfo.getTrapV1SpecificType():"+trapmessageinfo.getTrapV1SpecificType());
|
trapInfo.append(Constants.COMMON_DATA_POINT);
|
||||||
logger.debug("agent IP:"+s+" trap信息:"+trapInfo.toString());
|
trapInfo.append(" TrapVersion:" + trapmessageinfo.getTrapVersion());
|
||||||
new CommonService(dao).newClientCheck(s,trapmessageinfo.getTrapVersion());
|
trapInfo.append(Constants.COMMON_DATA_POINT);
|
||||||
|
trapInfo.append(" TrapOID:" + trapmessageinfo.getTrapOID());
|
||||||
|
trapInfo.append(Constants.COMMON_DATA_POINT);
|
||||||
|
trapInfo.append(" PduAgentIP:" + trapmessageinfo.getPduAgentIP());
|
||||||
|
trapInfo.append(Constants.COMMON_DATA_POINT);
|
||||||
|
trapInfo.append(" TrapV1GenericType:" + trapmessageinfo.getTrapV1GenericType());
|
||||||
|
trapInfo.append(Constants.COMMON_DATA_POINT);
|
||||||
|
trapInfo.append(" TrapV1SpecificType:" + trapmessageinfo.getTrapV1SpecificType());
|
||||||
|
logger.debug("agent IP:" + s + " trap信息:" + trapInfo.toString());
|
||||||
|
new CommonService(dao).newClientCheck(s, trapmessageinfo.getTrapVersion());
|
||||||
SetInfo info = Common.getSnmpTrapSetInfo();
|
SetInfo info = Common.getSnmpTrapSetInfo();
|
||||||
String [] dsb = Common.alarmExceptionInfo(info.getId(), s, info.getCheckTypeName(), info.getProcessIden(), trapmessageinfo.getReceiverTime().getTime(), 1,Constants.DETECTION_INFO_ALARM_WRONG, trapInfo.toString());
|
logger.debug(String.format("snmp setInfo : %s", Json.toJson(info, JsonFormat.tidy())));
|
||||||
|
//snmp trap 默认告警级别为:0紧急
|
||||||
|
String[] dsb = Common.alarmExceptionInfo(info.getId(), s, info.getCheckTypeName(), info.getProcessIden(),
|
||||||
|
trapmessageinfo.getReceiverTime().getTime(), 0, Constants.DETECTION_INFO_ALARM_WRONG,
|
||||||
|
trapInfo.toString());
|
||||||
Common.addAlarmData(dsb);
|
Common.addAlarmData(dsb);
|
||||||
|
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception exception)
|
logger.error("解析UDP TRAP发生错误:", e);
|
||||||
{
|
} finally {
|
||||||
logger.debug((new StringBuilder("解析UDP TRAP发生错误:")).append(exception.getMessage()).toString());
|
if (dao != null) {
|
||||||
}finally{
|
|
||||||
if(dao!=null){
|
|
||||||
dao.close();
|
dao.close();
|
||||||
dao=null;
|
dao = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTrapName(Variable variable1){
|
public String getTrapName(Variable variable1) {
|
||||||
String trapName = "";
|
return variable1.toString();
|
||||||
Map allTrapTypeDefine = new HashMap();
|
|
||||||
trapName = allTrapTypeDefine.get(variable1.toString()).toString();
|
|
||||||
return trapName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setOIDList(TrapMessageInfo trapmessageinfo, PDU pdu)
|
void setOIDList(TrapMessageInfo trapmessageinfo, PDU pdu) {
|
||||||
{
|
|
||||||
Vector vector = pdu.getVariableBindings();
|
Vector vector = pdu.getVariableBindings();
|
||||||
String s;
|
String s;
|
||||||
// for(int i=0;i<vector.size();i++){
|
// for(int i=0;i<vector.size();i++){
|
||||||
// VariableBinding vbing = (VariableBinding)vector.elementAt(i);
|
// VariableBinding vbing = (VariableBinding)vector.elementAt(i);
|
||||||
// s = vbing.getOid().toString();
|
// s = vbing.getOid().toString();
|
||||||
// trapmessageinfo.getTrapPDUOIDs().add(s);
|
// trapmessageinfo.getTrapPDUOIDs().add(s);
|
||||||
// }
|
// }
|
||||||
for (Iterator iterator = vector.iterator(); iterator.hasNext(); trapmessageinfo.getTrapPDUOIDs().add(s))
|
for (Iterator iterator = vector.iterator(); iterator.hasNext(); trapmessageinfo.getTrapPDUOIDs().add(s)) {
|
||||||
{
|
VariableBinding variablebinding = (VariableBinding) iterator.next();
|
||||||
VariableBinding variablebinding = (VariableBinding)iterator.next();
|
|
||||||
s = variablebinding.getOid().toString();
|
s = variablebinding.getOid().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setValueList(TrapMessageInfo trapmessageinfo, PDU pdu)
|
void setValueList(TrapMessageInfo trapmessageinfo, PDU pdu) {
|
||||||
{
|
|
||||||
Vector vector = pdu.getVariableBindings();
|
Vector vector = pdu.getVariableBindings();
|
||||||
Variable variable;
|
Variable variable;
|
||||||
for (Iterator iterator = vector.iterator(); iterator.hasNext(); trapmessageinfo.getTrapPDUOIDValues().add(variable))
|
for (Iterator iterator = vector.iterator(); iterator.hasNext(); trapmessageinfo.getTrapPDUOIDValues()
|
||||||
{
|
.add(variable)) {
|
||||||
VariableBinding variablebinding = (VariableBinding)iterator.next();
|
VariableBinding variablebinding = (VariableBinding) iterator.next();
|
||||||
variable = variablebinding.getVariable();
|
variable = variablebinding.getVariable();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public static void main(String[] args) {
|
|
||||||
TrapServer multithreadedtrapreceiver = new TrapServer();
|
|
||||||
multithreadedtrapreceiver.run();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
/**
|
/**
|
||||||
@@ -325,22 +297,6 @@ implements CommandResponder{// implements CommandResponder, extends Service
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 将十进六制转换成为中文
|
|
||||||
*//*
|
|
||||||
private static String hexString = "0123456789ABCDEF";
|
|
||||||
|
|
||||||
public static String toStringHex(String bytes) {
|
|
||||||
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream(
|
|
||||||
bytes.length() / 2);
|
|
||||||
//将每2位16进制整数组装成一个字节
|
|
||||||
for (int i = 0; i < bytes.length(); i += 2) {
|
|
||||||
baos.write((hexString.indexOf(bytes.charAt(i)) << 4 | hexString
|
|
||||||
.indexOf(bytes.charAt(i + 1))));
|
|
||||||
}
|
|
||||||
return new String(baos.toByteArray());
|
|
||||||
}*/
|
|
||||||
|
|
||||||
protected static String printVariableBindings(PDU response) {
|
protected static String printVariableBindings(PDU response) {
|
||||||
String strCom = "";
|
String strCom = "";
|
||||||
@@ -356,18 +312,16 @@ implements CommandResponder{// implements CommandResponder, extends Service
|
|||||||
}
|
}
|
||||||
strCom += vb.getVariable();
|
strCom += vb.getVariable();
|
||||||
if (str.length != 1) {
|
if (str.length != 1) {
|
||||||
logger.debug("==第行=vb.getVariable()=" + SNMP4JUtils.toStringHex(strOut));//显示中文
|
logger.debug("==第行=vb.getVariable()=" + SNMP4JUtils.toStringHex(strOut));// 显示中文
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return strCom;
|
return strCom;
|
||||||
|
|
||||||
}
|
}
|
||||||
public static void main(String [] args) {
|
|
||||||
|
public static void main(String[] args) {
|
||||||
try {
|
try {
|
||||||
TrapServer.getInstance();
|
TrapServer.getInstance();
|
||||||
TrapServer.getInstance();
|
|
||||||
TrapServer.getInstance();
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,11 +138,9 @@ public class ChangePluginScriptFile implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String ip : ncNodesIpStrSet) {
|
for (String ip : ncNodesIpStrSet) {
|
||||||
Common.runChangeRunnable(new SendPluginScriptFile(ip, sendRecordList.get(ip)));
|
Common.runChangeRunnable(new SendPluginScriptFile(ip, sendRecordList.get(ip)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 延时清理脚本
|
// 延时清理脚本
|
||||||
new Thread(new DeletePluginScriptDirAfterSending()).start();
|
new Thread(new DeletePluginScriptDirAfterSending()).start();
|
||||||
|
|
||||||
@@ -348,6 +346,11 @@ public class ChangePluginScriptFile implements Runnable {
|
|||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
logger.error("Delete EventRecordLibrary", e);
|
logger.error("Delete EventRecordLibrary", e);
|
||||||
|
} finally {
|
||||||
|
if (dao != null) {
|
||||||
|
dao.close();
|
||||||
|
dao = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -403,7 +406,7 @@ public class ChangePluginScriptFile implements Runnable {
|
|||||||
String ips = Common.getIpSeqIdMap().get(recvIpSet.iterator().next())+"";
|
String ips = Common.getIpSeqIdMap().get(recvIpSet.iterator().next())+"";
|
||||||
changeService.saveEventRecordLibrary(SEND_PLUGIN_SCRIPT_FILE, ips,
|
changeService.saveEventRecordLibrary(SEND_PLUGIN_SCRIPT_FILE, ips,
|
||||||
"S2C", JSONObject.fromObject(recordContent).toString());
|
"S2C", JSONObject.fromObject(recordContent).toString());
|
||||||
|
task.new DeletePluginScriptDirAfterSending().run();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -514,6 +517,7 @@ public class ChangePluginScriptFile implements Runnable {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logger.debug("删除临时目录" + pluginScriptDir.getAbsolutePath());
|
||||||
FileUtils.deleteAllFiles(pluginScriptDir, true);
|
FileUtils.deleteAllFiles(pluginScriptDir, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -528,6 +532,7 @@ public class ChangePluginScriptFile implements Runnable {
|
|||||||
File tempPluginDir = new File(Constants.PLUGIN_SCRIPT_FILE_DIR, System.currentTimeMillis()+"");
|
File tempPluginDir = new File(Constants.PLUGIN_SCRIPT_FILE_DIR, System.currentTimeMillis()+"");
|
||||||
if (!tempPluginDir.exists()) {
|
if (!tempPluginDir.exists()) {
|
||||||
tempPluginDir.mkdirs();
|
tempPluginDir.mkdirs();
|
||||||
|
logger.debug("创建临时目录" + tempPluginDir.getAbsolutePath());
|
||||||
}
|
}
|
||||||
return tempPluginDir;
|
return tempPluginDir;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import java.util.Queue;
|
|||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.alibaba.druid.support.json.JSONUtils;
|
||||||
import com.fang.lang.Db;
|
import com.fang.lang.Db;
|
||||||
import com.nms.server.bean.AlarmInfo;
|
import com.nms.server.bean.AlarmInfo;
|
||||||
import com.nms.server.bean.DetectInfo;
|
import com.nms.server.bean.DetectInfo;
|
||||||
@@ -38,7 +39,7 @@ import com.nms.server.util.StringUtil;
|
|||||||
*/
|
*/
|
||||||
public class DataResolveThread implements Runnable{
|
public class DataResolveThread implements Runnable{
|
||||||
private static Logger logger = Logger.getLogger(DataResolveThread.class);
|
private static Logger logger = Logger.getLogger(DataResolveThread.class);
|
||||||
private final SimpleDateFormat format = Common.getFormat(); //Java Date 类型数据格式化格式
|
private SimpleDateFormat format = new SimpleDateFormat(Constants.COMMON_DATE_FORMAT); //Java Date 类型数据格式化格式
|
||||||
private static Db db = Common.getDb();
|
private static Db db = Common.getDb();
|
||||||
|
|
||||||
|
|
||||||
@@ -396,7 +397,7 @@ public class DataResolveThread implements Runnable{
|
|||||||
delyFlag = false;
|
delyFlag = false;
|
||||||
}
|
}
|
||||||
Calendar arriveTime = Calendar.getInstance();
|
Calendar arriveTime = Calendar.getInstance();
|
||||||
detectInfo = new Object[33];
|
detectInfo = new Object[DetectInfo.DETEC_ARR_SIZE];
|
||||||
//detectInfo[DetectInfo.null] = (CSVUtils.csvBytesPrinter1(strsList, Constants.COMMON_TEXT_CODING));
|
//detectInfo[DetectInfo.null] = (CSVUtils.csvBytesPrinter1(strsList, Constants.COMMON_TEXT_CODING));
|
||||||
detectInfo[DetectInfo.SEQID] = (seqId);
|
detectInfo[DetectInfo.SEQID] = (seqId);
|
||||||
detectInfo[DetectInfo.SETINFOID] = (setInfoId);
|
detectInfo[DetectInfo.SETINFOID] = (setInfoId);
|
||||||
@@ -846,6 +847,7 @@ public class DataResolveThread implements Runnable{
|
|||||||
//--基本信息解析 存在异常值 无须保存,返回错误信息 用于系统告警
|
//--基本信息解析 存在异常值 无须保存,返回错误信息 用于系统告警
|
||||||
if(errorInfo.length() != 0){
|
if(errorInfo.length() != 0){
|
||||||
logger.error(" 第一步-1: 新格式监测数据解析异常: seqId:"+seqId+",setInfoId:"+setInfoId+",checkType:"+checkType+" checkTime:"+new Date(checkTime)+" 监测数据解析异常:"+errorInfo);
|
logger.error(" 第一步-1: 新格式监测数据解析异常: seqId:"+seqId+",setInfoId:"+setInfoId+",checkType:"+checkType+" checkTime:"+new Date(checkTime)+" 监测数据解析异常:"+errorInfo);
|
||||||
|
logger.error("错误数据内容如下 : "+JSONUtils.toJSONString(strsList));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -857,7 +859,7 @@ public class DataResolveThread implements Runnable{
|
|||||||
|
|
||||||
//公共信息集合
|
//公共信息集合
|
||||||
Calendar arriveTime = Calendar.getInstance();
|
Calendar arriveTime = Calendar.getInstance();
|
||||||
detectInfo = new Object[33];
|
detectInfo = new Object[DetectInfo.DETEC_ARR_SIZE];
|
||||||
//detectInfo[DetectInfo.null] = (CSVUtils.csvBytesPrinter1(strsList, Constants.COMMON_TEXT_CODING));
|
//detectInfo[DetectInfo.null] = (CSVUtils.csvBytesPrinter1(strsList, Constants.COMMON_TEXT_CODING));
|
||||||
detectInfo[DetectInfo.SEQID] = (seqId);
|
detectInfo[DetectInfo.SEQID] = (seqId);
|
||||||
detectInfo[DetectInfo.SETINFOID] = (setInfoId);
|
detectInfo[DetectInfo.SETINFOID] = (setInfoId);
|
||||||
@@ -955,28 +957,32 @@ public class DataResolveThread implements Runnable{
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String fileType = field.getFiledType().toUpperCase();
|
String fileType = field.getFiledType().toUpperCase();
|
||||||
|
String col = detailsArr0[index];
|
||||||
if("DATE".equals(fileType)){
|
if("DATE".equals(fileType)){
|
||||||
if(StringUtils.isNumeric(detailsArr0[index])){//如果为数字型时间,转换
|
if(StringUtils.isBlank(col)){
|
||||||
detail.put(field.getFiledName(), format.format(new Date(Long.parseLong(detailsArr0[index].trim()))));
|
detail.put(field.getFiledName(), null);
|
||||||
|
}else if(StringUtils.isNumeric(col)){//如果为数字型时间,转换
|
||||||
|
detail.put(field.getFiledName(), format.format(new Date(Long.parseLong(col.trim()))));
|
||||||
}else{//eg:2016-03-06 12:12:12
|
}else{//eg:2016-03-06 12:12:12
|
||||||
detail.put(field.getFiledName(), detailsArr0[index].trim());
|
detail.put(field.getFiledName(), col.trim());
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if("NUMBER".equals(fileType)){
|
if("NUMBER".equals(fileType)){
|
||||||
if (StringUtils.isBlank(detailsArr0[index])
|
if(StringUtils.isBlank(col)){
|
||||||
|| StringUtil.isRationalNumber(detailsArr0[index])) {
|
detail.put(field.getFiledName(), null);
|
||||||
detail.put(field.getFiledName(), detailsArr0[index].trim());
|
} else if (StringUtil.isRationalNumber(col)) {
|
||||||
} else if (detailsArr0[index].trim().contains(" days, ")) {
|
detail.put(field.getFiledName(), col.trim());
|
||||||
detail.put(field.getFiledName(), CommonService.getLongTimeStr(detailsArr0[index].trim()));
|
} else if (col.trim().contains(" days, ")) {
|
||||||
|
detail.put(field.getFiledName(), CommonService.getLongTimeStr(col.trim()));
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("NUMBER数据格式错误!");
|
throw new Exception("NUMBER数据格式错误!");
|
||||||
}
|
}
|
||||||
}else{ // VARCHAR2(x)
|
}else{ // VARCHAR2(x)
|
||||||
String length = fileType.replaceAll("VARCHAR2\\((\\d+)\\)", "$1");
|
String length = fileType.replaceAll("VARCHAR2\\((\\d+)\\)", "$1");
|
||||||
if(Integer.parseInt(length) < detailsArr0[index].trim().length()) {
|
if(Integer.parseInt(length) < col.trim().length()) {
|
||||||
throw new Exception("VARCHAR2数据格式错误!");
|
throw new Exception("VARCHAR2数据格式错误!");
|
||||||
}
|
}
|
||||||
detail.put(field.getFiledName(), detailsArr0[index].trim());
|
detail.put(field.getFiledName(), col.trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -988,7 +994,7 @@ public class DataResolveThread implements Runnable{
|
|||||||
}
|
}
|
||||||
errorInfo.deleteCharAt(errorInfo.length()-1);
|
errorInfo.deleteCharAt(errorInfo.length()-1);
|
||||||
//监测数据的详细信息如果和指定的字段类型不匹配,则抛弃此条监测数据,避免影响批量入库
|
//监测数据的详细信息如果和指定的字段类型不匹配,则抛弃此条监测数据,避免影响批量入库
|
||||||
logger.error(" 第一步-1: 新格式监测数据解析异常: seqId:"+seqId+",setInfoId:"+setInfoId+",checkType:"+checkType+" checkTime:"+new Date(checkTime)+" 监测数据解析异常:"+errorInfo);
|
logger.error(" 第一步-1: 新格式监测数据解析异常: seqId:"+seqId+",setInfoId:"+setInfoId+",checkType:"+checkType+" checkTime:"+new Date(checkTime)+" 监测数据解析异常:"+errorInfo,e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
@@ -1015,18 +1021,20 @@ public class DataResolveThread implements Runnable{
|
|||||||
String ifAdminStatus = detailsArr0[9];//showNum=7,1:up,2:down
|
String ifAdminStatus = detailsArr0[9];//showNum=7,1:up,2:down
|
||||||
if("2".equals(ifAdminStatus)) {
|
if("2".equals(ifAdminStatus)) {
|
||||||
state = 0;//监测公共信息的状态
|
state = 0;//监测公共信息的状态
|
||||||
dsinfo += "$@$端口"+ifDescr+"异常(配置状态与实际状态不符)";
|
// dsinfo += "$@$端口"+ifDescr+"异常(配置状态与实际状态不符)";
|
||||||
|
dsinfo += "i18n_server.CommonService.dsinfo1_n81i"+ifDescr+"i18n_server.CommonService.dsinfo1.exception_n81i";
|
||||||
detailDetectionState = "0";//当前端口的状态
|
detailDetectionState = "0";//当前端口的状态
|
||||||
pLevel = Constants.PORT_ALARM_LEVEL;//非界面设置,默认为5级
|
pLevel = Constants.PORT_ALARM_LEVEL;//非界面设置,默认为5级
|
||||||
}
|
}
|
||||||
|
//2018年12月3日18:11:57 添加开关,可以控制是否开启流量为 0 告警功能
|
||||||
if("1".equals(detailDetectionState)) {//如果当前端口的状态正常,才需要判断流量是否为0
|
if("1".equals(detailDetectionState) && Constants.PORT_ZERO_WARNING_FLAG) {//如果当前端口的状态正常,才需要判断流量是否为0
|
||||||
double inOctetsSpeed = detailsArr0[25]==null?0d:("".equals(detailsArr0[25])?0d:Double.parseDouble(detailsArr0[25].trim()));//23+2=25,瞬时输入字节速度
|
double inOctetsSpeed = detailsArr0[25]==null?0d:("".equals(detailsArr0[25])?0d:Double.parseDouble(detailsArr0[25].trim()));//23+2=25,瞬时输入字节速度
|
||||||
double outOctetsSpeed = detailsArr0[29]==null?0d:("".equals(detailsArr0[29])?0d:Double.parseDouble(detailsArr0[29].trim()));//27+2=29,瞬时输出字节速度
|
double outOctetsSpeed = detailsArr0[29]==null?0d:("".equals(detailsArr0[29])?0d:Double.parseDouble(detailsArr0[29].trim()));//27+2=29,瞬时输出字节速度
|
||||||
logger.info("test:port:inOctetsSpeed="+inOctetsSpeed+";outOctetsSpeed="+outOctetsSpeed);
|
logger.info("test:port:inOctetsSpeed="+inOctetsSpeed+";outOctetsSpeed="+outOctetsSpeed);
|
||||||
if((inOctetsSpeed+outOctetsSpeed)<=0) {
|
if((inOctetsSpeed+outOctetsSpeed)<=0) {
|
||||||
state = 0;//监测公共信息的状态
|
state = 0;//监测公共信息的状态
|
||||||
dsinfo += "$@$端口"+ifDescr+"异常(流量为0),inOctetsSpeed="+inOctetsSpeed+",outOctetsSpeed="+outOctetsSpeed+",sum="+(inOctetsSpeed+outOctetsSpeed);
|
// dsinfo += "$@$端口"+ifDescr+"异常(流量为0),inOctetsSpeed="+inOctetsSpeed+",outOctetsSpeed="+outOctetsSpeed+",sum="+(inOctetsSpeed+outOctetsSpeed);
|
||||||
|
dsinfo += "i18n_server.CommonService.dsinfo1_n81i"+ifDescr+"i18n_server.CommonService.dsinfo1.exception_n81i,inOctetsSpeed="+inOctetsSpeed+",outOctetsSpeed="+outOctetsSpeed+",sum="+(inOctetsSpeed+outOctetsSpeed);
|
||||||
detailDetectionState = "0";//当前端口的状态
|
detailDetectionState = "0";//当前端口的状态
|
||||||
pLevel = Constants.PORT_ALARM_LEVEL;//非界面设置,默认为5级
|
pLevel = Constants.PORT_ALARM_LEVEL;//非界面设置,默认为5级
|
||||||
}
|
}
|
||||||
@@ -1089,9 +1097,10 @@ public class DataResolveThread implements Runnable{
|
|||||||
filedComments = tm==null?"":tm.getFiledComments();
|
filedComments = tm==null?"":tm.getFiledComments();
|
||||||
}
|
}
|
||||||
cpInfo += " "+(StringUtils.isEmpty(elem.getFiledCommonts())?filedName:elem.getFiledCommonts());
|
cpInfo += " "+(StringUtils.isEmpty(elem.getFiledCommonts())?filedName:elem.getFiledCommonts());
|
||||||
cpInfo += " 为:"+detail.get(filedName);
|
cpInfo += " i18n_server.CommonService.for_n81i:"+detail.get(filedName);
|
||||||
cpInfo += (elem.getPoliceUnit()==null ? "" : "null".equals(elem.getPoliceUnit()) ? "" : elem.getPoliceUnit());
|
cpInfo += (elem.getPoliceUnit()==null ? "" : "null".equals(elem.getPoliceUnit()) ? "" : elem.getPoliceUnit());
|
||||||
cpInfo += " 报警级别:"+pLevel;
|
// cpInfo += " 报警级别:"+pLevel;
|
||||||
|
cpInfo += " i18n_server.CommonService.policyLevel_n81i:"+pLevel;
|
||||||
cpInfo += " \n";
|
cpInfo += " \n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,7 +168,9 @@ public class DetectDetailInsertThread implements Runnable{
|
|||||||
int count=0;
|
int count=0;
|
||||||
for(Object[] e : params){
|
for(Object[] e : params){
|
||||||
arrTemp=e;
|
arrTemp=e;
|
||||||
logger.debug(" params " + Arrays.toString(e)+"addToBatch :"+ ++count);
|
if(Constants.DEBUG_DETECTDETAILINSERTTHREAD_SAVETODB) {
|
||||||
|
logger.debug(" params " + Arrays.toString(e)+"addToBatch :"+ ++count);
|
||||||
|
}
|
||||||
for (int i = 0; i < e.length; i++) {
|
for (int i = 0; i < e.length; i++) {
|
||||||
Object value = e[i];
|
Object value = e[i];
|
||||||
temp=value;
|
temp=value;
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ public class DetectInfoInsertThread implements Runnable {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("error", e);
|
logger.error("error", e);
|
||||||
}finally {
|
}finally {
|
||||||
db.closeQuiet(infoStmt,warnStmt,emailStmt,statusChangeStmt,conn,infoNewInsertStmt,infoNewUpdateStmt);
|
db.closeQuiet(infoStmt,warnStmt,emailStmt,statusChangeStmt,conn,infoNewInsertStmt,infoNewUpdateStmt,warnUpdateStmt);
|
||||||
infoStmt = null;
|
infoStmt = null;
|
||||||
warnStmt = null;
|
warnStmt = null;
|
||||||
emailStmt = null;
|
emailStmt = null;
|
||||||
@@ -118,6 +118,7 @@ public class DetectInfoInsertThread implements Runnable {
|
|||||||
conn = null;
|
conn = null;
|
||||||
infoNewInsertStmt=null;
|
infoNewInsertStmt=null;
|
||||||
infoNewUpdateStmt=null;
|
infoNewUpdateStmt=null;
|
||||||
|
warnUpdateStmt = null;
|
||||||
}
|
}
|
||||||
sw.end();
|
sw.end();
|
||||||
logger.info("监测数据info信息解析入库,耗时: " + U.StopWatch.toString(sw.total()) + " ,共 " + count + " 条");
|
logger.info("监测数据info信息解析入库,耗时: " + U.StopWatch.toString(sw.total()) + " ,共 " + count + " 条");
|
||||||
@@ -223,8 +224,12 @@ public class DetectInfoInsertThread implements Runnable {
|
|||||||
|
|
||||||
// 入库
|
// 入库
|
||||||
saveToNew(insertDataTonew, 0);
|
saveToNew(insertDataTonew, 0);
|
||||||
|
sw.tag("insertDataTonew");
|
||||||
|
logger.debug("耗时统计: insertDataTonew " + sw.toString(sw.between("insertDataTonew",l + "e")));
|
||||||
|
|
||||||
saveToNew(updateDataTonew, 1);
|
saveToNew(updateDataTonew, 1);
|
||||||
logger.info("info_new table update success! data size : "+(insertDataTonew.size()+updateDataTonew.size()));
|
sw.tag("updateDataTonew");
|
||||||
|
logger.debug("耗时统计: updateDataTonew " + sw.toString(sw.between("updateDataTonew","insertDataTonew")));
|
||||||
saveInfo(params);
|
saveInfo(params);
|
||||||
sw.tag(l + "sa");
|
sw.tag(l + "sa");
|
||||||
logger.debug("入库完成,耗时:" + U.StopWatch.toString(sw.between(l + "sa", l + "e")) );
|
logger.debug("入库完成,耗时:" + U.StopWatch.toString(sw.between(l + "sa", l + "e")) );
|
||||||
@@ -243,12 +248,16 @@ public class DetectInfoInsertThread implements Runnable {
|
|||||||
*/
|
*/
|
||||||
private void saveInfo(List<Object[]> infoList) throws SQLException {
|
private void saveInfo(List<Object[]> infoList) throws SQLException {
|
||||||
Object[] temInfo = null;
|
Object[] temInfo = null;
|
||||||
|
StopWatch sw = new StopWatch();
|
||||||
|
sw.tag("start");
|
||||||
try {
|
try {
|
||||||
int infoCount = infoList.size();
|
int infoCount = infoList.size();
|
||||||
int warnCount = 0;
|
int warnCount = 0;
|
||||||
int emailCount = 0;
|
int emailCount = 0;
|
||||||
|
int warnRecoveryCount = 0;
|
||||||
Map<String,Long> statusChangeMap = U.newHashMap();
|
Map<String,Long> statusChangeMap = U.newHashMap();
|
||||||
boolean emailFlag = Constants.flag_email == 1;// 是否启用 email
|
boolean emailFlag = Constants.flag_email == 1;// 是否启用 email
|
||||||
|
logger.info(emailFlag?"邮件功能開啟" : "邮件功能已关闭");
|
||||||
Iterator<Object[]> ite = infoList.iterator();
|
Iterator<Object[]> ite = infoList.iterator();
|
||||||
while (ite.hasNext()) {
|
while (ite.hasNext()) {
|
||||||
temInfo = ite.next();
|
temInfo = ite.next();
|
||||||
@@ -332,7 +341,7 @@ public class DetectInfoInsertThread implements Runnable {
|
|||||||
|
|
||||||
// 添加邮件信息
|
// 添加邮件信息
|
||||||
if (!emailFlag) {
|
if (!emailFlag) {
|
||||||
logger.info("邮件功能已关闭");
|
|
||||||
} else {
|
} else {
|
||||||
if ((Boolean) temInfo[DetectInfo.SENDEMAILFLAG]) {
|
if ((Boolean) temInfo[DetectInfo.SENDEMAILFLAG]) {
|
||||||
EmailInfo emailInfo = (EmailInfo) temInfo[DetectInfo.EMAILINFO];
|
EmailInfo emailInfo = (EmailInfo) temInfo[DetectInfo.EMAILINFO];
|
||||||
@@ -387,17 +396,39 @@ public class DetectInfoInsertThread implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态恢复
|
||||||
|
*/
|
||||||
|
if(temInfo[DetectInfo.WARN_2_OK] != null && temInfo[DetectInfo.WARN_2_OK].equals(1)) {
|
||||||
|
Object[] params = new Object[] {temInfo[DetectInfo.SEQID],temInfo[DetectInfo.SETINFOID]};
|
||||||
|
addRecordToStatement(warnUpdateStmt, params);
|
||||||
|
warnRecoveryCount ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ite.remove();
|
ite.remove();
|
||||||
}
|
}
|
||||||
|
sw.tag("while");
|
||||||
|
logger.debug("耗时统计: add statement " + sw.toString(sw.between("while","start")));
|
||||||
if(infoCount >0){
|
if(infoCount >0){
|
||||||
infoStmt.executeBatch();
|
infoStmt.executeBatch();
|
||||||
}
|
}
|
||||||
|
sw.tag("info");
|
||||||
|
logger.debug("耗时统计: info executeBatch " + sw.toString(sw.between("info","while")));
|
||||||
|
|
||||||
if(warnCount >0){
|
if(warnCount >0){
|
||||||
warnStmt.executeBatch();
|
warnStmt.executeBatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sw.tag("warn");
|
||||||
|
logger.debug("耗时统计: warnStmt executeBatch " + sw.toString(sw.between("warn","info")));
|
||||||
|
|
||||||
if(emailCount >0){
|
if(emailCount >0){
|
||||||
emailStmt.executeBatch();
|
emailStmt.executeBatch();
|
||||||
}
|
}
|
||||||
|
sw.tag("email");
|
||||||
|
logger.debug("耗时统计: email executeBatch " + sw.toString(sw.between("email","warn")));
|
||||||
|
|
||||||
if(statusChangeMap.size() > 0){
|
if(statusChangeMap.size() > 0){
|
||||||
if(statusChangeStmt == null){
|
if(statusChangeStmt == null){
|
||||||
@@ -411,10 +442,19 @@ public class DetectInfoInsertThread implements Runnable {
|
|||||||
}
|
}
|
||||||
statusChangeStmt.executeBatch();
|
statusChangeStmt.executeBatch();
|
||||||
}
|
}
|
||||||
|
sw.tag("status");
|
||||||
warnUpdateStmt.executeBatch();//update warning
|
logger.debug("耗时统计: status executeBatch " + sw.toString(sw.between("status","email")));
|
||||||
|
if(warnRecoveryCount > 0) {
|
||||||
|
warnUpdateStmt.executeBatch();
|
||||||
|
}
|
||||||
|
//warnUpdateStmt.executeBatch();//update warning
|
||||||
|
sw.tag("warnUpdate");
|
||||||
|
logger.debug("耗时统计: warnUpdate executeBatch " + sw.toString(sw.between("warnUpdate","status")));
|
||||||
|
|
||||||
conn.commit();
|
conn.commit();
|
||||||
|
sw.tag("commit");
|
||||||
|
logger.debug("耗时统计: commit executeBatch " + sw.toString(sw.between("commit","warnUpdate")));
|
||||||
|
|
||||||
logger.info("批量保存,info :" + infoCount + " , warn : " + warnCount + " ,email : "+ emailCount);
|
logger.info("批量保存,info :" + infoCount + " , warn : " + warnCount + " ,email : "+ emailCount);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("info save error ,temInfo : "+Arrays.toString(temInfo) ,e);
|
logger.error("info save error ,temInfo : "+Arrays.toString(temInfo) ,e);
|
||||||
@@ -432,6 +472,9 @@ public class DetectInfoInsertThread implements Runnable {
|
|||||||
if(statusChangeStmt != null){
|
if(statusChangeStmt != null){
|
||||||
statusChangeStmt.clearBatch();
|
statusChangeStmt.clearBatch();
|
||||||
}
|
}
|
||||||
|
if(warnUpdateStmt != null) {
|
||||||
|
warnUpdateStmt.clearBatch();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -581,12 +624,12 @@ public class DetectInfoInsertThread implements Runnable {
|
|||||||
/* 判断状态变更 */
|
/* 判断状态变更 */
|
||||||
stateChange(newDetecInfo, oldDetecInfo);
|
stateChange(newDetecInfo, oldDetecInfo);
|
||||||
} else {// 监测时间小于数据库中监测数据的时间,说明当前需要入库的监测为延迟数据
|
} else {// 监测时间小于数据库中监测数据的时间,说明当前需要入库的监测为延迟数据
|
||||||
if (state != 1) {// 延迟数据监测状态没有成功,数据库入库的是正常数据,补录一条报警信息
|
/*if (state != 1) {// 延迟数据监测状态没有成功,数据库入库的是正常数据,补录一条报警信息
|
||||||
if ((Integer) newDetecInfo[DetectInfo.STATE] == 1
|
if ((Integer) newDetecInfo[DetectInfo.STATE] == 1
|
||||||
&& (Integer) oldDetecInfo[DetectInfo.PLEVEL] == 99) {
|
&& (Integer) oldDetecInfo[DetectInfo.PLEVEL] == 99) {
|
||||||
newDetecInfo[DetectInfo.APPENDWARNINGINFO] = oldDetecInfo;
|
newDetecInfo[DetectInfo.APPENDWARNINGINFO] = oldDetecInfo;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
} else {// 大于两条数据时,排序之后判断数据库的数据是否为最接近的时间数据
|
} else {// 大于两条数据时,排序之后判断数据库的数据是否为最接近的时间数据
|
||||||
// 未入库的数据排序
|
// 未入库的数据排序
|
||||||
@@ -790,6 +833,7 @@ public class DetectInfoInsertThread implements Runnable {
|
|||||||
if (checkType.equalsIgnoreCase(Constants.DETEC_NMSC_STR)) {
|
if (checkType.equalsIgnoreCase(Constants.DETEC_NMSC_STR)) {
|
||||||
newDetecInfo[DetectInfo.STATUSCHANGTIME] = (checkTime);
|
newDetecInfo[DetectInfo.STATUSCHANGTIME] = (checkTime);
|
||||||
}
|
}
|
||||||
|
newDetecInfo[DetectInfo.WARN_2_OK] = 1;//告警恢复正常
|
||||||
// //update warning table
|
// //update warning table
|
||||||
// collectWarnUpdateInfo(newDetecInfo);
|
// collectWarnUpdateInfo(newDetecInfo);
|
||||||
}
|
}
|
||||||
@@ -881,7 +925,9 @@ public class DetectInfoInsertThread implements Runnable {
|
|||||||
*/
|
*/
|
||||||
private void addRecordToStatement(PreparedStatement stmt, Object[] params) throws SQLException {
|
private void addRecordToStatement(PreparedStatement stmt, Object[] params) throws SQLException {
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
logger.debug(" params " + Arrays.toString(params));
|
if(Constants.DEBUG_DETECTINFOINSERTTHREAD_ADDRECORDTOSTATEMENT) {
|
||||||
|
logger.debug(" params " + Arrays.toString(params));
|
||||||
|
}
|
||||||
for (int i = 0; i < params.length; i++) {
|
for (int i = 0; i < params.length; i++) {
|
||||||
stmt.setObject(i + 1, params[i]);
|
stmt.setObject(i + 1, params[i]);
|
||||||
}
|
}
|
||||||
@@ -899,15 +945,14 @@ public class DetectInfoInsertThread implements Runnable {
|
|||||||
if((Long)newDeteInfo[DetectInfo.CHECKTIME]>(Long)oldDetecInfo[DetectInfo.CHECKTIME]){
|
if((Long)newDeteInfo[DetectInfo.CHECKTIME]>(Long)oldDetecInfo[DetectInfo.CHECKTIME]){
|
||||||
newDataList.add(newDeteInfo);
|
newDataList.add(newDeteInfo);
|
||||||
}
|
}
|
||||||
if((Integer)newDeteInfo[DetectInfo.STATE]==1){
|
/*if((Integer)newDeteInfo[DetectInfo.STATE]==1 && (Integer)oldDetecInfo[DetectInfo.STATE] != 1){//状态恢复正常
|
||||||
Object[] params={newDeteInfo[DetectInfo.SEQID],newDeteInfo[DetectInfo.SETINFOID]};
|
Object[] params={newDeteInfo[DetectInfo.SEQID],newDeteInfo[DetectInfo.SETINFOID]};
|
||||||
try {
|
try {
|
||||||
addRecordToStatement(warnUpdateStmt, params);
|
addRecordToStatement(warnUpdateStmt, params);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveToNew(List<Object[]> dataList,int flag){
|
private void saveToNew(List<Object[]> dataList,int flag){
|
||||||
@@ -983,18 +1028,13 @@ public class DetectInfoInsertThread implements Runnable {
|
|||||||
infoNewUpdateStmt.executeBatch();
|
infoNewUpdateStmt.executeBatch();
|
||||||
logger.info("info_new table update success! size : "+ dataList.size());
|
logger.info("info_new table update success! size : "+ dataList.size());
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
logger.error("update info to info_new table error"+e.getMessage());
|
logger.error("update info to info_new table error",e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dataList.clear();
|
dataList.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void collectWarnUpdateInfo(Object[] newDetectInfo){
|
|
||||||
Object[] params={newDetectInfo[DetectInfo.SEQID],newDetectInfo[DetectInfo.SETINFOID]};
|
|
||||||
try {
|
|
||||||
addRecordToStatement(warnUpdateStmt, params);
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class FileUploadManagerThread implements Runnable{
|
|||||||
dao = new CommonDao();
|
dao = new CommonDao();
|
||||||
service = new UpgradeService(dao);
|
service = new UpgradeService(dao);
|
||||||
}
|
}
|
||||||
hostIp = service.getHostIpByMissionId(mid);
|
hostIp = Constants.FILE_DOWNLOAD_FROM_COMMUNICATE_WEB ? Constants.WEB_SOCKET_IP : service.getHostIpByMissionId(mid);
|
||||||
Common.addMissionIdWebIPMap(mid,hostIp);
|
Common.addMissionIdWebIPMap(mid,hostIp);
|
||||||
}
|
}
|
||||||
}catch (NumberFormatException e) {
|
}catch (NumberFormatException e) {
|
||||||
|
|||||||
@@ -142,7 +142,11 @@ public class LoadNewMissionThread implements Runnable{
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String hostIp = service.getHostIpBySystemId(mission.getSystemId());
|
/*
|
||||||
|
* 任务 文件 下载 ip 获取方式,true:配置文件中的 web.socket.ip;false:system_table表中的 server_ip
|
||||||
|
* 默认 :true
|
||||||
|
*/
|
||||||
|
String hostIp = Constants.FILE_DOWNLOAD_FROM_COMMUNICATE_WEB ? Constants.WEB_SOCKET_IP : service.getHostIpBySystemId(mission.getSystemId());
|
||||||
Integer port = Constants.WEB_SOCKET_PORT;
|
Integer port = Constants.WEB_SOCKET_PORT;
|
||||||
if(missionFileList != null && missionFileList.size()>0){
|
if(missionFileList != null && missionFileList.size()>0){
|
||||||
// ServerTable serverTable = Common.getServerTable();
|
// ServerTable serverTable = Common.getServerTable();
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ public class MonitorManagerThread implements Runnable{
|
|||||||
//NMSC
|
//NMSC
|
||||||
Common.runMonitorRunnable(new SystemDateThread(name,model.getNodeIp(),socketPort,setInfo,startTime));
|
Common.runMonitorRunnable(new SystemDateThread(name,model.getNodeIp(),socketPort,setInfo,startTime));
|
||||||
}else{ //非服务器节点
|
}else{ //非服务器节点
|
||||||
logger.info("监测目标:"+model.getNodeIp()+" 是非服务器节点,不进行"+Constants.DETEC_SYSTEMDATE_STR+"监测");
|
logger.debug("监测目标:"+model.getNodeIp()+" 是非服务器节点,不进行"+Constants.DETEC_SYSTEMDATE_STR+"监测");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ public class MonitorManagerThread implements Runnable{
|
|||||||
//交换机类型节点监测 SNMP校验监测
|
//交换机类型节点监测 SNMP校验监测
|
||||||
Common.runMonitorRunnable(new SwitchPortThread(name,model.getNodeIp(),setInfo,startTime));
|
Common.runMonitorRunnable(new SwitchPortThread(name,model.getNodeIp(),setInfo,startTime));
|
||||||
}else{ //计算机类型校验
|
}else{ //计算机类型校验
|
||||||
logger.info("监测目标:"+model.getNodeIp()+" 不是交换机,无法进行监测");
|
logger.debug("监测目标:"+model.getNodeIp()+" 不是交换机,无法进行监测");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,7 +162,7 @@ public class MonitorManagerThread implements Runnable{
|
|||||||
if(model.getNodeType() != null && model.getNodeType().longValue() != 0l){ //非服务器节点
|
if(model.getNodeType() != null && model.getNodeType().longValue() != 0l){ //非服务器节点
|
||||||
Common.runMonitorRunnable(new SNMP4JThread(name,model.getNodeIp(),setInfo,startTime));
|
Common.runMonitorRunnable(new SNMP4JThread(name,model.getNodeIp(),setInfo,startTime));
|
||||||
}else{ //计算机类型校验
|
}else{ //计算机类型校验
|
||||||
logger.info("监测目标:"+model.getNodeIp()+" 是服务器节点,不进行该类监测");
|
logger.debug("监测目标:"+model.getNodeIp()+" 是服务器节点,不进行该类监测");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,14 +119,11 @@ public class SNMP4JThread implements Runnable{
|
|||||||
nextTime.add(Calendar.MINUTE, info.getCheckGap().intValue());
|
nextTime.add(Calendar.MINUTE, info.getCheckGap().intValue());
|
||||||
pubDatas.add(nextTime.getTimeInMillis() + "");// 下次计划监测时间,
|
pubDatas.add(nextTime.getTimeInMillis() + "");// 下次计划监测时间,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//- DetecDatas 拼写 Body
|
//- DetecDatas 拼写 Body
|
||||||
List<List<String>> pubDatasList = new ArrayList<List<String>>();
|
List<List<String>> pubDatasList = new ArrayList<List<String>>();
|
||||||
if(state != -1){
|
if(state != -1){
|
||||||
pubDatasList = datasBody(retries,stateInfo.toString(),state,snmpDatasList);
|
pubDatasList = snmpDatasList;//datasBody(retries,stateInfo.toString(),state,snmpDatasList);
|
||||||
}
|
}
|
||||||
|
|
||||||
pubDatas.add(state+""); // 执行状态
|
pubDatas.add(state+""); // 执行状态
|
||||||
pubDatas.add(stateInfo.toString()); // 状态信息(描述信息),
|
pubDatas.add(stateInfo.toString()); // 状态信息(描述信息),
|
||||||
pubDatas.add(""); // 性能数据,
|
pubDatas.add(""); // 性能数据,
|
||||||
@@ -139,6 +136,7 @@ public class SNMP4JThread implements Runnable{
|
|||||||
//- 存入缓存
|
//- 存入缓存
|
||||||
if(pubDatasList!=null && pubDatasList.size()>0){
|
if(pubDatasList!=null && pubDatasList.size()>0){
|
||||||
try {
|
try {
|
||||||
|
Common.alarmJudgement(pubDatasList);//告警判断
|
||||||
Common.addDeteData(CSVUtils.csvFilePrinter(pubDatasList, Constants.COMMON_TEXT_CODING));
|
Common.addDeteData(CSVUtils.csvFilePrinter(pubDatasList, Constants.COMMON_TEXT_CODING));
|
||||||
logger.debug("监测数据以 CSV格式 保存完成");
|
logger.debug("监测数据以 CSV格式 保存完成");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ import java.util.concurrent.CountDownLatch;
|
|||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
import org.nutz.json.Json;
|
||||||
|
import org.nutz.json.JsonFormat;
|
||||||
import org.snmp4j.mp.SnmpConstants;
|
import org.snmp4j.mp.SnmpConstants;
|
||||||
|
|
||||||
import com.nms.server.bean.SetInfo;
|
import com.nms.server.bean.SetInfo;
|
||||||
@@ -518,8 +520,8 @@ public class SwitchPortThread implements Runnable{
|
|||||||
//- DetecDatas 拼写 Body
|
//- DetecDatas 拼写 Body
|
||||||
List<List<String>> pubDatasList = new ArrayList<List<String>>();
|
List<List<String>> pubDatasList = new ArrayList<List<String>>();
|
||||||
if(state != -1){//执行成功了
|
if(state != -1){//执行成功了
|
||||||
pubDatasList = datasBody(retries,stateInfo.toString(),state,snmpDatasList2);
|
pubDatasList =snmpDatasList2;//
|
||||||
|
//datasBody(retries,stateInfo.toString(),state,snmpDatasList2);
|
||||||
//64位获取失败告警
|
//64位获取失败告警
|
||||||
if(!dataFlag64){
|
if(!dataFlag64){
|
||||||
state=0;
|
state=0;
|
||||||
@@ -539,6 +541,8 @@ public class SwitchPortThread implements Runnable{
|
|||||||
//- 存入缓存
|
//- 存入缓存
|
||||||
if(pubDatasList!=null && pubDatasList.size()>0){
|
if(pubDatasList!=null && pubDatasList.size()>0){
|
||||||
try {
|
try {
|
||||||
|
logger.debug("switchDetection : " + Json.toJson(pubDatasList,JsonFormat.tidy()));
|
||||||
|
Common.alarmJudgement(pubDatasList);//告警判断
|
||||||
//添加监测数据到缓存,等待监测数据解析线程的解析入库
|
//添加监测数据到缓存,等待监测数据解析线程的解析入库
|
||||||
Common.addDeteData(CSVUtils.csvFilePrinter(pubDatasList, Constants.COMMON_TEXT_CODING));
|
Common.addDeteData(CSVUtils.csvFilePrinter(pubDatasList, Constants.COMMON_TEXT_CODING));
|
||||||
logger.debug("监测数据以 CSV格式 保存完成");
|
logger.debug("监测数据以 CSV格式 保存完成");
|
||||||
@@ -949,22 +953,13 @@ public class SwitchPortThread implements Runnable{
|
|||||||
|
|
||||||
//拼写监测信息的详细信息:对于switchport,就是每个端口的监测信息
|
//拼写监测信息的详细信息:对于switchport,就是每个端口的监测信息
|
||||||
private List<List<String>> datasBody(int times,String stateInfo,int state,List<List<String>> snmpDatas2)throws Exception{
|
private List<List<String>> datasBody(int times,String stateInfo,int state,List<List<String>> snmpDatas2)throws Exception{
|
||||||
|
|
||||||
// List<List<String>> pubDatasList = new LinkedList<List<String>>();
|
|
||||||
|
|
||||||
logger.debug("监测数据主体拼写 state "+state+" size"+(snmpDatas2==null ? -1 :snmpDatas2.size()));
|
logger.debug("监测数据主体拼写 state "+state+" size"+(snmpDatas2==null ? -1 :snmpDatas2.size()));
|
||||||
|
|
||||||
if(snmpDatas2!=null && snmpDatas2.size()!=0){
|
if(snmpDatas2!=null && snmpDatas2.size()!=0){
|
||||||
for (List<String> snmpDatas : snmpDatas2) {
|
for (List<String> snmpDatas : snmpDatas2) {
|
||||||
// List<String> pubDatas0 = new LinkedList<String>();
|
|
||||||
// 执行状态是否成功是否正常, 第三方脚本监测任务执行结果(用于报警 -1执行失败 0不正常,1正常)-1时可保留后续数据为空,但是数据个数需要对应
|
|
||||||
// -- 执行状态是否成功,记录的状态是否正常(用于报警),
|
// -- 执行状态是否成功,记录的状态是否正常(用于报警),
|
||||||
String [] datas0 = new String[0];
|
String [] datas0 = new String[0];
|
||||||
datas0 = snmpDatas.toArray(datas0);
|
datas0 = snmpDatas.toArray(datas0);
|
||||||
// logger.debug("snmpDatas>>>> "+Arrays.toString(snmpDatas.toArray(datas0)));
|
|
||||||
// logger.debug("Common.getAlarmInfoMap()>>>> "+Common.getAlarmInfoMap().size());
|
|
||||||
String[] pArray = Common.getAlarmState(Common.getAlarmInfoMap().get(info.getId()+""), datas0);
|
String[] pArray = Common.getAlarmState(Common.getAlarmInfoMap().get(info.getId()+""), datas0);
|
||||||
// logger.debug("pArray>>>> "+Arrays.toString(pArray));
|
|
||||||
if (pArray == null || pArray.length==0) {//无告警信息
|
if (pArray == null || pArray.length==0) {//无告警信息
|
||||||
snmpDatas.add(0, "");//插入后,列表之后的信息顺序往后移
|
snmpDatas.add(0, "");//插入后,列表之后的信息顺序往后移
|
||||||
snmpDatas.add(1, "");
|
snmpDatas.add(1, "");
|
||||||
@@ -975,13 +970,19 @@ public class SwitchPortThread implements Runnable{
|
|||||||
snmpDatas.add(1, pArray == null ? "" : pArray[1]);
|
snmpDatas.add(1, pArray == null ? "" : pArray[1]);
|
||||||
snmpDatas.add(2, pArray == null ? "" : pArray[2]);
|
snmpDatas.add(2, pArray == null ? "" : pArray[2]);
|
||||||
stateInfo+=Common.getStateInfo(info.getCheckTypeName(),Common.getAlarmInfoMap().get(info.getId()+""), datas0);
|
stateInfo+=Common.getStateInfo(info.getCheckTypeName(),Common.getAlarmInfoMap().get(info.getId()+""), datas0);
|
||||||
|
logger.debug("swtich stateInfo : " + stateInfo);
|
||||||
}
|
}
|
||||||
// logger.debug("pArray>>>> "+Arrays.toString(pubDatas0.toArray()));
|
if(logger.isDebugEnabled()) {
|
||||||
}
|
logger.debug(String.format("snmpData : %s , stateInfo : %s ", Json.toJson(snmpDatas,JsonFormat.tidy()),Json.toJson(stateInfo,JsonFormat.tidy())));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return snmpDatas2;
|
return snmpDatas2;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
class Switch{
|
class Switch{
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.nms.server.common.Constants;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
@@ -101,14 +103,18 @@ public class MessageDecoder extends ByteToMessageDecoder {
|
|||||||
if(m != null){
|
if(m != null){
|
||||||
out.add(m);
|
out.add(m);
|
||||||
init();
|
init();
|
||||||
logger.debug("成功组包一条消息:type : " +m.getBusinessType().getName() +",length : " + m.getLength());
|
if(Constants.DEBUG_MESSAGEDECODER_DECODE) {
|
||||||
|
logger.debug("成功组包一条消息:type : " +m.getBusinessType().getName() +",length : " + m.getLength());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Message decode(ByteBuf in) throws Exception{
|
private Message decode(ByteBuf in) throws Exception{
|
||||||
int readableBytes = in.readableBytes();
|
int readableBytes = in.readableBytes();
|
||||||
logger.debug("decode begin,flag:"+flag+ " ,readableBytes:" + readableBytes);
|
if(Constants.DEBUG_MESSAGEDECODER_DECODE) {
|
||||||
|
logger.debug("decode begin,flag:"+flag+ " ,readableBytes:" + readableBytes);
|
||||||
|
}
|
||||||
if(flag && readableBytes < (headerLength)){//初始状态,且不能读取 协议头
|
if(flag && readableBytes < (headerLength)){//初始状态,且不能读取 协议头
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -181,7 +187,9 @@ public class MessageDecoder extends ByteToMessageDecoder {
|
|||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
logger.debug("decode end,type : "+businessType.getName()+" bodyLength: "+bodyLength+" , remain :" +remain);
|
if(Constants.DEBUG_MESSAGEDECODER_DECODE) {
|
||||||
|
logger.debug("decode end,type : "+businessType.getName()+" bodyLength: "+bodyLength+" , remain :" +remain);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class NMSWebBPDownload extends SocketUtils implements Callable<Object>{
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
logger.warn("Target communication:>"+ip+" create failure",e);
|
logger.warn("Target communication:>"+ip+":"+port+" create failure",e);
|
||||||
close();
|
close();
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
|
|||||||
@@ -66,19 +66,23 @@ public class SSLServerManager implements Callable<Object>{
|
|||||||
Thread.currentThread().setName("Receiving communication");
|
Thread.currentThread().setName("Receiving communication");
|
||||||
try {
|
try {
|
||||||
while (true) {
|
while (true) {
|
||||||
|
Common.acquireServerSemaphore();//阻塞 获取 server 信号量
|
||||||
Socket socket = sslServer.accept();
|
Socket socket = sslServer.accept();
|
||||||
|
String address = socket.getInetAddress().getHostAddress();
|
||||||
|
logger.debug(String.format("client addr :%s", address));
|
||||||
if(Common.SERVER_UN_UPGRADE_FLAG){ //当SOCKET_FLAG为true时,允许建立通讯,否则放弃通讯,用于NMSServer升级功能
|
if(Common.SERVER_UN_UPGRADE_FLAG){ //当SOCKET_FLAG为true时,允许建立通讯,否则放弃通讯,用于NMSServer升级功能
|
||||||
logger.debug("来自:"+socket.getInetAddress().getHostAddress());
|
|
||||||
Common.service.submit(new SSLServer(socket));
|
Common.service.submit(new SSLServer(socket));
|
||||||
}else{ //关闭 放弃的通讯
|
}else{ //关闭 放弃的通讯
|
||||||
logger.debug("Server升级 抛弃通讯:"+socket.getInetAddress().getHostAddress());
|
logger.debug(String.format("Server升级 抛弃通讯:%s", address));
|
||||||
|
Common.releaseServerSemaphore();
|
||||||
socket.close();
|
socket.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("Local communication port monitor thread exception termination"+e.getMessage());
|
logger.error("Local communication port monitor thread exception termination"+e.getMessage());
|
||||||
Common.addErrorInfo(Constants.ERROR_CODE_SOCKET_SERVER_RUNTIME,Common.getLocalIp(), Calendar.getInstance().getTime(), Constants.ERROR_INFO_SATAE_ERROR,"");
|
Common.addErrorInfo(Constants.ERROR_CODE_SOCKET_SERVER_RUNTIME,Common.getLocalIp(), Calendar.getInstance().getTime(), Constants.ERROR_INFO_SATAE_ERROR,"");
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
logger.error("socket server error",e);
|
||||||
}finally{
|
}finally{
|
||||||
try {
|
try {
|
||||||
sslServer.close();
|
sslServer.close();
|
||||||
|
|||||||
@@ -935,7 +935,7 @@ public class ConnectionOracle {
|
|||||||
fields.add(idName);
|
fields.add(idName);
|
||||||
fields.add(pidName);
|
fields.add(pidName);
|
||||||
Set<String> temp = new HashSet<String>();
|
Set<String> temp = new HashSet<String>();
|
||||||
ArrayList<Map<String,String>> list = this.dbSelect(sql, fields);
|
ArrayList<Map<String,String>> list = this.dbSelect(sb.toString(), fields);
|
||||||
if(list != null){
|
if(list != null){
|
||||||
for(Map<String,String> map : list){
|
for(Map<String,String> map : list){
|
||||||
String id = map.get(idName);
|
String id = map.get(idName);
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public class DruidPool {
|
|||||||
ds.setPassword(Constants.DB_PASSWORD);
|
ds.setPassword(Constants.DB_PASSWORD);
|
||||||
ds.configFromPropety(properties);
|
ds.configFromPropety(properties);
|
||||||
ds.setName("Druid连接池");
|
ds.setName("Druid连接池");
|
||||||
|
ds.setMaxWait(Constants.DRUID_MAXWAIT_MILLIS);//最大等待时间
|
||||||
ds.init();
|
ds.init();
|
||||||
logger.debug("Druid初始化连接池成功,"+ds.toString());
|
logger.debug("Druid初始化连接池成功,"+ds.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -398,11 +398,11 @@ public class SNMP4JUtils {
|
|||||||
for (int j = 0; j < list.size(); j++) {
|
for (int j = 0; j < list.size(); j++) {
|
||||||
TreeEvent treeEvent = (TreeEvent)list.get(j);
|
TreeEvent treeEvent = (TreeEvent)list.get(j);
|
||||||
if (treeEvent.isError())
|
if (treeEvent.isError())
|
||||||
throw new Exception((new StringBuilder("i18n_server.SNMP4JUtils.Exception3_n81i:")).append(treeEvent.getErrorMessage()).toString());
|
throw new Exception((new StringBuilder("Error getting SNMP table:")).append(treeEvent.getErrorMessage()).toString());
|
||||||
if (treeEvent.getException() != null)
|
if (treeEvent.getException() != null)
|
||||||
throw new Exception((new StringBuilder("i18n_server.SNMP4JUtils.Exception4_n81i:")).append(treeEvent.getErrorMessage()).append(" ").append(treeEvent.getException().getMessage()).toString());
|
throw new Exception((new StringBuilder("Get an exception in SNMP table:")).append(treeEvent.getErrorMessage()).append(" ").append(treeEvent.getException().getMessage()).toString());
|
||||||
if (treeEvent.getStatus() != 0)
|
if (treeEvent.getStatus() != 0)
|
||||||
throw new Exception((new StringBuilder("i18n_server.SNMP4JUtils.Exception3_n81i:")).append(treeEvent.getErrorMessage()).toString());
|
throw new Exception((new StringBuilder("Error getting SNMP table:")).append(treeEvent.getErrorMessage()).toString());
|
||||||
if (treeEvent.getVariableBindings() != null ){
|
if (treeEvent.getVariableBindings() != null ){
|
||||||
VariableBinding vbArr[] = treeEvent.getVariableBindings();
|
VariableBinding vbArr[] = treeEvent.getVariableBindings();
|
||||||
if(vbArr != null){
|
if(vbArr != null){
|
||||||
@@ -411,7 +411,15 @@ public class SNMP4JUtils {
|
|||||||
OID oid = vb.getOid();
|
OID oid = vb.getOid();
|
||||||
String index = oid.last()+"";//索引
|
String index = oid.last()+"";//索引
|
||||||
String oidStr = oid.toString();
|
String oidStr = oid.toString();
|
||||||
|
if (rootOid.startsWith("1.3.6.1.4.1.5000000.1.4.1.1")) {
|
||||||
|
logger.debug("对5000000.1.4.1.1进行特殊处理");
|
||||||
|
String[] p = oidStr.substring(rootOid.length()).split("[.]");
|
||||||
|
if (p.length == 4) {
|
||||||
|
oidStr = rootOid + "." + p[1]+"."+p[3];
|
||||||
|
}
|
||||||
|
}
|
||||||
oidStr = oidStr.substring(0, oidStr.lastIndexOf("."));
|
oidStr = oidStr.substring(0, oidStr.lastIndexOf("."));
|
||||||
|
System.out.println(oid.toString() + " --> " + oidStr);
|
||||||
if(oidModel.contains(oidStr)){
|
if(oidModel.contains(oidStr)){
|
||||||
Map<String, String> map = mapInstance.get(index);
|
Map<String, String> map = mapInstance.get(index);
|
||||||
if(map == null){
|
if(map == null){
|
||||||
@@ -457,11 +465,11 @@ public class SNMP4JUtils {
|
|||||||
for (int j = 0; j < list.size(); j++) {
|
for (int j = 0; j < list.size(); j++) {
|
||||||
TreeEvent treeEvent = (TreeEvent)list.get(j);
|
TreeEvent treeEvent = (TreeEvent)list.get(j);
|
||||||
if (treeEvent.isError())
|
if (treeEvent.isError())
|
||||||
throw new Exception((new StringBuilder("i18n_server.SNMP4JUtils.Exception3_n81i:")).append(treeEvent.getErrorMessage()).toString());
|
throw new Exception((new StringBuilder("Error getting SNMP table:")).append(treeEvent.getErrorMessage()).toString());
|
||||||
if (treeEvent.getException() != null)
|
if (treeEvent.getException() != null)
|
||||||
throw new Exception((new StringBuilder("i18n_server.SNMP4JUtils.Exception4_n81i:")).append(treeEvent.getErrorMessage()).append(" ").append(treeEvent.getException().getMessage()).toString());
|
throw new Exception((new StringBuilder("Get an exception in SNMP table:")).append(treeEvent.getErrorMessage()).append(" ").append(treeEvent.getException().getMessage()).toString());
|
||||||
if (treeEvent.getStatus() != 0)
|
if (treeEvent.getStatus() != 0)
|
||||||
throw new Exception((new StringBuilder("i18n_server.SNMP4JUtils.Exception3_n81i:")).append(treeEvent.getErrorMessage()).toString());
|
throw new Exception((new StringBuilder("Error getting SNMP table:")).append(treeEvent.getErrorMessage()).toString());
|
||||||
if (treeEvent.getVariableBindings() != null ){
|
if (treeEvent.getVariableBindings() != null ){
|
||||||
VariableBinding vbArr[] = treeEvent.getVariableBindings();
|
VariableBinding vbArr[] = treeEvent.getVariableBindings();
|
||||||
if(vbArr != null){
|
if(vbArr != null){
|
||||||
@@ -513,7 +521,7 @@ public class SNMP4JUtils {
|
|||||||
oidModel.add("1.3.6.1.2.1.1.6");
|
oidModel.add("1.3.6.1.2.1.1.6");
|
||||||
oidModel.add("1.3.6.1.2.1.1.7");*/
|
oidModel.add("1.3.6.1.2.1.1.7");*/
|
||||||
// [1.3.6.1.2.1.31.1.1.1.1, 1.3.6.1.2.1.31.1.1.1.2, 1.3.6.1.2.1.31.1.1.1.3, 1.3.6.1.2.1.31.1.1.1.4, 1.3.6.1.2.1.31.1.1.1.5, 1.3.6.1.2.1.31.1.1.1.6, 1.3.6.1.2.1.31.1.1.1.7, 1.3.6.1.2.1.31.1.1.1.8, 1.3.6.1.2.1.31.1.1.1.9, 1.3.6.1.2.1.31.1.1.1.10, 1.3.6.1.2.1.31.1.1.1.11, 1.3.6.1.2.1.31.1.1.1.12, 1.3.6.1.2.1.31.1.1.1.13, 1.3.6.1.2.1.31.1.1.1.14, 1.3.6.1.2.1.31.1.1.1.15, 1.3.6.1.2.1.31.1.1.1.17, 1.3.6.1.2.1.31.1.1.1.16, 1.3.6.1.2.1.31.1.1.1.19, 1.3.6.1.2.1.31.1.1.1.18]
|
// [1.3.6.1.2.1.31.1.1.1.1, 1.3.6.1.2.1.31.1.1.1.2, 1.3.6.1.2.1.31.1.1.1.3, 1.3.6.1.2.1.31.1.1.1.4, 1.3.6.1.2.1.31.1.1.1.5, 1.3.6.1.2.1.31.1.1.1.6, 1.3.6.1.2.1.31.1.1.1.7, 1.3.6.1.2.1.31.1.1.1.8, 1.3.6.1.2.1.31.1.1.1.9, 1.3.6.1.2.1.31.1.1.1.10, 1.3.6.1.2.1.31.1.1.1.11, 1.3.6.1.2.1.31.1.1.1.12, 1.3.6.1.2.1.31.1.1.1.13, 1.3.6.1.2.1.31.1.1.1.14, 1.3.6.1.2.1.31.1.1.1.15, 1.3.6.1.2.1.31.1.1.1.17, 1.3.6.1.2.1.31.1.1.1.16, 1.3.6.1.2.1.31.1.1.1.19, 1.3.6.1.2.1.31.1.1.1.18]
|
||||||
oidModel.add("1.3.6.1.4.1.1000.4.3.1.1");
|
/* oidModel.add("1.3.6.1.4.1.1000.4.3.1.1");
|
||||||
oidModel.add("1.3.6.1.4.1.1000.4.3.1.2");
|
oidModel.add("1.3.6.1.4.1.1000.4.3.1.2");
|
||||||
oidModel.add("1.3.6.1.4.1.1000.4.3.1.3");
|
oidModel.add("1.3.6.1.4.1.1000.4.3.1.3");
|
||||||
oidModel.add("1.3.6.1.4.1.1000.4.3.1.4");
|
oidModel.add("1.3.6.1.4.1.1000.4.3.1.4");
|
||||||
@@ -522,10 +530,11 @@ public class SNMP4JUtils {
|
|||||||
oidModel.add("1.3.6.1.4.1.1000.4.3.1.7");
|
oidModel.add("1.3.6.1.4.1.1000.4.3.1.7");
|
||||||
oidModel.add("1.3.6.1.4.1.1000.4.3.1.8");
|
oidModel.add("1.3.6.1.4.1.1000.4.3.1.8");
|
||||||
oidModel.add("1.3.6.1.4.1.1000.4.3.1.9");
|
oidModel.add("1.3.6.1.4.1.1000.4.3.1.9");
|
||||||
oidModel.add("1.3.6.1.4.1.1000.4.3.1.10");
|
oidModel.add("1.3.6.1.4.1.1000.4.3.1.10");*/
|
||||||
|
oidModel.add("1.3.6.1.4.1.5000000.1.4.1.1.3");
|
||||||
//String oid = "1.3.6.1.2.1.1";
|
//String oid = "1.3.6.1.2.1.1";
|
||||||
String oid = "1.3.6.1.4.1.1000.4.3.1";
|
String oid = "1.3.6.1.4.1.5000000.1.4.1.1";
|
||||||
String host = "10.0.6.230";
|
String host = "10.4.2.5";
|
||||||
String port = "161";
|
String port = "161";
|
||||||
String community = "public";
|
String community = "public";
|
||||||
int retries = 3;
|
int retries = 3;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public abstract class SSLSocketCallable extends SocketUtils implements Callable<
|
|||||||
private static Logger logger = Logger.getLogger(SSLSocketCallable.class);
|
private static Logger logger = Logger.getLogger(SSLSocketCallable.class);
|
||||||
//ServerSocket 通讯服务
|
//ServerSocket 通讯服务
|
||||||
protected SSLServerSocket ss = null;
|
protected SSLServerSocket ss = null;
|
||||||
|
private boolean clientFlag = false;// 是否dc server 接收的client
|
||||||
/**
|
/**
|
||||||
* 通讯创建
|
* 通讯创建
|
||||||
* @param ip 目标主机IP
|
* @param ip 目标主机IP
|
||||||
@@ -41,6 +41,7 @@ public abstract class SSLSocketCallable extends SocketUtils implements Callable<
|
|||||||
*/
|
*/
|
||||||
public SSLSocketCallable(Socket client) {
|
public SSLSocketCallable(Socket client) {
|
||||||
super(client);
|
super(client);
|
||||||
|
clientFlag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,39 +52,39 @@ public abstract class SSLSocketCallable extends SocketUtils implements Callable<
|
|||||||
public Object call(){
|
public Object call(){
|
||||||
Thread.currentThread().setName("Create communication"+ip+":"+port);
|
Thread.currentThread().setName("Create communication"+ip+":"+port);
|
||||||
Object obj = null; //返回对象
|
Object obj = null; //返回对象
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
try {
|
||||||
|
//- 校验 是否创建新通讯连接
|
||||||
|
if(socket==null){ //客户端通讯创建
|
||||||
|
createClientSocket();
|
||||||
|
}else{ //服务端通讯创建
|
||||||
|
createServerSocket();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SocketException e) {
|
||||||
|
logger.error("Create failed:"+e.getMessage(),e);
|
||||||
|
Common.addErrorInfo(Constants.ERROR_CODE_CREATE_SOCKET,ip, Calendar.getInstance().getTime(), Constants.ERROR_INFO_SATAE_ERROR,"");
|
||||||
|
close();
|
||||||
|
return obj;
|
||||||
|
} catch (Exception e) {
|
||||||
|
close();
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
//- 校验 是否创建新通讯连接
|
//-- 自定义通讯操作
|
||||||
if(socket==null){ //客户端通讯创建
|
try {
|
||||||
createClientSocket();
|
obj = toDo();
|
||||||
}else{ //服务端通讯创建
|
}catch (Exception e) {
|
||||||
createServerSocket();
|
logger.error("Communicate contents exception"+e.getMessage(),e);
|
||||||
|
Common.addErrorInfo(Constants.ERROR_CODE_SOCKET_RUNTIME,ip, Calendar.getInstance().getTime(), Constants.ERROR_INFO_SATAE_ERROR,"");
|
||||||
|
} finally {
|
||||||
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (SocketException e) {
|
|
||||||
logger.error("Create failed:"+e.getMessage(),e);
|
|
||||||
Common.addErrorInfo(Constants.ERROR_CODE_CREATE_SOCKET,ip, Calendar.getInstance().getTime(), Constants.ERROR_INFO_SATAE_ERROR,"");
|
|
||||||
close();
|
|
||||||
return obj;
|
|
||||||
} catch (IOException e) {
|
|
||||||
close();
|
|
||||||
return obj;
|
|
||||||
}catch (Exception e) {
|
|
||||||
close();
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-- 自定义通讯操作
|
|
||||||
try {
|
|
||||||
obj = toDo();
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("Communicate contents exception"+e.getMessage(),e);
|
|
||||||
Common.addErrorInfo(Constants.ERROR_CODE_SOCKET_RUNTIME,ip, Calendar.getInstance().getTime(), Constants.ERROR_INFO_SATAE_ERROR,"");
|
|
||||||
} finally {
|
} finally {
|
||||||
close();
|
if(clientFlag){
|
||||||
|
Common.releaseServerSemaphore();//释放server信号量
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
##--公共数据存放父目录(*部署需修改*)
|
##--公共数据存放父目录(*部署需修改*)
|
||||||
common.datas.dir = D:/nms/nmsdata
|
common.datas.dir = D:/nms/nmsdata
|
||||||
##--系统SNMP监测,指定服务器IP 指本机(*部署需修改*)
|
##--系统SNMP监测,指定服务器IP 指本机(*部署需修改*)
|
||||||
system.inet.address = 10.0.6.114
|
system.inet.address = 192.168.11.229
|
||||||
##--NMSWeb端 通讯IP 指WEB(*部署需修改*)
|
##--NMSWeb端 通讯IP 指WEB(*部署需修改*)
|
||||||
web.socket.ip = 10.0.6.114
|
web.socket.ip = 10.0.6.114
|
||||||
#--数据库驱动
|
#--数据库驱动
|
||||||
@@ -10,7 +10,7 @@ web.socket.ip = 10.0.6.114
|
|||||||
db.driver=com.mysql.jdbc.Driver
|
db.driver=com.mysql.jdbc.Driver
|
||||||
##--数据库 地址(*部署需修改*)
|
##--数据库 地址(*部署需修改*)
|
||||||
#db.url = jdbc:oracle:thin:@10.0.6.100:1521:ict
|
#db.url = jdbc:oracle:thin:@10.0.6.100:1521:ict
|
||||||
db.url = jdbc:mysql://10.0.6.123:3306/nms?useUnicode=true&characterEncoding=utf-8&useOldAliasMetadataBehavior=true&rewriteBatchedStatements=true
|
db.url = jdbc:mysql://192.168.10.182:3306/nms?useUnicode=true&characterEncoding=utf-8&useOldAliasMetadataBehavior=true&rewriteBatchedStatements=true
|
||||||
##--数据库 用户名(*部署需修改*)
|
##--数据库 用户名(*部署需修改*)
|
||||||
#db.username = nms
|
#db.username = nms
|
||||||
db.username = nms
|
db.username = nms
|
||||||
@@ -48,6 +48,8 @@ email.host =
|
|||||||
web.socket.port = 60703
|
web.socket.port = 60703
|
||||||
|
|
||||||
#---Common-------
|
#---Common-------
|
||||||
|
##--分中心只执行自身范围内client的任务 0 关闭;1 开启;
|
||||||
|
mission.single = 1
|
||||||
##--全局文本解析编码,与web端、Agent端一致,不可修改
|
##--全局文本解析编码,与web端、Agent端一致,不可修改
|
||||||
common.text.coding = UTF-8
|
common.text.coding = UTF-8
|
||||||
##--全局日期格式化方式,须与数据库 日期数据格式化方式(db.date.format)保持一致,不建议修改
|
##--全局日期格式化方式,须与数据库 日期数据格式化方式(db.date.format)保持一致,不建议修改
|
||||||
|
|||||||
Reference in New Issue
Block a user