|
|
package com.sitech.jmx.mbean;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import org.apache.log4j.Logger;
|
|
|
|
|
|
import com.sitech.base.AgentProperties;
|
|
|
import com.sitech.database.dao.TbAtoDynamicThresholdDao;
|
|
|
import com.sitech.database.dao.TbCfgEventDao;
|
|
|
import com.sitech.database.dao.TbCfgOidMibDao;
|
|
|
import com.sitech.database.domain.TbCfgEvent;
|
|
|
import com.sitech.database.domain.TbCfgOidMib;
|
|
|
import com.sitech.ismp.check.downtime.DowntimeDao;
|
|
|
import com.sitech.ismp.coll.cron.CronConstants;
|
|
|
import com.sitech.ismp.messageObject.AgentSyncObject;
|
|
|
import com.sitech.ismp.messageObject.AlarmEventConfig;
|
|
|
import com.sitech.ismp.messageObject.AlarmEventConfigSyncObject;
|
|
|
import com.sitech.ismp.messageObject.MibConfig;
|
|
|
import com.sitech.ismp.messageObject.MibConfigSyncObject;
|
|
|
import com.sitech.ismp.messageObject.ScheduleLog;
|
|
|
import com.sitech.ismp.messageObject.*;
|
|
|
import com.sitech.jmx.manage.CollScheduleManager;
|
|
|
import com.sitech.jmx.manage.MBeanManager;
|
|
|
import com.sitech.schedule.ScheduleCache;
|
|
|
import com.sitech.schedule.Scheduler;
|
|
|
import com.sitech.snmptrap.TbTopoPhysicalDeviceDao;
|
|
|
import com.sitech.util.Formater;
|
|
|
import com.sitech.util.mq.MQConstants;
|
|
|
import com.sitech.util.mq.TunnelFactory;
|
|
|
import org.apache.log4j.Logger;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 采集/告警配置同步
|
...
|
...
|
@@ -71,6 +68,9 @@ public class ConfigSync implements ConfigSyncMBean { |
|
|
String scheduleOperate = obj.getParams().get("SCHEDULE_OPERATE");
|
|
|
extInfo.put("SCHEDULE_OPERATE",scheduleOperate);
|
|
|
removeCollSchedule(obj);
|
|
|
// removeMemDbCfgData(obj);
|
|
|
removeDowntimeMBean(obj);
|
|
|
// 删除内存数据库中相关的配置数据
|
|
|
scheStatus = "0";
|
|
|
if("1".equals(scheduleOperate)){
|
|
|
logInfo = "agent删除调度任务成功";
|
...
|
...
|
@@ -114,7 +114,7 @@ public class ConfigSync implements ConfigSyncMBean { |
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
public void syncEventCfg(AlarmEventConfigSyncObject obj) throws Exception {
|
|
|
int type = obj.getSyncType();
|
|
|
List<AlarmEventConfig> configList = obj.getConfigList();
|
...
|
...
|
@@ -154,6 +154,54 @@ public class ConfigSync implements ConfigSyncMBean { |
|
|
logger.info("End refresh table[TB_CFG_EVENT], delete ["+configList.size()+"] config");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除添加主机的MBean。
|
|
|
* @param obj
|
|
|
*/
|
|
|
private void removeMemDbCfgData(AgentSyncObject obj){
|
|
|
if(obj.getClassName().equals("com.sitech.snmptrap.TbTopoPhysicalDevice")){
|
|
|
TbTopoPhysicalDeviceDao physicalDeviceDao = new TbTopoPhysicalDeviceDao();
|
|
|
physicalDeviceDao.deletePhysicalDeviceByIp(obj.getParams().get("DEVICE_IP"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除需要监控宕机的主机。
|
|
|
* @param obj
|
|
|
*/
|
|
|
private void removeDowntimeMBean(AgentSyncObject obj){
|
|
|
if(obj.getClassName().equals("com.sitech.ismp.check.downtime.Downtime")){
|
|
|
DowntimeDao dao = new DowntimeDao();
|
|
|
dao.deleteDowntimeHostByIp(obj.getParams().get("DEVICE_IP"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 添加监控宕机的MBean。
|
|
|
* 监控主机连接状态,有异常的时候,产生告警。
|
|
|
* frank 2017-04-11
|
|
|
*/
|
|
|
/*private void regeditDowntimeMBean(AgentSyncObject obj,String scheduleId){
|
|
|
boolean isExist=CollScheduleManager.getInstance().scheduleExist(scheduleId);
|
|
|
if(!isExist){
|
|
|
DowntimeServer server=new DowntimeServer();
|
|
|
if(obj.getClassName().equals("com.sitech.snmptrap.TbTopoPhysicalDevice")){
|
|
|
AgentSyncObject downtimeAgentSyncObject= server.getAgentSyncObject(obj,scheduleId);
|
|
|
log.info("get DowntimeMBean,className ====== "+downtimeAgentSyncObject.getClassName());
|
|
|
try {
|
|
|
addCollSchedule(downtimeAgentSyncObject);
|
|
|
log.info("******************************************************************");
|
|
|
log.info("************* 注册DowntimeMBean完成,开始监听宕机情况 **************");
|
|
|
log.info("******************************************************************");
|
|
|
} catch (Exception e) {
|
|
|
log.error("regedit DowntimeMBean has wrong",e);
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}*/
|
|
|
|
|
|
private void updateEventCfg(List<AlarmEventConfig> configList) {
|
|
|
String[] guid = new String[configList.size()];
|
|
|
for (int i = 0; i < configList.size(); i++) {
|
...
|
...
|
@@ -361,4 +409,91 @@ public class ConfigSync implements ConfigSyncMBean { |
|
|
TunnelFactory.getTunnel(MQConstants.Q_ROPORT_FROM_AGENT).writeData(log);
|
|
|
}
|
|
|
|
|
|
public void syncDynamicCfg(AlarmDynamicConfigSyncObject obj) throws Exception {
|
|
|
int type = obj.getSyncType();
|
|
|
List<TbAtoDynamicThreshold> configList = obj.getConfigList();
|
|
|
|
|
|
logger.info("Begin refresh table[TB_ATO_DYNAMIC_THRESHOLD]...");
|
|
|
|
|
|
if (configList == null || configList.size() == 0) {
|
|
|
logger.info("End refresh table[TB_ATO_DYNAMIC_THRESHOLD], update [0] config");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
switch (type) {
|
|
|
case TYPE_SYNC_ALL:
|
|
|
refreshAllDynamicCfg(configList);
|
|
|
break;
|
|
|
case TYPE_CREATE:
|
|
|
addDynamicCfg(configList);
|
|
|
break;
|
|
|
case TYPE_UPDATE:
|
|
|
updateDynamicCfg(configList);
|
|
|
break;
|
|
|
case TYPE_DELETE:
|
|
|
deleteDynamicCfg(configList);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 刷新所有动态阀值配置
|
|
|
* @param configList
|
|
|
*/
|
|
|
private void refreshAllDynamicCfg(List<TbAtoDynamicThreshold> configList) {
|
|
|
TbAtoDynamicThresholdDao dao = new TbAtoDynamicThresholdDao();
|
|
|
int result = dao.deleteTbAtoDynamicThresholdAll();
|
|
|
if (result != -1) {
|
|
|
for (TbAtoDynamicThreshold config : configList) {
|
|
|
//TbCfgEvent tbCfgEvent = new TbCfgEvent(config);
|
|
|
dao.insertTbAtoDynamicThreshold(config);
|
|
|
}
|
|
|
}
|
|
|
logger.info("End refresh table[TB_ATO_DYNAMIC_THRESHOLD], update ["+configList.size()+"] config");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新增动态阀值配置
|
|
|
* @param configList
|
|
|
*/
|
|
|
private void addDynamicCfg(List<TbAtoDynamicThreshold> configList) {
|
|
|
TbAtoDynamicThresholdDao dao = new TbAtoDynamicThresholdDao();
|
|
|
for (TbAtoDynamicThreshold config : configList) {
|
|
|
//TbCfgEvent tbCfgEvent = new TbCfgEvent(config);
|
|
|
dao.insertTbAtoDynamicThreshold(config);
|
|
|
}
|
|
|
logger.info("End refresh table[TB_ATO_DYNAMIC_THRESHOLD], add ["+configList.size()+"] config");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 更新动态阀值配置
|
|
|
* @param configList
|
|
|
*/
|
|
|
private void updateDynamicCfg(List<TbAtoDynamicThreshold> configList) {
|
|
|
String[] id = new String[configList.size()];
|
|
|
for (int i = 0; i < configList.size(); i++) {
|
|
|
id[i] = configList.get(i).getID();
|
|
|
}
|
|
|
TbAtoDynamicThresholdDao dao = new TbAtoDynamicThresholdDao();
|
|
|
dao.deleteTbAtoDynamicThreshold(id);
|
|
|
for (TbAtoDynamicThreshold config : configList) {
|
|
|
dao.insertTbAtoDynamicThreshold(config);
|
|
|
}
|
|
|
logger.info("End refresh table[TB_ATO_DYNAMIC_THRESHOLD], update ["+configList.size()+"] config");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除动态阀值配置
|
|
|
* @param configList
|
|
|
*/
|
|
|
private void deleteDynamicCfg(List<TbAtoDynamicThreshold> configList) {
|
|
|
String[] guid = new String[configList.size()];
|
|
|
for (int i = 0; i < configList.size(); i++) {
|
|
|
guid[i] = configList.get(i).getGUID();
|
|
|
}
|
|
|
TbAtoDynamicThresholdDao dao = new TbAtoDynamicThresholdDao();
|
|
|
dao.deleteTbAtoDynamicThreshold(guid);
|
|
|
logger.info("End refresh table[TB_ATO_DYNAMIC_THRESHOLD], delete ["+configList.size()+"] config");
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|