Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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"?>
|
||||
<classpath>
|
||||
<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="lib" path="lib/commons-beanutils-1.7.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-collections.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-io.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-lang.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/ezmorph-1.0.4.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/junit.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ojdbc14.jar"/>
|
||||
<classpathentry kind="lib" path="lib/mail.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ostermillerutils_1_07_00.jar"/>
|
||||
<classpathentry kind="lib" path="lib/sigar.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ObjectSNMP.jar"/>
|
||||
<classpathentry kind="lib" path="lib/fileComment.jar"/>
|
||||
<classpathentry kind="lib" path="lib/snmp4j-2.0.3.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ant.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/bonecp/bonecp-0.8.0-rc2.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-log4j12-1.6.1.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/jconsole-1.8.0.jar"/>
|
||||
<classpathentry kind="lib" path="lib/druid-1.1.10.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="output" path="bin"/>
|
||||
</classpath>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<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_80"/>
|
||||
<classpathentry kind="lib" path="lib/commons-beanutils-1.7.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-collections.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-io.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-lang.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/ezmorph-1.0.4.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/junit.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ojdbc14.jar"/>
|
||||
<classpathentry kind="lib" path="lib/mail.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ostermillerutils_1_07_00.jar"/>
|
||||
<classpathentry kind="lib" path="lib/sigar.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ObjectSNMP.jar"/>
|
||||
<classpathentry kind="lib" path="lib/fileComment.jar"/>
|
||||
<classpathentry kind="lib" path="lib/snmp4j-2.0.3.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ant.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/bonecp/bonecp-0.8.0-rc2.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-log4j12-1.6.1.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/jconsole-1.8.0.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/netty-all-4.1.28.Final.jar" sourcepath="lib/netty-all-4.1.28.Final-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/nutz-1.r.66.jar"/>
|
||||
<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
|
||||
|
||||
DEFAULT_DATA_DIR="/home/nms/nmsdata"
|
||||
DEFAULT_INSTALL_DIR="/home/nms/datacontroller"
|
||||
DEFAULT_DATA_DIR="/home/ceiec/nms/nmsdata"
|
||||
DEFAULT_INSTALL_DIR="/home/ceiec/nms/datacontroller"
|
||||
|
||||
# --- set install dir
|
||||
PRG="$0"
|
||||
@@ -54,10 +54,10 @@ fi
|
||||
# --- install jdk
|
||||
cd "$INSTALL_DIR"/..
|
||||
NMS_JDK="$(pwd)/nmsjdk"
|
||||
JDK_DIR="$(pwd)/jdk1.7.0_80"
|
||||
JDK_BIN_FILE=$CUR_PRGDIR"/jre_install/jdk-7u80-linux-i586.tar.gz"
|
||||
JDK_DIR="$(pwd)/jre1.7.0_80"
|
||||
JDK_BIN_FILE=$CUR_PRGDIR"/jre_install/jre-7u80-linux-i586.tar.gz"
|
||||
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
|
||||
if [ $install_jdk = 1 ]
|
||||
then
|
||||
@@ -223,7 +223,7 @@ then
|
||||
fi
|
||||
|
||||
#-----------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
|
||||
echo -n "enter database username: "
|
||||
|
||||
@@ -134,7 +134,18 @@ elif [ "$1" = "stop" ]; then
|
||||
echo "$name kill ok !!!!!!!!!!!!!"
|
||||
else
|
||||
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
|
||||
getPid
|
||||
if [ -n "$proc_id" ]
|
||||
|
||||
@@ -3,15 +3,18 @@ package com.nms.server.bean;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.fang.U;
|
||||
import com.nms.server.common.Common;
|
||||
import com.nms.server.common.Config;
|
||||
import com.nms.server.dao.OracleToMysql;
|
||||
|
||||
public class DetectInfo {
|
||||
|
||||
/**
|
||||
* 数组大小
|
||||
*/
|
||||
public static final int DETEC_ARR_SIZE = 34;
|
||||
|
||||
public static final int SEQID = 0; //seqId
|
||||
public static final int SETINFOID = 1; //监测设置ID
|
||||
public static final int CHECKTYPE = 2; //监测类别
|
||||
@@ -55,6 +58,10 @@ public class DetectInfo {
|
||||
public static final int SHOWNUMLIST = 30;
|
||||
public static final int PLEVELLIST = 31;
|
||||
public static final int ALARMLIST = 32;
|
||||
/**
|
||||
* 告警恢复标识
|
||||
*/
|
||||
public static final int WARN_2_OK = 33;
|
||||
|
||||
/**
|
||||
* detect_queue 的 key
|
||||
@@ -314,7 +321,7 @@ public class DetectInfo {
|
||||
*/
|
||||
public static String getInsertWarningSql(){
|
||||
//插入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, " +
|
||||
"POLICE_LEVEL, DATA_CHECK_TIME, DATA_ARRIVE_TIME, DETECTIONED_STATE, " +
|
||||
"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.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@@ -35,6 +36,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.json.JsonFormat;
|
||||
import org.snmp4j.Snmp;
|
||||
|
||||
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.TableColumnsModel;
|
||||
import com.nms.server.bean.TableModel;
|
||||
import com.nms.server.dao.CommonDao;
|
||||
import com.nms.server.thread.alarmData.AlarmDataResoveThread;
|
||||
import com.nms.server.thread.detecData.NewDetecDataResoveThread;
|
||||
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 monitorSemaphore = new Semaphore(Constants.DETEC_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>();
|
||||
@@ -308,6 +316,7 @@ public class Common {
|
||||
logger.debug("缓存中任务并发剩余许可:"+(missionSemaphore.availablePermits()));
|
||||
logger.debug("缓存中监测并发剩余许可:"+(monitorSemaphore.availablePermits()));
|
||||
logger.debug("缓存中变更并发剩余许可:"+(changeSemaphore.availablePermits()));
|
||||
logger.debug("缓存中server并发剩余许可:"+(SERVER_ACCEPT_SEMAPHORE.availablePermits()));
|
||||
|
||||
// logger.debug("基本线程池用量:"+(service.));
|
||||
// logger.debug("定时线程池用量:"+(scheduled));
|
||||
@@ -493,7 +502,9 @@ public class Common {
|
||||
logger.debug("监测数据 添加到 集合2");
|
||||
deteDataList2.add(dsb); }
|
||||
}*/
|
||||
logger.debug(new String(dsb));
|
||||
if(Constants.DEBUG_COMMON_ADDDETEDATA) {
|
||||
logger.debug(new String(dsb));
|
||||
}
|
||||
DETE_DATA_QUEUE.add(dsb);
|
||||
}
|
||||
|
||||
@@ -1016,6 +1027,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 +1540,10 @@ public class Common {
|
||||
//获得当前的报警设置信息,与相应字段值比较
|
||||
public static String[] getAlarmState(List<AlarmInfo> alarmInfos, String[] sysData) throws Exception{
|
||||
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){
|
||||
strs = new String[]{"", "", ""};
|
||||
for(AlarmInfo alarm : alarmInfos){
|
||||
// logger.debug("!!you gaojing o "+alarm.getPoliceValue());
|
||||
if(sysData.length>=alarm.getShowNum()){
|
||||
if(sysData[alarm.getShowNum()-1]==null){
|
||||
logger.error("Monitoring data is empty and can not do alarm verification");
|
||||
@@ -2472,6 +2506,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){
|
||||
|
||||
|
||||
@@ -411,6 +411,8 @@ public class Constants {
|
||||
// public static final Integer TEST_COMPUTER;
|
||||
// public static final Integer TEST_SWITCH;
|
||||
//static final 自变量的初始化
|
||||
//当前业务系统id
|
||||
public static final String MISSION_SINGLE;
|
||||
|
||||
public static final String DB_TYPE;
|
||||
public static final boolean IS_MYSQL;
|
||||
@@ -468,7 +470,33 @@ public class Constants {
|
||||
|
||||
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;
|
||||
|
||||
static {
|
||||
|
||||
@@ -776,6 +804,9 @@ public class Constants {
|
||||
/**
|
||||
* 是否是 mysql 数据库
|
||||
*/
|
||||
|
||||
MISSION_SINGLE = Config.getString("mission.single", "0");
|
||||
|
||||
IS_MYSQL = "mysql".equalsIgnoreCase(DB_TYPE);
|
||||
/**
|
||||
* //dc监测数据入库模式,1:由web 主控控制入库,2:自己主动入库
|
||||
@@ -827,6 +858,32 @@ public class Constants {
|
||||
CURRVAL_FUNCTION_NAME = Config.getString("currval_function_name", "currval");
|
||||
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);
|
||||
}
|
||||
|
||||
//文件传输 临时文件命名后缀
|
||||
|
||||
@@ -1449,7 +1449,8 @@ public class CommonService {
|
||||
" left join mission_parameter_table6 para" +
|
||||
" on para.mission_id=t.mission_id" +
|
||||
" 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" +
|
||||
" from (" +
|
||||
" 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" +
|
||||
/* " 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 " ;
|
||||
}else{
|
||||
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" +
|
||||
" on para.mission_id=t.mission_id" +
|
||||
" 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" +
|
||||
" from (" +
|
||||
" 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" +
|
||||
" on para.mission_id=t.mission_id" +
|
||||
" 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 " ;
|
||||
}
|
||||
|
||||
logger.debug("重新手机任务结果sql(task6AllSql)-->"+task6AllSql);
|
||||
logger.debug("重新手机任务结果sql(task6SucSql)-->"+task6SucSql);
|
||||
return getNonRltIpTaskMap(task6AllSql,task6SucSql);
|
||||
}
|
||||
|
||||
@@ -3701,7 +3706,7 @@ public class CommonService {
|
||||
//-- 获取ID
|
||||
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";
|
||||
fields.add("id");
|
||||
@@ -4077,7 +4082,8 @@ public class CommonService {
|
||||
String ifAdminStatus = detailsArr0[9];//showNum=7,1:up,2:down
|
||||
if("2".equals(ifAdminStatus)) {
|
||||
state = 0;//监测公共信息的状态
|
||||
dsinfo += "$@$端口"+ifDescr+"异常(配置状态与实际状态不符)";
|
||||
// dsinfo += "$@$端口"+ifDescr+"异常(配置状态与实际状态不符)";
|
||||
dsinfo += "i18n_server.CommonService.dsinfo1_n81i"+ifDescr+"i18n_server.CommonService.dsinfo1.exception_n81i";
|
||||
detailDetectionState = "0";//当前端口的状态
|
||||
pLevel = Constants.PORT_ALARM_LEVEL;//非界面设置,默认为5级
|
||||
}
|
||||
@@ -4088,7 +4094,8 @@ public class CommonService {
|
||||
logger.info("test:port:inOctetsSpeed="+inOctetsSpeed+";outOctetsSpeed="+outOctetsSpeed);
|
||||
if((inOctetsSpeed+outOctetsSpeed)<=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";//当前端口的状态
|
||||
pLevel = Constants.PORT_ALARM_LEVEL;//非界面设置,默认为5级
|
||||
}
|
||||
@@ -4151,9 +4158,10 @@ public class CommonService {
|
||||
filedComments = tm==null?"":tm.getFiledComments();
|
||||
}
|
||||
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 += " 报警级别:"+pLevel;
|
||||
// cpInfo += " 报警级别:"+pLevel;
|
||||
cpInfo += " i18n_server.CommonService.policyLevel_n81i:"+pLevel;
|
||||
cpInfo += " \n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.nms.server.bean.LoopMissionRoundInfo;
|
||||
import com.nms.server.bean.MissionResult;
|
||||
import com.nms.server.bean.MissionResult2;
|
||||
import com.nms.server.bean.MissionStateTable;
|
||||
import com.nms.server.bean.ServerIpSegment;
|
||||
import com.nms.server.bean.Task1;
|
||||
import com.nms.server.bean.Task4;
|
||||
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 非周期任务
|
||||
if (missionId!=null && missionId.longValue() !=0l) {
|
||||
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 ");
|
||||
ArrayList<String> fields = new ArrayList<String>();
|
||||
fields.add("mission_id");
|
||||
@@ -90,19 +91,106 @@ public class UpgradeService extends CommonService{
|
||||
try {
|
||||
rs = dao.dbSelect(searchSQL.toString(), fields);
|
||||
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){
|
||||
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);
|
||||
//是否加载任务
|
||||
boolean flag = false;
|
||||
//第一步,判断是否过滤dc范围外节点
|
||||
if (missionSingle) {
|
||||
logger.info("当前dc的server_id:" + serverId);
|
||||
|
||||
//第二步,获取每个任务下发的所有节点,判断是否在dc范围内,若一个在范围内的都没有就把任务状态改为失败
|
||||
//----查询任务下发的节点组ids/节点ids
|
||||
String messionType = maps.get("mission_type");
|
||||
StringBuffer mnSql = new StringBuffer();
|
||||
mnSql.append("SELECT mpt.node_ips_id, mpt.node_groups_id ");
|
||||
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;
|
||||
@@ -237,7 +325,12 @@ public class UpgradeService extends CommonService{
|
||||
searchSql.append("and t.is_loop =0 "); //非周期任务
|
||||
// searchSql.append("and mpt4.node_group_id in( "+groupsIdsSQL+") ");
|
||||
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("order by t.create_time asc ");
|
||||
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.mission_id in( "+missionSql4+") ");
|
||||
// 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("order by t.create_time asc ");
|
||||
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.mission_id in( "+missionSql6+") ");
|
||||
// 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("order by t.create_time asc ");
|
||||
mapsList = dao.dbSelect(searchSql.toString(), fields);
|
||||
@@ -751,8 +854,19 @@ public class UpgradeService extends CommonService{
|
||||
}
|
||||
|
||||
//查询任务下发节点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>();
|
||||
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("end_ipn");
|
||||
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){
|
||||
omNode:for(Map<String, String> map : omNodeMapList){
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -876,8 +990,19 @@ public class UpgradeService extends CommonService{
|
||||
}
|
||||
|
||||
//查询任务下发节点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>();
|
||||
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("end_ipn");
|
||||
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){
|
||||
omNode:for(Map<String, String> map : omNodeMapList){
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,11 +138,9 @@ public class ChangePluginScriptFile implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (String ip : ncNodesIpStrSet) {
|
||||
Common.runChangeRunnable(new SendPluginScriptFile(ip, sendRecordList.get(ip)));
|
||||
}
|
||||
|
||||
// 延时清理脚本
|
||||
new Thread(new DeletePluginScriptDirAfterSending()).start();
|
||||
|
||||
@@ -348,6 +346,11 @@ public class ChangePluginScriptFile implements Runnable {
|
||||
|
||||
} catch (SQLException 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())+"";
|
||||
changeService.saveEventRecordLibrary(SEND_PLUGIN_SCRIPT_FILE, ips,
|
||||
"S2C", JSONObject.fromObject(recordContent).toString());
|
||||
|
||||
task.new DeletePluginScriptDirAfterSending().run();
|
||||
} catch (SQLException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
} finally {
|
||||
@@ -514,6 +517,7 @@ public class ChangePluginScriptFile implements Runnable {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
logger.debug("删除临时目录" + pluginScriptDir.getAbsolutePath());
|
||||
FileUtils.deleteAllFiles(pluginScriptDir, true);
|
||||
}
|
||||
}
|
||||
@@ -528,6 +532,7 @@ public class ChangePluginScriptFile implements Runnable {
|
||||
File tempPluginDir = new File(Constants.PLUGIN_SCRIPT_FILE_DIR, System.currentTimeMillis()+"");
|
||||
if (!tempPluginDir.exists()) {
|
||||
tempPluginDir.mkdirs();
|
||||
logger.debug("创建临时目录" + tempPluginDir.getAbsolutePath());
|
||||
}
|
||||
return tempPluginDir;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.Queue;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.alibaba.druid.support.json.JSONUtils;
|
||||
import com.fang.lang.Db;
|
||||
import com.nms.server.bean.AlarmInfo;
|
||||
import com.nms.server.bean.DetectInfo;
|
||||
@@ -38,7 +39,7 @@ import com.nms.server.util.StringUtil;
|
||||
*/
|
||||
public class DataResolveThread implements Runnable{
|
||||
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();
|
||||
|
||||
|
||||
@@ -396,7 +397,7 @@ public class DataResolveThread implements Runnable{
|
||||
delyFlag = false;
|
||||
}
|
||||
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.SEQID] = (seqId);
|
||||
detectInfo[DetectInfo.SETINFOID] = (setInfoId);
|
||||
@@ -846,6 +847,7 @@ public class DataResolveThread implements Runnable{
|
||||
//--基本信息解析 存在异常值 无须保存,返回错误信息 用于系统告警
|
||||
if(errorInfo.length() != 0){
|
||||
logger.error(" 第一步-1: 新格式监测数据解析异常: seqId:"+seqId+",setInfoId:"+setInfoId+",checkType:"+checkType+" checkTime:"+new Date(checkTime)+" 监测数据解析异常:"+errorInfo);
|
||||
logger.error("错误数据内容如下 : "+JSONUtils.toJSONString(strsList));
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -857,7 +859,7 @@ public class DataResolveThread implements Runnable{
|
||||
|
||||
//公共信息集合
|
||||
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.SEQID] = (seqId);
|
||||
detectInfo[DetectInfo.SETINFOID] = (setInfoId);
|
||||
@@ -955,28 +957,32 @@ public class DataResolveThread implements Runnable{
|
||||
}
|
||||
try {
|
||||
String fileType = field.getFiledType().toUpperCase();
|
||||
String col = detailsArr0[index];
|
||||
if("DATE".equals(fileType)){
|
||||
if(StringUtils.isNumeric(detailsArr0[index])){//如果为数字型时间,转换
|
||||
detail.put(field.getFiledName(), format.format(new Date(Long.parseLong(detailsArr0[index].trim()))));
|
||||
if(StringUtils.isBlank(col)){
|
||||
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
|
||||
detail.put(field.getFiledName(), detailsArr0[index].trim());
|
||||
detail.put(field.getFiledName(), col.trim());
|
||||
}
|
||||
}else{
|
||||
if("NUMBER".equals(fileType)){
|
||||
if (StringUtils.isBlank(detailsArr0[index])
|
||||
|| StringUtil.isRationalNumber(detailsArr0[index])) {
|
||||
detail.put(field.getFiledName(), detailsArr0[index].trim());
|
||||
} else if (detailsArr0[index].trim().contains(" days, ")) {
|
||||
detail.put(field.getFiledName(), CommonService.getLongTimeStr(detailsArr0[index].trim()));
|
||||
if(StringUtils.isBlank(col)){
|
||||
detail.put(field.getFiledName(), null);
|
||||
} else if (StringUtil.isRationalNumber(col)) {
|
||||
detail.put(field.getFiledName(), col.trim());
|
||||
} else if (col.trim().contains(" days, ")) {
|
||||
detail.put(field.getFiledName(), CommonService.getLongTimeStr(col.trim()));
|
||||
} else {
|
||||
throw new Exception("NUMBER数据格式错误!");
|
||||
}
|
||||
}else{ // VARCHAR2(x)
|
||||
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数据格式错误!");
|
||||
}
|
||||
detail.put(field.getFiledName(), detailsArr0[index].trim());
|
||||
detail.put(field.getFiledName(), col.trim());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -988,7 +994,7 @@ public class DataResolveThread implements Runnable{
|
||||
}
|
||||
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;
|
||||
}
|
||||
index++;
|
||||
@@ -1015,18 +1021,20 @@ public class DataResolveThread implements Runnable{
|
||||
String ifAdminStatus = detailsArr0[9];//showNum=7,1:up,2:down
|
||||
if("2".equals(ifAdminStatus)) {
|
||||
state = 0;//监测公共信息的状态
|
||||
dsinfo += "$@$端口"+ifDescr+"异常(配置状态与实际状态不符)";
|
||||
// dsinfo += "$@$端口"+ifDescr+"异常(配置状态与实际状态不符)";
|
||||
dsinfo += "i18n_server.CommonService.dsinfo1_n81i"+ifDescr+"i18n_server.CommonService.dsinfo1.exception_n81i";
|
||||
detailDetectionState = "0";//当前端口的状态
|
||||
pLevel = Constants.PORT_ALARM_LEVEL;//非界面设置,默认为5级
|
||||
}
|
||||
|
||||
if("1".equals(detailDetectionState)) {//如果当前端口的状态正常,才需要判断流量是否为0
|
||||
//2018年12月3日18:11:57 添加开关,可以控制是否开启流量为 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 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);
|
||||
if((inOctetsSpeed+outOctetsSpeed)<=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";//当前端口的状态
|
||||
pLevel = Constants.PORT_ALARM_LEVEL;//非界面设置,默认为5级
|
||||
}
|
||||
@@ -1089,9 +1097,10 @@ public class DataResolveThread implements Runnable{
|
||||
filedComments = tm==null?"":tm.getFiledComments();
|
||||
}
|
||||
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 += " 报警级别:"+pLevel;
|
||||
// cpInfo += " 报警级别:"+pLevel;
|
||||
cpInfo += " i18n_server.CommonService.policyLevel_n81i:"+pLevel;
|
||||
cpInfo += " \n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,9 @@ public class DetectDetailInsertThread implements Runnable{
|
||||
int count=0;
|
||||
for(Object[] e : params){
|
||||
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++) {
|
||||
Object value = e[i];
|
||||
temp=value;
|
||||
|
||||
@@ -108,7 +108,7 @@ public class DetectInfoInsertThread implements Runnable {
|
||||
} catch (Exception e) {
|
||||
logger.error("error", e);
|
||||
}finally {
|
||||
db.closeQuiet(infoStmt,warnStmt,emailStmt,statusChangeStmt,conn,infoNewInsertStmt,infoNewUpdateStmt);
|
||||
db.closeQuiet(infoStmt,warnStmt,emailStmt,statusChangeStmt,conn,infoNewInsertStmt,infoNewUpdateStmt,warnUpdateStmt);
|
||||
infoStmt = null;
|
||||
warnStmt = null;
|
||||
emailStmt = null;
|
||||
@@ -118,6 +118,7 @@ public class DetectInfoInsertThread implements Runnable {
|
||||
conn = null;
|
||||
infoNewInsertStmt=null;
|
||||
infoNewUpdateStmt=null;
|
||||
warnUpdateStmt = null;
|
||||
}
|
||||
sw.end();
|
||||
logger.info("监测数据info信息解析入库,耗时: " + U.StopWatch.toString(sw.total()) + " ,共 " + count + " 条");
|
||||
@@ -223,8 +224,12 @@ public class DetectInfoInsertThread implements Runnable {
|
||||
|
||||
// 入库
|
||||
saveToNew(insertDataTonew, 0);
|
||||
sw.tag("insertDataTonew");
|
||||
logger.debug("耗时统计: insertDataTonew " + sw.toString(sw.between("insertDataTonew",l + "e")));
|
||||
|
||||
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);
|
||||
sw.tag(l + "sa");
|
||||
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 {
|
||||
Object[] temInfo = null;
|
||||
StopWatch sw = new StopWatch();
|
||||
sw.tag("start");
|
||||
try {
|
||||
int infoCount = infoList.size();
|
||||
int warnCount = 0;
|
||||
int emailCount = 0;
|
||||
int warnRecoveryCount = 0;
|
||||
Map<String,Long> statusChangeMap = U.newHashMap();
|
||||
boolean emailFlag = Constants.flag_email == 1;// 是否启用 email
|
||||
logger.info(emailFlag?"邮件功能開啟" : "邮件功能已关闭");
|
||||
Iterator<Object[]> ite = infoList.iterator();
|
||||
while (ite.hasNext()) {
|
||||
temInfo = ite.next();
|
||||
@@ -332,7 +341,7 @@ public class DetectInfoInsertThread implements Runnable {
|
||||
|
||||
// 添加邮件信息
|
||||
if (!emailFlag) {
|
||||
logger.info("邮件功能已关闭");
|
||||
|
||||
} else {
|
||||
if ((Boolean) temInfo[DetectInfo.SENDEMAILFLAG]) {
|
||||
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();
|
||||
}
|
||||
sw.tag("while");
|
||||
logger.debug("耗时统计: add statement " + sw.toString(sw.between("while","start")));
|
||||
if(infoCount >0){
|
||||
infoStmt.executeBatch();
|
||||
}
|
||||
sw.tag("info");
|
||||
logger.debug("耗时统计: info executeBatch " + sw.toString(sw.between("info","while")));
|
||||
|
||||
if(warnCount >0){
|
||||
warnStmt.executeBatch();
|
||||
}
|
||||
|
||||
sw.tag("warn");
|
||||
logger.debug("耗时统计: warnStmt executeBatch " + sw.toString(sw.between("warn","info")));
|
||||
|
||||
if(emailCount >0){
|
||||
emailStmt.executeBatch();
|
||||
}
|
||||
sw.tag("email");
|
||||
logger.debug("耗时统计: email executeBatch " + sw.toString(sw.between("email","warn")));
|
||||
|
||||
if(statusChangeMap.size() > 0){
|
||||
if(statusChangeStmt == null){
|
||||
@@ -411,10 +442,19 @@ public class DetectInfoInsertThread implements Runnable {
|
||||
}
|
||||
statusChangeStmt.executeBatch();
|
||||
}
|
||||
|
||||
warnUpdateStmt.executeBatch();//update warning
|
||||
sw.tag("status");
|
||||
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();
|
||||
sw.tag("commit");
|
||||
logger.debug("耗时统计: commit executeBatch " + sw.toString(sw.between("commit","warnUpdate")));
|
||||
|
||||
logger.info("批量保存,info :" + infoCount + " , warn : " + warnCount + " ,email : "+ emailCount);
|
||||
} catch (Exception e) {
|
||||
logger.error("info save error ,temInfo : "+Arrays.toString(temInfo) ,e);
|
||||
@@ -432,6 +472,9 @@ public class DetectInfoInsertThread implements Runnable {
|
||||
if(statusChangeStmt != null){
|
||||
statusChangeStmt.clearBatch();
|
||||
}
|
||||
if(warnUpdateStmt != null) {
|
||||
warnUpdateStmt.clearBatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -581,12 +624,12 @@ public class DetectInfoInsertThread implements Runnable {
|
||||
/* 判断状态变更 */
|
||||
stateChange(newDetecInfo, oldDetecInfo);
|
||||
} else {// 监测时间小于数据库中监测数据的时间,说明当前需要入库的监测为延迟数据
|
||||
if (state != 1) {// 延迟数据监测状态没有成功,数据库入库的是正常数据,补录一条报警信息
|
||||
/*if (state != 1) {// 延迟数据监测状态没有成功,数据库入库的是正常数据,补录一条报警信息
|
||||
if ((Integer) newDetecInfo[DetectInfo.STATE] == 1
|
||||
&& (Integer) oldDetecInfo[DetectInfo.PLEVEL] == 99) {
|
||||
newDetecInfo[DetectInfo.APPENDWARNINGINFO] = oldDetecInfo;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
} else {// 大于两条数据时,排序之后判断数据库的数据是否为最接近的时间数据
|
||||
// 未入库的数据排序
|
||||
@@ -790,6 +833,7 @@ public class DetectInfoInsertThread implements Runnable {
|
||||
if (checkType.equalsIgnoreCase(Constants.DETEC_NMSC_STR)) {
|
||||
newDetecInfo[DetectInfo.STATUSCHANGTIME] = (checkTime);
|
||||
}
|
||||
newDetecInfo[DetectInfo.WARN_2_OK] = 1;//告警恢复正常
|
||||
// //update warning table
|
||||
// collectWarnUpdateInfo(newDetecInfo);
|
||||
}
|
||||
@@ -881,7 +925,9 @@ public class DetectInfoInsertThread implements Runnable {
|
||||
*/
|
||||
private void addRecordToStatement(PreparedStatement stmt, Object[] params) throws SQLException {
|
||||
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++) {
|
||||
stmt.setObject(i + 1, params[i]);
|
||||
}
|
||||
@@ -899,15 +945,14 @@ public class DetectInfoInsertThread implements Runnable {
|
||||
if((Long)newDeteInfo[DetectInfo.CHECKTIME]>(Long)oldDetecInfo[DetectInfo.CHECKTIME]){
|
||||
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]};
|
||||
try {
|
||||
addRecordToStatement(warnUpdateStmt, params);
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private void saveToNew(List<Object[]> dataList,int flag){
|
||||
@@ -983,18 +1028,13 @@ public class DetectInfoInsertThread implements Runnable {
|
||||
infoNewUpdateStmt.executeBatch();
|
||||
logger.info("info_new table update success! size : "+ dataList.size());
|
||||
} 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();
|
||||
}
|
||||
}
|
||||
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();
|
||||
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);
|
||||
}
|
||||
}catch (NumberFormatException e) {
|
||||
|
||||
@@ -142,7 +142,11 @@ public class LoadNewMissionThread implements Runnable{
|
||||
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;
|
||||
if(missionFileList != null && missionFileList.size()>0){
|
||||
// ServerTable serverTable = Common.getServerTable();
|
||||
|
||||
@@ -135,7 +135,7 @@ public class MonitorManagerThread implements Runnable{
|
||||
//NMSC
|
||||
Common.runMonitorRunnable(new SystemDateThread(name,model.getNodeIp(),socketPort,setInfo,startTime));
|
||||
}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校验监测
|
||||
Common.runMonitorRunnable(new SwitchPortThread(name,model.getNodeIp(),setInfo,startTime));
|
||||
}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){ //非服务器节点
|
||||
Common.runMonitorRunnable(new SNMP4JThread(name,model.getNodeIp(),setInfo,startTime));
|
||||
}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());
|
||||
pubDatas.add(nextTime.getTimeInMillis() + "");// 下次计划监测时间,
|
||||
|
||||
|
||||
|
||||
//- DetecDatas 拼写 Body
|
||||
List<List<String>> pubDatasList = new ArrayList<List<String>>();
|
||||
if(state != -1){
|
||||
pubDatasList = datasBody(retries,stateInfo.toString(),state,snmpDatasList);
|
||||
pubDatasList = snmpDatasList;//datasBody(retries,stateInfo.toString(),state,snmpDatasList);
|
||||
}
|
||||
|
||||
pubDatas.add(state+""); // 执行状态
|
||||
pubDatas.add(stateInfo.toString()); // 状态信息(描述信息),
|
||||
pubDatas.add(""); // 性能数据,
|
||||
@@ -139,6 +136,7 @@ public class SNMP4JThread implements Runnable{
|
||||
//- 存入缓存
|
||||
if(pubDatasList!=null && pubDatasList.size()>0){
|
||||
try {
|
||||
Common.alarmJudgement(pubDatasList);//告警判断
|
||||
Common.addDeteData(CSVUtils.csvFilePrinter(pubDatasList, Constants.COMMON_TEXT_CODING));
|
||||
logger.debug("监测数据以 CSV格式 保存完成");
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -17,6 +17,8 @@ import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.nutz.json.Json;
|
||||
import org.nutz.json.JsonFormat;
|
||||
import org.snmp4j.mp.SnmpConstants;
|
||||
|
||||
import com.nms.server.bean.SetInfo;
|
||||
@@ -518,8 +520,8 @@ public class SwitchPortThread implements Runnable{
|
||||
//- DetecDatas 拼写 Body
|
||||
List<List<String>> pubDatasList = new ArrayList<List<String>>();
|
||||
if(state != -1){//执行成功了
|
||||
pubDatasList = datasBody(retries,stateInfo.toString(),state,snmpDatasList2);
|
||||
|
||||
pubDatasList =snmpDatasList2;//
|
||||
//datasBody(retries,stateInfo.toString(),state,snmpDatasList2);
|
||||
//64位获取失败告警
|
||||
if(!dataFlag64){
|
||||
state=0;
|
||||
@@ -539,6 +541,8 @@ public class SwitchPortThread implements Runnable{
|
||||
//- 存入缓存
|
||||
if(pubDatasList!=null && pubDatasList.size()>0){
|
||||
try {
|
||||
logger.debug("switchDetection : " + Json.toJson(pubDatasList,JsonFormat.tidy()));
|
||||
Common.alarmJudgement(pubDatasList);//告警判断
|
||||
//添加监测数据到缓存,等待监测数据解析线程的解析入库
|
||||
Common.addDeteData(CSVUtils.csvFilePrinter(pubDatasList, Constants.COMMON_TEXT_CODING));
|
||||
logger.debug("监测数据以 CSV格式 保存完成");
|
||||
@@ -949,22 +953,13 @@ public class SwitchPortThread implements Runnable{
|
||||
|
||||
//拼写监测信息的详细信息:对于switchport,就是每个端口的监测信息
|
||||
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()));
|
||||
|
||||
if(snmpDatas2!=null && snmpDatas2.size()!=0){
|
||||
for (List<String> snmpDatas : snmpDatas2) {
|
||||
// List<String> pubDatas0 = new LinkedList<String>();
|
||||
// 执行状态是否成功是否正常, 第三方脚本监测任务执行结果(用于报警 -1执行失败 0不正常,1正常)-1时可保留后续数据为空,但是数据个数需要对应
|
||||
for (List<String> snmpDatas : snmpDatas2) {
|
||||
// -- 执行状态是否成功,记录的状态是否正常(用于报警),
|
||||
String [] datas0 = new String[0];
|
||||
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);
|
||||
// logger.debug("pArray>>>> "+Arrays.toString(pArray));
|
||||
if (pArray == null || pArray.length==0) {//无告警信息
|
||||
snmpDatas.add(0, "");//插入后,列表之后的信息顺序往后移
|
||||
snmpDatas.add(1, "");
|
||||
@@ -975,13 +970,19 @@ public class SwitchPortThread implements Runnable{
|
||||
snmpDatas.add(1, pArray == null ? "" : pArray[1]);
|
||||
snmpDatas.add(2, pArray == null ? "" : pArray[2]);
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
class Switch{
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.nms.server.common.Constants;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@@ -101,14 +103,18 @@ public class MessageDecoder extends ByteToMessageDecoder {
|
||||
if(m != null){
|
||||
out.add(m);
|
||||
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{
|
||||
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)){//初始状态,且不能读取 协议头
|
||||
return null;
|
||||
}
|
||||
@@ -181,7 +187,9 @@ public class MessageDecoder extends ByteToMessageDecoder {
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public class NMSWebBPDownload extends SocketUtils implements Callable<Object>{
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
logger.warn("Target communication:>"+ip+" create failure",e);
|
||||
logger.warn("Target communication:>"+ip+":"+port+" create failure",e);
|
||||
close();
|
||||
return -2;
|
||||
|
||||
|
||||
@@ -66,19 +66,23 @@ public class SSLServerManager implements Callable<Object>{
|
||||
Thread.currentThread().setName("Receiving communication");
|
||||
try {
|
||||
while (true) {
|
||||
Common.acquireServerSemaphore();//阻塞 获取 server 信号量
|
||||
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升级功能
|
||||
logger.debug("来自:"+socket.getInetAddress().getHostAddress());
|
||||
Common.service.submit(new SSLServer(socket));
|
||||
}else{ //关闭 放弃的通讯
|
||||
logger.debug("Server升级 抛弃通讯:"+socket.getInetAddress().getHostAddress());
|
||||
logger.debug(String.format("Server升级 抛弃通讯:%s", address));
|
||||
Common.releaseServerSemaphore();
|
||||
socket.close();
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
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,"");
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
logger.error("socket server error",e);
|
||||
}finally{
|
||||
try {
|
||||
sslServer.close();
|
||||
|
||||
@@ -935,7 +935,7 @@ public class ConnectionOracle {
|
||||
fields.add(idName);
|
||||
fields.add(pidName);
|
||||
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){
|
||||
for(Map<String,String> map : list){
|
||||
String id = map.get(idName);
|
||||
|
||||
@@ -39,6 +39,7 @@ public class DruidPool {
|
||||
ds.setPassword(Constants.DB_PASSWORD);
|
||||
ds.configFromPropety(properties);
|
||||
ds.setName("Druid连接池");
|
||||
ds.setMaxWait(Constants.DRUID_MAXWAIT_MILLIS);//最大等待时间
|
||||
ds.init();
|
||||
logger.debug("Druid初始化连接池成功,"+ds.toString());
|
||||
}
|
||||
|
||||
@@ -398,11 +398,11 @@ public class SNMP4JUtils {
|
||||
for (int j = 0; j < list.size(); j++) {
|
||||
TreeEvent treeEvent = (TreeEvent)list.get(j);
|
||||
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)
|
||||
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)
|
||||
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 ){
|
||||
VariableBinding vbArr[] = treeEvent.getVariableBindings();
|
||||
if(vbArr != null){
|
||||
@@ -411,7 +411,15 @@ public class SNMP4JUtils {
|
||||
OID oid = vb.getOid();
|
||||
String index = oid.last()+"";//索引
|
||||
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("."));
|
||||
System.out.println(oid.toString() + " --> " + oidStr);
|
||||
if(oidModel.contains(oidStr)){
|
||||
Map<String, String> map = mapInstance.get(index);
|
||||
if(map == null){
|
||||
@@ -457,11 +465,11 @@ public class SNMP4JUtils {
|
||||
for (int j = 0; j < list.size(); j++) {
|
||||
TreeEvent treeEvent = (TreeEvent)list.get(j);
|
||||
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)
|
||||
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)
|
||||
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 ){
|
||||
VariableBinding vbArr[] = treeEvent.getVariableBindings();
|
||||
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.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]
|
||||
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.3");
|
||||
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.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.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.4.1.1000.4.3.1";
|
||||
String host = "10.0.6.230";
|
||||
String oid = "1.3.6.1.4.1.5000000.1.4.1.1";
|
||||
String host = "10.4.2.5";
|
||||
String port = "161";
|
||||
String community = "public";
|
||||
int retries = 3;
|
||||
|
||||
@@ -24,7 +24,7 @@ public abstract class SSLSocketCallable extends SocketUtils implements Callable<
|
||||
private static Logger logger = Logger.getLogger(SSLSocketCallable.class);
|
||||
//ServerSocket 通讯服务
|
||||
protected SSLServerSocket ss = null;
|
||||
|
||||
private boolean clientFlag = false;// 是否dc server 接收的client
|
||||
/**
|
||||
* 通讯创建
|
||||
* @param ip 目标主机IP
|
||||
@@ -41,6 +41,7 @@ public abstract class SSLSocketCallable extends SocketUtils implements Callable<
|
||||
*/
|
||||
public SSLSocketCallable(Socket client) {
|
||||
super(client);
|
||||
clientFlag = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,39 +52,39 @@ public abstract class SSLSocketCallable extends SocketUtils implements Callable<
|
||||
public Object call(){
|
||||
Thread.currentThread().setName("Create communication"+ip+":"+port);
|
||||
Object obj = null; //返回对象
|
||||
|
||||
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){ //客户端通讯创建
|
||||
createClientSocket();
|
||||
}else{ //服务端通讯创建
|
||||
createServerSocket();
|
||||
//-- 自定义通讯操作
|
||||
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 {
|
||||
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 {
|
||||
close();
|
||||
if(clientFlag){
|
||||
Common.releaseServerSemaphore();//释放server信号量
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
##--公共数据存放父目录(*部署需修改*)
|
||||
common.datas.dir = D:/nms/nmsdata
|
||||
##--系统SNMP监测,指定服务器IP 指本机(*部署需修改*)
|
||||
system.inet.address = 10.0.6.114
|
||||
system.inet.address = 127.0.0.1
|
||||
##--NMSWeb端 通讯IP 指WEB(*部署需修改*)
|
||||
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.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://localhost:3306/nms?useUnicode=true&characterEncoding=utf-8&useOldAliasMetadataBehavior=true&rewriteBatchedStatements=true
|
||||
##--数据库 用户名(*部署需修改*)
|
||||
#db.username = nms
|
||||
db.username = nms
|
||||
@@ -48,6 +48,8 @@ email.host =
|
||||
web.socket.port = 60703
|
||||
|
||||
#---Common-------
|
||||
##--分中心只执行自身范围内client的任务 0 关闭;1 开启;
|
||||
mission.single = 1
|
||||
##--全局文本解析编码,与web端、Agent端一致,不可修改
|
||||
common.text.coding = UTF-8
|
||||
##--全局日期格式化方式,须与数据库 日期数据格式化方式(db.date.format)保持一致,不建议修改
|
||||
|
||||
Reference in New Issue
Block a user