1、mtr探测设备增加并发限制。
2、开发防火墙策略区分ipv4和ipv6。 3、脚本执行策略下发时间优化。
This commit is contained in:
@@ -15,6 +15,8 @@ public class PolicyTypeVo {
|
||||
private String versions;
|
||||
/** 路由信息 */
|
||||
private String routes;
|
||||
/** 业务网卡名称*/
|
||||
private String netName;
|
||||
/** 时间戳 */
|
||||
private Long timestamp = Instant.now().getEpochSecond();
|
||||
}
|
||||
|
||||
@@ -353,6 +353,8 @@ public class MessageHandler {
|
||||
rmDeploymentPolicyService.issueDeployPolicyMsgByClientId(clientId);
|
||||
// 如果路由有变化,更新路由信息
|
||||
rmNetworkInterfaceService.updateRouteMsg(clientId);
|
||||
// 如果业务网卡名称有变化,更新防火墙策略
|
||||
rmNetworkInterfaceService.issueNetName(clientId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -926,6 +928,32 @@ public class MessageHandler {
|
||||
String collectValue = systemDataVo.getValue();
|
||||
insertData.setCollectType(collectType);
|
||||
insertData.setCollectValue(collectValue);
|
||||
|
||||
// 定义需要先删后插的collectType列表
|
||||
List<String> specialCollectTypes = Arrays.asList(
|
||||
"kernelMaxprocCollect",
|
||||
"memorySizeTotalCollect",
|
||||
"systemBoottimeCollect",
|
||||
"systemCpuNum",
|
||||
"systemDiskSizeTotalCollect",
|
||||
"systemLocaltimeCollect",
|
||||
"systemSwArchCollect",
|
||||
"systemSwOsCollect",
|
||||
"systemUnameCollect",
|
||||
"systemUptimeCollect"
|
||||
);
|
||||
|
||||
// 如果collectType在特殊列表中,先删除上个时间段的记录
|
||||
if (specialCollectTypes.contains(collectType)) {
|
||||
|
||||
// 删除相同clientId、collectType和时间范围内的记录
|
||||
InitialSystemOtherCollectData deleteData = new InitialSystemOtherCollectData();
|
||||
deleteData.setClientId(message.getClientId());
|
||||
deleteData.setCollectType(collectType);
|
||||
deleteData.setCreateTime(createTime);
|
||||
iInitialSystemOtherCollectDataService.deleteInitialSystemOtherCollectData(deleteData);
|
||||
}
|
||||
|
||||
iInitialSystemOtherCollectDataService.insertInitialSystemOtherCollectData(insertData);
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -1239,6 +1267,7 @@ public class MessageHandler {
|
||||
if (isSwitch) {
|
||||
rmAlarmLog.setClientId(switchName);
|
||||
rmAlarmLog.setAlarmType("2");
|
||||
alarmContent = switchName + "下线";
|
||||
} else {
|
||||
// 查询管理网公网ip
|
||||
RmNetworkInterface rmNetworkInterface = new RmNetworkInterface();
|
||||
|
||||
+7
@@ -67,4 +67,11 @@ public interface InitialSystemOtherCollectDataMapper
|
||||
* @return
|
||||
*/
|
||||
Map getMonitorMsg(InitialSystemOtherCollectData initialSystemOtherCollectData);
|
||||
|
||||
/**
|
||||
* 删除上一次的详情
|
||||
* @param deleteData
|
||||
* @return
|
||||
*/
|
||||
int deleteInitialSystemOtherCollectData(InitialSystemOtherCollectData deleteData);
|
||||
}
|
||||
|
||||
+7
@@ -116,4 +116,11 @@ public interface IInitialSystemOtherCollectDataService
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> procNumEcharts(InitialSystemOtherCollectData initialSystemOtherCollectData);
|
||||
|
||||
/**
|
||||
* 删除上一次的详情,除去图形
|
||||
* @param deleteData
|
||||
* @return
|
||||
*/
|
||||
int deleteInitialSystemOtherCollectData(InitialSystemOtherCollectData deleteData);
|
||||
}
|
||||
|
||||
+6
@@ -79,4 +79,10 @@ public interface IRmNetworkInterfaceService
|
||||
* @param clientId
|
||||
*/
|
||||
void updateRouteMsg(String clientId);
|
||||
|
||||
/**
|
||||
* 下发业务网卡名称
|
||||
* @param clientId
|
||||
*/
|
||||
void issueNetName(String clientId);
|
||||
}
|
||||
|
||||
+5
@@ -309,4 +309,9 @@ public class InitialSystemOtherCollectDataServiceImpl implements IInitialSystemO
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteInitialSystemOtherCollectData(InitialSystemOtherCollectData deleteData) {
|
||||
return initialSystemOtherCollectDataMapper.deleteInitialSystemOtherCollectData(deleteData);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -348,7 +348,7 @@ public class RmDeploymentPolicyServiceImpl implements IRmDeploymentPolicyService
|
||||
scriptPolicyVo.setPolicyTime(timestampInSecondes);
|
||||
}
|
||||
String[] clientIdArr = policy.getDeployDevice().split("\n");
|
||||
sendDeploymentPolicy(clientIdArr, scriptPolicyVo);
|
||||
sendDeploymentPolicy(clientIdArr, scriptPolicyVo, policy.getCreateTime().getTime() /1000);
|
||||
// 更新策略状态为已下发
|
||||
RmDeploymentPolicy deploymentPolicy = new RmDeploymentPolicy();
|
||||
deploymentPolicy.setId(policy.getId());
|
||||
@@ -367,13 +367,14 @@ public class RmDeploymentPolicyServiceImpl implements IRmDeploymentPolicyService
|
||||
/**
|
||||
* 发送配置到设备
|
||||
*/
|
||||
private void sendDeploymentPolicy(String[] clientIdArr, ServerScriptPolicyVo scriptPolicyVo) {
|
||||
private void sendDeploymentPolicy(String[] clientIdArr, ServerScriptPolicyVo scriptPolicyVo, long createTime) {
|
||||
MessageProducer messageProducer = new MessageProducer();
|
||||
|
||||
PolicyVo<ServerScriptPolicyVo> policyVo = new PolicyVo();
|
||||
List<ServerScriptPolicyVo> list = new ArrayList<>();
|
||||
list.add(scriptPolicyVo);
|
||||
policyVo.setContents(list);
|
||||
policyVo.setUpTime(createTime);
|
||||
String policyVoStr = JSONObject.toJSONString(policyVo);
|
||||
PolicyTypeVo policyTypeVo = new PolicyTypeVo();
|
||||
policyTypeVo.setScripts(policyVoStr);
|
||||
|
||||
+31
@@ -179,4 +179,35 @@ public class RmNetworkInterfaceServiceImpl implements IRmNetworkInterfaceService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void issueNetName(String clientId) {
|
||||
RmNetworkInterface rmNetworkInterface = new RmNetworkInterface();
|
||||
rmNetworkInterface.setClientIds(clientId);
|
||||
List<RmNetworkInterface> networkInterfaces = rmNetworkInterfaceMapper.selectRmNetworkInterfaceList(rmNetworkInterface);
|
||||
// 拼接所有符合条件的网络接口名称,用分号隔开
|
||||
StringBuilder netNameBuilder = new StringBuilder();
|
||||
for (int i = 0; i < networkInterfaces.size(); i++) {
|
||||
if (i > 0) {
|
||||
netNameBuilder.append(";");
|
||||
}
|
||||
netNameBuilder.append(networkInterfaces.get(i).getInterfaceName());
|
||||
}
|
||||
String netName = netNameBuilder.toString();
|
||||
MessageProducer messageProducer = new MessageProducer();
|
||||
PolicyTypeVo policyTypeVo = new PolicyTypeVo();
|
||||
policyTypeVo.setNetName(netName);
|
||||
String configJson = JSONObject.toJSONString(policyTypeVo);
|
||||
DeviceMessage message = new DeviceMessage();
|
||||
message.setClientId(clientId);
|
||||
message.setData(configJson);
|
||||
message.setDataType(MsgEnum.获取最新策略应答.getValue());
|
||||
|
||||
messageProducer.sendAsyncProducerMessage(
|
||||
producerMode.getAgentTopic(),
|
||||
"",
|
||||
"",
|
||||
JSONObject.toJSONString(message)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user