Merge remote-tracking branch 'origin/main' into lichang

This commit is contained in:
TsMask
2024-04-30 20:21:58 +08:00
34 changed files with 533 additions and 275 deletions

View File

@@ -1,5 +1,18 @@
# 版本发布日志
## 2.2404.6-20240430
* 优化 网元状态信息表的记录修改为只保留一天duration=1
* 优化 删除过期记录的调度任务增加参数sessFlagtrue:使用session模式进行删除false或者不带该参数不使用session模式删除可加快速度
## 2.2404.5-20240426
* 优化 adb升级目录切换安装升级时替换/usr/local/etc/adb/adb.conf的replica-read-only只读属性为no增加masterauth密码行
* 修复 网元状态异常时如果网元的状态记录被完全清空导致无法产生10000的网元状态异常告警
* 优化 后端增加SMF在线用户状态Up State的处理修改查询接口增加查询参数upstate={Inactive/Active}
* 优化 告警短信前转,增加短信方式选择配置项,可使用短信云服务和短信中心模式,告警前转日志增加前转接口字段
* 优化 重构黄金指标存储表优化为将所有kpiid存储在一条记录同时分网元存储不同的表如kpi_report_amf上周发布的版本黄金指标发送到原表和新的表前端还未实现从新表获取统计数据
## 2.2404.4-20240419
- 优化 隐藏性能统计和跟踪的任务和数据菜单项

View File

@@ -1,7 +1,7 @@
# Makefile for rest agent project
PROJECT = OMC
VERSION = 2.2404.4
VERSION = 2.2404.6
PLATFORM = amd64
ARMPLATFORM = aarch64
BUILDDIR = ../../build

View File

@@ -137,6 +137,7 @@ alarm:
password: xxxxxx
# TLS skip verify: true/false
tlsSkipVerify: true
smProxy: smsc
sms:
apiURL: http://smsc.xxx.com
accessKeyID: xxx

View File

@@ -1,7 +1,7 @@
# Makefile for rest agent project
PROJECT = OMC
VERSION = 2.2404.4
VERSION = 2.2404.6
RelDate = `date +%Y%m%d`
Release = $(RelDate)
RelVer = $(VERSION)-$(RelDate)

View File

@@ -1,49 +1,39 @@
-- MariaDB dump 10.19 Distrib 10.6.16-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: 192.168.2.219 Database: omc_db
-- ------------------------------------------------------
-- Server version 10.3.38-MariaDB
/*
Navicat Premium Data Transfer
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
Source Server : local_mariadb
Source Server Type : MariaDB
Source Server Version : 100338 (10.3.38-MariaDB)
Source Host : localhost:33066
Source Schema : omc_db
--
-- Table structure for table `alarm_forward_log`
--
Target Server Type : MariaDB
Target Server Version : 100338 (10.3.38-MariaDB)
File Encoding : 65001
Date: 23/04/2024 14:05:00
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for alarm_forward_log
-- ----------------------------
DROP TABLE IF EXISTS `alarm_forward_log`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `alarm_forward_log` (
CREATE TABLE `alarm_forward_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ne_type` varchar(32) DEFAULT NULL,
`ne_id` varchar(32) DEFAULT NULL,
`alarm_id` varchar(32) DEFAULT NULL,
`alarm_title` varchar(255) DEFAULT NULL,
`alarm_seq` varchar(20) DEFAULT NULL,
`event_time` datetime DEFAULT NULL,
`to_user` varchar(255) DEFAULT NULL,
`oper_result` varchar(255) DEFAULT NULL,
`log_time` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`alarm_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`alarm_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`alarm_seq` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`event_time` datetime NULL DEFAULT NULL,
`interface` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`to_user` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`oper_result` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`log_time` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=209122 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
) ENGINE = InnoDB AUTO_INCREMENT = 209149 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2024-03-06 17:26:55
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -0,0 +1,41 @@
/*
Navicat Premium Data Transfer
Source Server : root@192.168.2.166
Source Server Type : MariaDB
Source Server Version : 100616 (10.6.16-MariaDB-0ubuntu0.22.04.1)
Source Host : 192.168.2.166:33066
Source Schema : omc_db
Target Server Type : MariaDB
Target Server Version : 100616 (10.6.16-MariaDB-0ubuntu0.22.04.1)
File Encoding : 65001
Date: 26/04/2024 17:20:10
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for kpi_report
-- ----------------------------
DROP TABLE IF EXISTS `kpi_report`;
CREATE TABLE `kpi_report` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ne_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`ne_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '',
`rm_uid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`date` date NOT NULL,
`start_time` time NULL DEFAULT NULL,
`end_time` time NULL DEFAULT NULL,
`index` smallint(6) NOT NULL,
`granularity` tinyint(4) NULL DEFAULT 60 COMMENT 'Time granualarity: 5/10/.../60/300 (second)',
`kpi_values` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
`created_at` bigint(20) NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_timestamp`(`created_at`) USING BTREE,
INDEX `idx_uid_datetime`(`rm_uid`, `date`, `start_time`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 10660 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -1,65 +1,56 @@
-- MariaDB dump 10.19 Distrib 10.6.16-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: 192.168.2.219 Database: omc_db
-- ------------------------------------------------------
-- Server version 10.3.38-MariaDB
/*
Navicat Premium Data Transfer
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
Source Server : local_mariadb
Source Server Type : MariaDB
Source Server Version : 100338 (10.3.38-MariaDB)
Source Host : localhost:33066
Source Schema : omc_db
--
-- Table structure for table `sys_job`
--
Target Server Type : MariaDB
Target Server Version : 100338 (10.3.38-MariaDB)
File Encoding : 65001
Date: 28/04/2024 16:05:50
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for sys_job
-- ----------------------------
DROP TABLE IF EXISTS `sys_job`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `sys_job` (
CREATE TABLE `sys_job` (
`job_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '任务ID',
`job_name` varchar(50) NOT NULL DEFAULT '' COMMENT '任务名称',
`job_group` varchar(50) NOT NULL DEFAULT 'DEFAULT' COMMENT '任务组名',
`invoke_target` varchar(50) NOT NULL COMMENT '调用目标字符串',
`target_params` varchar(500) DEFAULT '' COMMENT '调用目标传入参数',
`cron_expression` varchar(50) DEFAULT '' COMMENT 'cron执行表达式',
`misfire_policy` char(1) DEFAULT '3' COMMENT '计划执行错误策略1立即执行 2执行一次 3放弃执行',
`concurrent` char(1) DEFAULT '0' COMMENT '是否并发执行0禁止 1允许',
`status` char(1) DEFAULT '0' COMMENT '任务状态0暂停 1正常',
`save_log` varchar(1) DEFAULT '0' COMMENT '是否记录任务日志0不记录 1记录',
`create_by` varchar(50) DEFAULT '' COMMENT '创建者',
`create_time` bigint(20) DEFAULT 0 COMMENT '创建时间',
`update_by` varchar(50) DEFAULT '' COMMENT '更新者',
`update_time` bigint(20) DEFAULT 0 COMMENT '更新时间',
`remark` varchar(500) DEFAULT '' COMMENT '备注',
`job_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '任务名称',
`job_group` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'DEFAULT' COMMENT '任务组名',
`invoke_target` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '调用目标字符串',
`target_params` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '调用目标传入参数',
`cron_expression` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'cron执行表达式',
`misfire_policy` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '3' COMMENT '计划执行错误策略1立即执行 2执行一次 3放弃执行',
`concurrent` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '是否并发执行0禁止 1允许',
`status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '任务状态0暂停 1正常',
`save_log` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '是否记录任务日志0不记录 1记录',
`create_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '创建者',
`create_time` bigint(20) NULL DEFAULT 0 COMMENT '创建时间',
`update_by` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '更新者',
`update_time` bigint(20) NULL DEFAULT 0 COMMENT '更新时间',
`remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '备注',
PRIMARY KEY (`job_id`) USING BTREE,
UNIQUE KEY `idx_uni_name_group` (`job_name`,`job_group`) USING BTREE COMMENT 'unique index for job_name and job_group'
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='调度任务调度表';
/*!40101 SET character_set_client = @saved_cs_client */;
UNIQUE INDEX `idx_uni_name_group`(`job_name`, `job_group`) USING BTREE COMMENT 'unique index for job_name and job_group'
) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '调度任务调度表' ROW_FORMAT = Dynamic;
--
-- Dumping data for table `sys_job`
--
-- ----------------------------
-- Records of sys_job
-- ----------------------------
INSERT INTO `sys_job` VALUES (1, 'job.monitor_sys_resource', 'SYSTEM', 'monitor_sys_resource', '{\"interval\":5}', '0 0/5 * * * ?', '3', '0', '1', '0', 'supervisor', 1698478134839, 'supervisor', 1700571615807, 'job.monitor_sys_resource_remark');
INSERT INTO `sys_job` VALUES (4, 'job.delExpiredNeBackup', 'SYSTEM', 'delExpiredNeBackup', '{\"duration\":60}', '0 20 0 * * ?', '3', '0', '1', '1', 'supervisor', 1698478134840, NULL, 0, 'job.delExpiredNeBackupRemark');
INSERT INTO `sys_job` VALUES (5, 'job.deleteExpiredAlarmRecord', 'SYSTEM', 'deleteExpiredRecord', '{\"duration\":90,\"tableName\":\"alarm\",\"colName\":\"event_time\",\"extras\":\"alarm_status=\'0\'\"}', '0 10 0 * * ?', '3', '0', '1', '1', 'supervisor', 1698478134841, NULL, 0, 'job.deleteExpiredAlarmRecordRemark');
INSERT INTO `sys_job` VALUES (6, 'job.deleteExpiredKpiRecord', 'SYSTEM', 'deleteExpiredRecord', '{\"duration\":30,\"tableName\":\"gold_kpi\",\"colName\":\"date\"}', '0 15 0 * * ?', '3', '0', '1', '1', 'supervisor', 1698478134842, 'supervisor', 1700570673113, 'job.deleteExpiredKpiRecordRemark');
INSERT INTO `sys_job` VALUES (7, 'job.backupEtcFromNE', 'SYSTEM', 'backupEtcFromNE', NULL, '0 30 0 * * ?', '3', '0', '1', '1', 'supervisor', 1698478134843, NULL, 0, 'job.backupEtcFromNERemark');
INSERT INTO `sys_job` VALUES (8, 'job.deleteExpiredNeStateRecord', 'SYSTEM', 'deleteExpiredRecord', '{\"duration\":1,\"tableName\":\"ne_state\",\"colName\":\"timestamp\"}', '0 25 0 * * ?', '3', '0', '1', '1', 'supervisor', 1698478134842, 'admin', 1703668901929, 'job.deleteExpiredNeStateRecordRemark');
INSERT INTO `sys_job` VALUES (9, 'job.getStateFromNE', 'SYSTEM', 'getStateFromNE', '', '0/10 * * * * ?', '3', '0', '1', '0', 'supervisor', 1698478134842, 'admin', 1713231120503, 'job.getStateFromNERemark');
INSERT INTO `sys_job` VALUES (10, 'job.genNeStateAlarm', 'SYSTEM', 'genNeStateAlarm', '{\"alarmID\":\"HXEMSSM10000\",\"alarmCode\":10000,\"alarmTitle\":\"The system state is abnormal\",\"neType\":\"OMC\",\"alarmType\":\"EquipmentAlarm\",\"origSeverity\": \"Major\",\"objectName\":\"EMS;SystemManagement;Heartbeat\",\"objectType\":\"SystemState\",\"specificProblem\":\"Alarm cause: the system state of target NE has not been received for {threshold} seconds\", \"specificProblemID\":\"AC10000\",\"threshold\":30}', '0/5 * * * * ?', '3', '0', '1', '0', 'supervisor', 1698478134842, 'admin', 1713781643031, 'job.genNeStateAlarmRemark');
LOCK TABLES `sys_job` WRITE;
/*!40000 ALTER TABLE `sys_job` DISABLE KEYS */;
INSERT INTO `sys_job` VALUES (1,'job.monitor_sys_resource','SYSTEM','monitor_sys_resource','{\"interval\":5}','0 0/5 * * * ?','3','0','1','0','supervisor',1698478134839,'supervisor',1700571615807,'job.monitor_sys_resource_remark'),(4,'job.delExpiredNeBackup','SYSTEM','delExpiredNeBackup','{\"duration\":60}','0 20 0 * * ?','3','0','1','1','supervisor',1698478134840,NULL,0,'job.delExpiredNeBackupRemark'),(5,'job.deleteExpiredAlarmRecord','SYSTEM','deleteExpiredRecord','{\"duration\":90,\"tableName\":\"alarm\",\"colName\":\"event_time\",\"extras\":\"alarm_status=\'0\'\"}','0 10 0 * * ?','3','0','1','1','supervisor',1698478134841,NULL,0,'job.deleteExpiredAlarmRecordRemark'),(6,'job.deleteExpiredKpiRecord','SYSTEM','deleteExpiredRecord','{\"duration\":30,\"tableName\":\"gold_kpi\",\"colName\":\"date\"}','0 15 0 * * ?','3','0','1','1','supervisor',1698478134842,'supervisor',1700570673113,'job.deleteExpiredKpiRecordRemark'),(7,'job.backupEtcFromNE','SYSTEM','backupEtcFromNE',NULL,'0 30 0 * * ?','3','0','1','1','supervisor',1698478134843,NULL,0,'job.backupEtcFromNERemark'),(8,'job.deleteExpiredNeStateRecord','SYSTEM','deleteExpiredRecord','{\"duration\":7,\"tableName\":\"ne_state\",\"colName\":\"timestamp\"}','0 25 0 * * ?','3','0','1','1','supervisor',1698478134842,'admin',1703668901929,'job.deleteExpiredNeStateRecordRemark'),(9,'job.getStateFromNE','SYSTEM','getStateFromNE','','0/10 * * * * ?','3','0','1','0','supervisor',1698478134842,'admin',1703669877919,'job.getStateFromNERemark'),(10,'job.genNeStateAlarm','SYSTEM','genNeStateAlarm','{\"alarmID\":\"HXEMSSM10000\",\"alarmCode\":10000,\"alarmTitle\":\"The system state is abnormal\",\"neType\":\"OMC\",\"alarmType\":\"EquipmentAlarm\",\"origSeverity\": \"Major\",\"objectName\":\"EMS;SystemManagement;Heartbeat\",\"objectType\":\"SystemState\",\"specificProblem\":\"Alarm cause: the system state of target NE has not been received for {threshold} seconds\", \"specificProblemID\":\"AC10000\",\"threshold\":30}','0/5 * * * * ?','3','0','1','0','supervisor',1698478134842,'admin',1704449600201,'job.genNeStateAlarmRemark');
/*!40000 ALTER TABLE `sys_job` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2024-03-06 17:27:00
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -223,7 +223,7 @@ INSERT INTO `sys_menu` VALUES (2099, 'menu.perf', 0, 5, 'perfManage', NULL, '1',
INSERT INTO `sys_menu` VALUES (2100, 'menu.perf.task', 2099, 1, 'taskManage', 'perfManage/taskManage/index', '1', '1', 'M', '0', '1', 'perfManage:taskManage:index', 'icon-wofaqi', 'supervisor', 1700000000000, 'admin', 1713177036412, 'menu.perf.taskRemark');
INSERT INTO `sys_menu` VALUES (2101, 'menu.perf.data', 2099, 2, 'perfData', 'perfManage/perfData/index', '1', '1', 'M', '0', '1', 'perfManage:perfData:index', 'icon-soutubiao', 'supervisor', 1700000000000, 'admin', 1713177042915, 'menu.perf.dataRemark');
INSERT INTO `sys_menu` VALUES (2102, 'menu.perf.report', 2099, 3, 'perfReport', 'perfManage/perfReport/index', '1', '0', 'M', '0', '0', 'perfManage:perfReport:index', 'icon-gonggaodayi', 'supervisor', 1700000000000, NULL, 0, 'menu.perf.reportRemark');
INSERT INTO `sys_menu` VALUES (2103, 'menu.perf.threshold', 2099, 4, 'perfThreshold', 'perfManage/perfThreshold/index', '1', '0', 'M', '1', '1', 'perfManage:perfThreshold:index', 'icon-zhuanrang', 'supervisor', 1700000000000, 'admin', 1712807935215, 'menu.perf.thresholdRemark');
INSERT INTO `sys_menu` VALUES (2103, 'menu.perf.threshold', 2099, 4, 'perfThreshold', 'perfManage/perfThreshold/index', '1', '0', 'M', '0', '1', 'perfManage:perfThreshold:index', 'icon-zhuanrang', 'supervisor', 1700000000000, 'admin', 1712807935215, 'menu.perf.thresholdRemark');
INSERT INTO `sys_menu` VALUES (2104, 'menu.perf.kpi', 2099, 5, 'goldTarget', 'perfManage/goldTarget/index', '1', '1', 'M', '1', '1', 'perfManage:goldTarget:index', 'icon-soutubiao', 'supervisor', 1700000000000, NULL, 0, 'menu.perf.kpiRemark');
INSERT INTO `sys_menu` VALUES (2105, 'menu.perf.customTarget', 2099, 6, 'customTarget', 'perfManage/customTarget/index', '1', '1', 'M', '0', '0', 'perfManage:customTarget:index', 'icon-fanhui1', 'supervisor', 1700000000000, 'admin', 1712807948673, 'menu.perf.customTargetRemark');
INSERT INTO `sys_menu` VALUES (2106, 'menu.perf.set', 2099, 7, 'perfSet', 'perfManage/perfSet/index', '1', '0', 'M', '0', '0', 'perfManage:perfSet:index', 'icon-gonggao', 'supervisor', 1700000000000, NULL, 0, 'menu.perf.setRemark');

View File

@@ -0,0 +1,40 @@
/*
Navicat Premium Data Transfer
Source Server : root@192.168.2.166
Source Server Type : MariaDB
Source Server Version : 100616 (10.6.16-MariaDB-0ubuntu0.22.04.1)
Source Host : 192.168.2.166:33066
Source Schema : omc_db
Target Server Type : MariaDB
Target Server Version : 100616 (10.6.16-MariaDB-0ubuntu0.22.04.1)
File Encoding : 65001
Date: 26/04/2024 17:20:44
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for kpi_report
-- ----------------------------
CREATE TABLE IF NOT EXISTS `kpi_report` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ne_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`ne_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '',
`rm_uid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`date` date NOT NULL,
`start_time` time NULL DEFAULT NULL,
`end_time` time NULL DEFAULT NULL,
`index` smallint(6) NOT NULL,
`granularity` tinyint(4) NULL DEFAULT 60 COMMENT 'Time granualarity: 5/10/.../60/300 (second)',
`kpi_values` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
`created_at` bigint(20) NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_timestamp`(`created_at`) USING BTREE,
INDEX `idx_uid_datetime`(`rm_uid`, `date`, `start_time`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 10660 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -335,4 +335,10 @@ VALUES (
'job.genNeStateAlarmRemark'
);
UPDATE `omc_db`.`sys_job`
SET
`target_params` = '{\"duration\":1,\"tableName\":\"ne_state\",\"colName\":\"timestamp\"}'
WHERE
`job_id` = 8;
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -704,7 +704,7 @@ SET
`is_frame` = '1',
`is_cache` = '1',
`menu_type` = 'M',
`visible` = '1',
`visible` = '0',
`status` = '1',
`perms` = 'perfManage:taskManage:index',
`icon` = 'icon-wofaqi',
@@ -726,7 +726,7 @@ SET
`is_frame` = '1',
`is_cache` = '1',
`menu_type` = 'M',
`visible` = '1',
`visible` = '0',
`status` = '1',
`perms` = 'perfManage:perfData:index',
`icon` = 'icon-soutubiao',
@@ -748,7 +748,7 @@ SET
`is_frame` = '1',
`is_cache` = '0',
`menu_type` = 'M',
`visible` = '1',
`visible` = '0',
`status` = '1',
`perms` = 'perfManage:perfThreshold:index',
`icon` = 'icon-zhuanrang',

View File

@@ -186,4 +186,7 @@ ALTER TABLE `omc_db`.`mml_system`
ADD COLUMN IF NOT EXISTS `object_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'mml' AFTER `mml_display`;
ALTER TABLE `omc_db`.`ne_state`
MODIFY COLUMN `expiry_date` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' AFTER `serial_num`;
MODIFY COLUMN `expiry_date` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' AFTER `serial_num`;
ALTER TABLE `omc_db`.`alarm_forward_log`
ADD COLUMN IF NOT EXISTS `interface` varchar(16) NULL AFTER `event_time`;

View File

@@ -0,0 +1,40 @@
/*
Navicat Premium Data Transfer
Source Server : root@192.168.2.166
Source Server Type : MariaDB
Source Server Version : 100616 (10.6.16-MariaDB-0ubuntu0.22.04.1)
Source Host : 192.168.2.166:33066
Source Schema : omc_db
Target Server Type : MariaDB
Target Server Version : 100616 (10.6.16-MariaDB-0ubuntu0.22.04.1)
File Encoding : 65001
Date: 26/04/2024 17:21:10
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for kpi_report
-- ----------------------------
CREATE TABLE IF NOT EXISTS `kpi_report` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ne_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`ne_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '',
`rm_uid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`date` date NOT NULL,
`start_time` time NULL DEFAULT NULL,
`end_time` time NULL DEFAULT NULL,
`index` smallint(6) NOT NULL,
`granularity` tinyint(4) NULL DEFAULT 60 COMMENT 'Time granualarity: 5/10/.../60/300 (second)',
`kpi_values` text CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
`created_at` bigint(20) NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_timestamp`(`created_at`) USING BTREE,
INDEX `idx_uid_datetime`(`rm_uid`, `date`, `start_time`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 10660 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -335,4 +335,10 @@ VALUES (
'job.genNeStateAlarmRemark'
);
UPDATE `omc_db`.`sys_job`
SET
`target_params` = '{\"duration\":1,\"tableName\":\"ne_state\",\"colName\":\"timestamp\"}'
WHERE
`job_id` = 8;
SET FOREIGN_KEY_CHECKS = 1;

View File

@@ -703,7 +703,7 @@ SET
`is_frame` = '1',
`is_cache` = '1',
`menu_type` = 'M',
`visible` = '1',
`visible` = '0',
`status` = '1',
`perms` = 'perfManage:taskManage:index',
`icon` = 'icon-wofaqi',
@@ -725,7 +725,7 @@ SET
`is_frame` = '1',
`is_cache` = '1',
`menu_type` = 'M',
`visible` = '1',
`visible` = '0',
`status` = '1',
`perms` = 'perfManage:perfData:index',
`icon` = 'icon-soutubiao',
@@ -747,7 +747,7 @@ SET
`is_frame` = '1',
`is_cache` = '0',
`menu_type` = 'M',
`visible` = '1',
`visible` = '0',
`status` = '1',
`perms` = 'perfManage:perfThreshold:index',
`icon` = 'icon-zhuanrang',

View File

@@ -186,4 +186,7 @@ ALTER TABLE `omc_db`.`mml_system`
ADD COLUMN IF NOT EXISTS `object_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT 'mml' AFTER `mml_display`;
ALTER TABLE `omc_db`.`ne_state`
MODIFY COLUMN `expiry_date` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' AFTER `serial_num`;
MODIFY COLUMN `expiry_date` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '-' AFTER `serial_num`;
ALTER TABLE `omc_db`.`alarm_forward_log`
ADD COLUMN IF NOT EXISTS `interface` varchar(16) NULL AFTER `event_time`;

View File

@@ -142,7 +142,8 @@ func PostNeInfo(w http.ResponseWriter, r *http.Request) {
services.ResponseInternalServerError500ProcessError(w, err)
return
}
neInfo.UpdateTime = time.Now().Format(time.DateTime)
//neInfo.UpdateTime = time.Now().Format(time.DateTime)
neInfo.UpdateTime = time.Now()
log.Debug("NE info:", neInfo)
//if !config.GetYamlConfig().OMC.Chk2Ne {
@@ -166,7 +167,7 @@ func PostNeInfo(w http.ResponseWriter, r *http.Request) {
} else {
hostUri := global.CombineHostUri(neInfo.Ip, neInfo.Port)
//hostUri := fmt.Sprintf("http://%s:%v", neInfo.Ip, neInfo.Port)
apiUri := fmt.Sprintf("%s/systemManagement/v1/elementType/%s/objectType/config/omcNeConfig", config.DefaultUriPrefix, strings.ToLower(neInfo.NeType))
apiUri := fmt.Sprintf("%s/systemManagement/v1/elementType/%s/objectType/config/omcNeConfig?ne_id=%s", config.DefaultUriPrefix, strings.ToLower(neInfo.NeType), neInfo.NeId)
requestURI2NF := fmt.Sprintf("%s%s", hostUri, apiUri)
log.Debug("requestURI2NF:", requestURI2NF)
@@ -252,7 +253,7 @@ func PutNeInfo(w http.ResponseWriter, r *http.Request) {
neInfo := new(dborm.NeInfo)
_ = json.Unmarshal(body, neInfo)
neInfo.NeType = strings.ToUpper(neType)
neInfo.UpdateTime = time.Now().Format(time.DateTime)
neInfo.UpdateTime = time.Now()
log.Debug("NE info:", neInfo)
//if !config.GetYamlConfig().OMC.Chk2Ne {
@@ -276,7 +277,7 @@ func PutNeInfo(w http.ResponseWriter, r *http.Request) {
} else {
hostUri := global.CombineHostUri(neInfo.Ip, neInfo.Port)
//hostUri := fmt.Sprintf("http://%s:%v", neInfo.Ip, neInfo.Port)
apiUri := fmt.Sprintf("%s/systemManagement/v1/elementType/%s/objectType/config/omcNeConfig", config.DefaultUriPrefix, neTypeLower)
apiUri := fmt.Sprintf("%s/systemManagement/v1/elementType/%s/objectType/config/omcNeConfig?ne_id=%s", config.DefaultUriPrefix, neTypeLower, neInfo.NeId)
requestURI2NF := fmt.Sprintf("%s%s", hostUri, apiUri)
log.Debug("requestURI2NF:", requestURI2NF)

View File

@@ -42,7 +42,7 @@ func GetParamConfigFromNF(w http.ResponseWriter, r *http.Request) {
neInfo := neService.NewNeInfoImpl.SelectNeInfoByNeTypeAndNeID(neType, neId)
var response services.DataResponse
if neInfo.NeId == neId {
if neInfo.NeId == neId && neInfo.NeId != "" {
requestURI2NF := fmt.Sprintf("http://%s:%v%s", neInfo.IP, neInfo.Port, r.RequestURI)
log.Debug("requestURI2NF:", requestURI2NF)
@@ -78,7 +78,7 @@ func PostParamConfigToNF(w http.ResponseWriter, r *http.Request) {
neInfo := neService.NewNeInfoImpl.SelectNeInfoByNeTypeAndNeID(neType, neId)
if neInfo.NeId != neId {
if neInfo.NeId != neId || neInfo.NeId == "" {
log.Error("neId is empty")
services.ResponseInternalServerError500DatabaseOperationFailed(w)
return
@@ -130,7 +130,7 @@ func PutParamConfigToNF(w http.ResponseWriter, r *http.Request) {
neId := ctx.GetQuery(r, "ne_id")
neInfo := neService.NewNeInfoImpl.SelectNeInfoByNeTypeAndNeID(neType, neId)
if neInfo.NeId != neId {
if neInfo.NeId != neId || neInfo.NeId == "" {
log.Error("neId is empty")
services.ResponseInternalServerError500DatabaseOperationFailed(w)
return
@@ -183,7 +183,7 @@ func DeleteParamConfigToNF(w http.ResponseWriter, r *http.Request) {
neId := ctx.GetQuery(r, "ne_id")
neInfo := neService.NewNeInfoImpl.SelectNeInfoByNeTypeAndNeID(neType, neId)
if neInfo.NeId != neId {
if neInfo.NeId != neId || neInfo.NeId == "" {
log.Error("neId is empty")
services.ResponseInternalServerError500DatabaseOperationFailed(w)
return

View File

@@ -461,8 +461,8 @@ func PostAlarmFromNF(w http.ResponseWriter, r *http.Request) {
if err = AlarmEmailForward(&alarmData); err != nil {
log.Error("Failed to AlarmEmailForward:", err)
}
if err = AlarmForwardBySMPP(&alarmData); err != nil {
log.Error("Failed to AlarmForwardBySMPP:", err)
if err = AlarmSMSForward(&alarmData); err != nil {
log.Error("Failed to AlarmSMSForward:", err)
}
}
}
@@ -735,8 +735,8 @@ func GetAlarmFromNF(w http.ResponseWriter, r *http.Request) {
if err = AlarmEmailForward(&alarmData); err != nil {
log.Error("Failed to AlarmEmailForward:", err)
}
if err = AlarmForwardBySMPP(&alarmData); err != nil {
log.Error("Failed to AlarmForwardBySMPP:", err)
if err = AlarmSMSForward(&alarmData); err != nil {
log.Error("Failed to AlarmSMSForward:", err)
}
}
}

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"net/http"
"net/url"
"strings"
"time"
"be.ems/lib/dborm"
@@ -15,7 +16,24 @@ import (
"github.com/linxGnu/gosmpp/pdu"
)
func AlarmForwardBySMS(alarmData *Alarm) error {
func AlarmSMSForward(alarmData *Alarm) error {
switch config.GetYamlConfig().Alarm.SMProxy {
case "sms":
users, err := AlarmForwardBySMS(alarmData)
writeLog(alarmData, users, "SMS", err)
return err
case "smsc":
users, err := AlarmForwardBySMPP(alarmData)
writeLog(alarmData, users, "SMS", err)
return err
default:
users, err := AlarmForwardBySMPP(alarmData)
writeLog(alarmData, users, "SMS", err)
return err
}
}
func AlarmForwardBySMS(alarmData *Alarm) (string, error) {
log.Info("AlarmForwardBySMS processing... ")
SMSFforwardconfig := config.GetYamlConfig().Alarm.SMS
@@ -29,86 +47,69 @@ func AlarmForwardBySMS(alarmData *Alarm) error {
toUsers, err := dborm.XormGetAlarmForward("SMS")
if err != nil {
log.Error("Failed to XormGetAlarmForward:", err)
return err
return "", err
} else if toUsers == nil {
err := errors.New("not found forward phone number")
log.Error(err)
return err
return "", err
}
userList := strings.Join(*toUsers, ",")
// 短信相关参数
params := url.Values{}
params.Set("PhoneNumbers", userList)
params.Set("SignName", SMSFforwardconfig.SignName)
params.Set("TemplateCode", SMSFforwardconfig.TemplateCode)
params.Set("TemplateParam", `{"message":"alarm"}`)
// 构建请求URL
reqURL := apiURL + "?Action=SendSms&" + params.Encode()
// 创建HTTP请求
req, err := http.NewRequest("GET", reqURL, nil)
if err != nil {
log.Error("Failed to create request:", err)
return userList, err
}
for _, toUser := range *toUsers {
// 短信相关参数
params := url.Values{}
params.Set("PhoneNumbers", toUser)
params.Set("SignName", SMSFforwardconfig.SignName)
params.Set("TemplateCode", SMSFforwardconfig.TemplateCode)
params.Set("TemplateParam", `{"message":"alarm"}`)
// 添加请求头部
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Authorization", "APPCODE "+accessKeySecret)
// 构建请求URL
reqURL := apiURL + "?Action=SendSms&" + params.Encode()
// 创建HTTP请求
req, err := http.NewRequest("GET", reqURL, nil)
if err != nil {
log.Error("Failed to create request:", err)
return err
}
// 添加请求头部
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Authorization", "APPCODE "+accessKeySecret)
forwardLog := &dborm.AlarmForwardLog{
NeType: alarmData.NeType,
NeID: alarmData.NeId,
AlarmID: alarmData.AlarmId,
AlarmTitle: alarmData.AlarmTitle,
AlarmSeq: alarmData.AlarmSeq,
EventTime: alarmData.EventTime,
ToUser: toUser,
}
// 发送请求
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
operResult := fmt.Sprintf("Failed to send request:%v", err)
log.Error(operResult)
forwardLog.OperResult = operResult
affected, err := dborm.XormInsertAlarmForwardLog(forwardLog)
if err != nil && affected <= 0 {
log.Error("Failed to insert data:", err)
}
continue
}
defer resp.Body.Close()
// 解析响应
if resp.StatusCode == http.StatusOK {
operResult := "SMS sent successfully!"
log.Info(operResult)
forwardLog.OperResult = operResult
affected, err := dborm.XormInsertAlarmForwardLog(forwardLog)
if err != nil && affected <= 0 {
log.Error("Failed to insert data:", err)
continue
}
} else {
operResult := fmt.Sprintf("Failed to send SMS, StatusCode=%d", resp.StatusCode)
log.Error(operResult)
forwardLog.OperResult = operResult
affected, err := dborm.XormInsertAlarmForwardLog(forwardLog)
if err != nil && affected <= 0 {
log.Error("Failed to insert data:", err)
continue
}
}
// 发送请求
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
log.Error("Failed to send request:%v", err)
return userList, err
}
defer resp.Body.Close()
// 解析响应
switch resp.StatusCode {
case http.StatusOK, http.StatusAccepted, http.StatusNoContent, http.StatusCreated:
return userList, nil
default:
err := fmt.Errorf("Failed to send SMS: %s(Code=%d)", resp.Status, resp.StatusCode)
log.Error(err)
return userList, err
}
return nil
}
func AlarmForwardBySMPP(alarmData *Alarm) error {
func AlarmForwardBySMPP(alarmData *Alarm) (string, error) {
log.Info("AlarmForwardBySMPP processing... ")
toUsers, err := dborm.XormGetAlarmForward("SMS")
if err != nil {
log.Error("Failed to XormGetAlarmForward:", err)
return "", err
} else if toUsers == nil {
err := errors.New("not found forward phone number")
log.Error(err)
return "", err
}
userList := strings.Join(*toUsers, ",")
auth := gosmpp.Auth{
SMSC: config.GetYamlConfig().Alarm.SMSC.Addr,
SystemID: config.GetYamlConfig().Alarm.SMSC.SystemID,
@@ -142,48 +143,49 @@ func AlarmForwardBySMPP(alarmData *Alarm) error {
}, -1)
if err != nil {
log.Error("Failed to create SMPP new session:", err)
return err
return userList, err
}
defer func() {
_ = trans.Close()
}()
toUsers, err := dborm.XormGetAlarmForward("SMS")
if err != nil {
log.Error("Failed to XormGetAlarmForward:", err)
return err
} else if toUsers == nil {
err := errors.New("not found forward phone number")
log.Error(err)
return err
}
// sending SMS(s)
for _, toUser := range *toUsers {
forwardLog := &dborm.AlarmForwardLog{
NeType: alarmData.NeType,
NeID: alarmData.NeId,
AlarmID: alarmData.AlarmId,
AlarmTitle: alarmData.AlarmTitle,
AlarmSeq: alarmData.AlarmSeq,
EventTime: alarmData.EventTime,
ToUser: toUser,
}
message := "Alarm Notification: " + alarmData.AlarmTitle + " from " + alarmData.NeType + " " + alarmData.NeId + " at " + alarmData.EventTime
if err = trans.Transceiver().Submit(newSubmitSM(toUser, message)); err != nil {
operResult := fmt.Sprintf("Failed to submit short message:%v", err)
log.Error(operResult)
forwardLog.OperResult = operResult
} else {
operResult := "SMS sent successfully!"
log.Trace(operResult)
forwardLog.OperResult = operResult
}
// var results []string
// for _, toUser := range *toUsers {
message := "Alarm Notification: " + alarmData.AlarmTitle + " from " + alarmData.NeType + " " + alarmData.NeId + " at " + alarmData.EventTime
if err = trans.Transceiver().Submit(newSubmitSM(userList, message)); err != nil {
// result := fmt.Sprintf("Failed to submit %s hort message:%s", toUser, err.Error())
// results = append(results, result)
log.Error("Failed to submit hort message:", err)
return userList, err
}
// }
return userList, nil
}
affected, err := dborm.XormInsertAlarmForwardLog(forwardLog)
if err != nil && affected <= 0 {
log.Error("Failed to insert data:", err)
continue
}
func writeLog(alarmData *Alarm, toUser, forwardBy string, err error) error {
var result string
if err == nil {
result = "SMS sent successfully"
} else {
result = err.Error()
}
forwardLog := &dborm.AlarmForwardLog{
NeType: alarmData.NeType,
NeID: alarmData.NeId,
AlarmID: alarmData.AlarmId,
AlarmTitle: alarmData.AlarmTitle,
AlarmSeq: alarmData.AlarmSeq,
EventTime: alarmData.EventTime,
Interface: forwardBy,
ToUser: toUser,
OperResult: result,
}
affected, err := dborm.XormInsertAlarmForwardLog(forwardLog)
if err != nil && affected <= 0 {
log.Error("Failed to insert data:", err)
return err
}
return nil
}

View File

@@ -8,6 +8,7 @@ import (
"math"
"net/http"
"strconv"
"strings"
"time"
"be.ems/lib/dborm"
@@ -63,6 +64,26 @@ type GoldKpi struct {
Timestamp string `json:"timestamp"`
}
type KpiData struct {
ID int `json:"id" xorm:"pk 'id' '<-' autoincr"`
NEType string `json:"neType" xorm:"ne_type"`
NEName string `json:"neName" xorm:"ne_name"`
RmUid string `json:"rmUid" xorm:"rm_uid"`
Date string `json:"date" xorm:"date"`
StartTime time.Time `json:"startTime" xorm:"start_time"`
EndTime time.Time `json:"endTime" xorm:"end_time"`
Index int `json:"index" xorm:"index"`
Granularity int8 `json:"granularity" xorm:"granularity"`
KPIValues []KPIVal `json:"kpiValues" xorm:"json 'kpi_values'"`
//CreatedAt int64 `json:"createdAt" xorm:"created 'created_at'"`
CreatedAt int64 `json:"createdAt" xorm:"'created_at'"`
}
type KPIVal struct {
KPIID string `json:"kpi_id" xorm:"kpi_id"`
Value int64 `json:"value" xorm:"value"`
Err string `json:"err" xorm:"err"`
}
var (
// performance management
PerformanceUri = config.DefaultUriPrefix + "/performanceManagement/{apiVersion}/elementType/{elementTypeValue}/objectType/kpiReport/{index}"
@@ -124,6 +145,21 @@ func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName, dbParam st
}
xEngine = DbClient.XEngine
// exist, err := xEngine.IsTableExist("kpi_report")
// if err != nil {
// log.Error("Failed to IsTableExist:", err)
// return err
// }
// if exist {
// // 复制表结构到新表
// sql := fmt.Sprintf("CREATE TABLE IF NOT EXISTS `%s` AS SELECT * FROM kpi_report WHERE 1=0", "kpi_report_amf")
// _, err := xEngine.Exec(sql)
// if err != nil {
// log.Error("Failed to Exec:", err)
// return err
// }
// }
return nil
}
@@ -204,12 +240,34 @@ func PostKPIReportFromNF(w http.ResponseWriter, r *http.Request) {
"startIndex": goldKpi.Index,
"timeGroup": goldKpi.StartTime,
}
// insert into new kpi_report_xxx table
kpiData := new(KpiData)
kpiData.Date = goldKpi.Date
kpiData.Index = goldKpi.Index
st, _ := time.ParseInLocation(time.RFC3339Nano, kpiReport.Task.Period.StartTime, time.Local)
et, _ := time.ParseInLocation(time.RFC3339Nano, kpiReport.Task.Period.EndTime, time.Local)
// kpiData.StartTime = goldKpi.StartTime
// kpiData.EndTime = goldKpi.EndTime
kpiData.StartTime = st
kpiData.EndTime = et
kpiData.Granularity = goldKpi.Granularity
kpiData.NEName = goldKpi.NEName
kpiData.NEType = goldKpi.NEType
kpiData.RmUid = goldKpi.RmUid
kpiVal := new(KPIVal)
kpiData.CreatedAt = time.Now().UnixMilli()
for _, k := range kpiReport.Task.NE.KPIs {
kpiEvent[k.KPIID] = k.Value // kip_id
goldKpi.KpiId = k.KPIID
goldKpi.Value = k.Value
goldKpi.Error = k.Err
log.Trace("goldKpi:", goldKpi)
kpiVal.KPIID = k.KPIID
kpiVal.Value = int64(k.Value)
kpiVal.Err = k.Err
kpiData.KPIValues = append(kpiData.KPIValues, *kpiVal)
//log.Trace("goldKpi:", goldKpi)
// 启动事务
err := session.Begin()
@@ -243,13 +301,22 @@ func PostKPIReportFromNF(w http.ResponseWriter, r *http.Request) {
}
}
// insert kpi_report table, no session
tableName := "kpi_report_" + strings.ToLower(kpiReport.Task.NE.NeType)
affected, err := xEngine.Table(tableName).Insert(kpiData)
if err != nil && affected <= 0 {
log.Errorf("Failed to insert %s:%v", tableName, err)
services.ResponseInternalServerError500ProcessError(w, err)
return
}
// 推送到ws订阅组
wsService.NewWSSendImpl.ByGroupID(wsService.GROUP_KPI, kpiEvent)
if goldKpi.NEType == "UPF" {
wsService.NewWSSendImpl.ByGroupID(wsService.GROUP_KPI_UPF, kpiEvent)
}
services.ResponseStatusOK200Null(w)
services.ResponseStatusOK204NoContent(w)
}
type MeasureTask struct {

View File

@@ -182,20 +182,20 @@ func InsertDataWithJson(insertData interface{}) (int64, error) {
}
type NeInfo struct {
Id int `json:"id" xorm:"pk 'id' autoincr"`
NeType string `json:"neType" xorm:"ne_type"`
NeId string `json:"neId" xorm:"ne_id"` // neUID/rmUID 网元唯一标识
RmUID string `json:"rmUid" xorm:"rm_uid"` // neUID/rmUID网元UID
NeName string `json:"neName" xorm:"ne_name"` // NeName/UserLabel 网元名称/网元设备友好名称
Ip string `json:"ip" xorm:"ip"`
Port string `json:"port" xorm:"port"`
PvFlag string `json:"pvFlag" xorm:"pv_flag"` // 网元虚实性标识 VNF/PNF: 虚拟/物理
NeAddress string `json:"neAddress" xorm:"ne_address"` // 只对PNF
Province string `json:"province" xorm:"province"` // 网元所在省份
VendorName string `json:"vendorName" xorm:"vendor_name"` // 厂商名称
Dn string `json:"dn" xorm:"dn"` // 网络标识
Status int `json:"status" xorm:"status"`
UpdateTime string `json:"-" xorm:"-"`
Id int `json:"id" xorm:"pk 'id' autoincr"`
NeType string `json:"neType" xorm:"ne_type"`
NeId string `json:"neId" xorm:"ne_id"` // neUID/rmUID 网元唯一标识
RmUID string `json:"rmUid" xorm:"rm_uid"` // neUID/rmUID网元UID
NeName string `json:"neName" xorm:"ne_name"` // NeName/UserLabel 网元名称/网元设备友好名称
Ip string `json:"ip" xorm:"ip"`
Port string `json:"port" xorm:"port"`
PvFlag string `json:"pvFlag" xorm:"pv_flag"` // 网元虚实性标识 VNF/PNF: 虚拟/物理
NeAddress string `json:"neAddress" xorm:"ne_address"` // 只对PNF
Province string `json:"province" xorm:"province"` // 网元所在省份
VendorName string `json:"vendorName" xorm:"vendor_name"` // 厂商名称
Dn string `json:"dn" xorm:"dn"` // 网络标识
Status int `json:"status" xorm:"status"`
UpdateTime time.Time `json:"updateTime" xorm:"<-"`
}
func XormGetMySQLVersion() (string, error) {
@@ -1453,6 +1453,15 @@ func XormDeleteDataByWhere(where, table string) (int64, error) {
return affected, nil
}
func XormDeleteDataByWhereNoSession(where, table string) (int64, error) {
affected, err := DbClient.XEngine.Table(table).Where(where).Delete()
if err != nil {
log.Error("Failed to Delete:", err)
return 0, err
}
return affected, nil
}
func XormDeleteDataById(id int, table string) (int64, error) {
log.Debug("XormDeleteDataByWhere processing... ")
@@ -1634,9 +1643,10 @@ type AlarmForwardLog struct {
AlarmTitle string `json:"alarmTitle" xorm:"alarm_title"`
AlarmSeq int `json:"alarmSeq" xorm:"alarm_seq"`
EventTime string `json:"eventTime" xorm:"event_time"`
Interface string `json:"interface" xorm:"interface"`
ToUser string `json:"toUser" xorm:"to_user"`
OperResult string `json:"operResult" xorm:"oper_result"`
LogTime string `json:"-" xorm:"-"`
LogTime string `json:"logTime" xorm:"<-"`
}
func XormInsertAlarmForwardLog(logData *AlarmForwardLog) (int64, error) {
@@ -1671,7 +1681,7 @@ func XormInsertSystemLog(logData *SystemLog) (int64, error) {
return affected, err
}
type permission struct {
type Permission struct {
ID int `json:"-" xorm:"pk 'id' autoincr"`
PermissionName string `json:"permissionName"`
Method string `json:"method"`

View File

@@ -3,7 +3,7 @@
ProjectL = omc
ProjectU = OMC
PROJECT = $(ProjectL)
VERSION = 2.2404.4
VERSION = 2.2404.6
RelDate = `date +%Y%m%d`
Release = $(RelDate)
RelVer = $(VERSION)-$(RelDate)

View File

@@ -15,17 +15,22 @@ case "$1" in
upgrade)
echo "Upgrade database ${DBNAME}"
for SQL in ${UpgradeSQLDir}/*.sql; do
echo "Execute SQL script: ${SQL} ..."
echo -n "Execute SQL script: ${SQL} ..."
mysql -u${USER} -p${PASSWORD} -P ${PORT} --protocol tcp -D ${DBNAME} < ${SQL};
if [ $? = 0 ]; then
echo "done"
fi
done
;;
upgvue3)
echo "Upgrade to vue3 database ${DBNAME}"
for SQL in ${Upgvue3SQLDir}/*.sql; do
echo "Execute SQL script: ${SQL} ..."
mysql -u${USER} -p${PASSWORD} -P ${PORT} --protocol tcp -D ${DBNAME} < ${SQL};
echo -n "Execute SQL script: ${SQL} ..."
mysql -u${USER} -p${PASSWORD} -P ${PORT} --protocol tcp -D ${DBNAME} < ${SQL};
if [ $? = 0 ]; then
echo "done"
fi
done
;;
@@ -35,8 +40,11 @@ case "$1" in
echo "Create database ${DBNAME} if not exist"
mysql -u${USER} -p${PASSWORD} -P $PORT --protocol tcp -e "${create_db_sql}"
for SQL in ${InstallSQLDir}/*.sql; do
echo "Execute SQL script: ${SQL} ..."
echo -n "Execute SQL script: ${SQL} ..."
mysql -u${USER} -p${PASSWORD} -P ${PORT} --protocol tcp -D ${DBNAME} < ${SQL};
if [ $? = 0 ]; then
echo "done"
fi
done
;;
@@ -51,8 +59,11 @@ case "$1" in
echo "Upgrade database ${DBNAME}"
for SQL in ${UpgradeSQLDir}/*.sql; do
echo "Execute SQL script: ${SQL} ..."
mysql -u${USER} -p${PASSWORD} -P ${PORT} --protocol tcp -D ${DBNAME} < ${SQL};
echo -n "Execute SQL script: ${SQL} ..."
mysql -u${USER} -p${PASSWORD} -P ${PORT} --protocol tcp -D ${DBNAME} < ${SQL};
if [ $? = 0 ]; then
echo "done"
fi
done
break
@@ -63,8 +74,11 @@ case "$1" in
echo "Upgrade to vue3 database ${DBNAME}"
for SQL in ${Upgvue3SQLDir}/*.sql; do
echo "Execute SQL script: ${SQL} ..."
mysql -u${USER} -p${PASSWORD} -P ${PORT} --protocol tcp -D ${DBNAME} < ${SQL};
echo -n "Execute SQL script: ${SQL} ..."
mysql -u${USER} -p${PASSWORD} -P ${PORT} --protocol tcp -D ${DBNAME} < ${SQL};
if [ $? = 0 ]; then
echo "done"
fi
done
break
@@ -78,8 +92,11 @@ case "$1" in
mysql -u${USER} -p${PASSWORD} -P $PORT --protocol tcp -e "${create_db_sql}"
for SQL in ${InstallSQLDir}/*.sql; do
echo "Execute SQL script: ${SQL} ..."
mysql -u${USER} -p${PASSWORD} -P ${PORT} --protocol tcp -D ${DBNAME} < ${SQL};
echo -n "Execute SQL script: ${SQL} ..."
mysql -u${USER} -p${PASSWORD} -P ${PORT} --protocol tcp -D ${DBNAME} < ${SQL};
if [ $? = 0 ]; then
echo "done"
fi
done
break
@@ -97,3 +114,15 @@ case "$1" in
done
;;
esac
# create kpi_report table with ne_type, exp: kpi_report_amf
ne_types=$(mysql -u${USER} -p${PASSWORD} -P ${PORT} --protocol tcp -D ${DBNAME} -se "SELECT DISTINCT LOWER(ne_type) FROM kpi_title")
for ne_type in ${ne_types}; do
TABLE_NAME="kpi_report_${ne_type}"
SQL="CREATE TABLE IF NOT EXISTS ${TABLE_NAME} AS SELECT * FROM kpi_report WHERE 1=0"
echo -n "Create table: ${TABLE_NAME} ..."
mysql -u${USER} -p${PASSWORD} -P ${PORT} --protocol tcp -D ${DBNAME} -e "${SQL}";
if [ $? = 0 ]; then
echo "done"
fi
done

View File

@@ -2,7 +2,7 @@
ProcList="restagent crontask sshsvc captrace data2html"
ProjectL=omc
VERSION=2.2404.4
VERSION=2.2404.6
RelDate=`date +%Y%m%d`
Release=${RelDate}
RelVer=${VERSION}-${RelDate}

View File

@@ -77,7 +77,8 @@ type YamlConfig struct {
} `yaml:"omc"`
Alarm struct {
ForwardAlarm bool `yaml:"forwardAlarm"`
ForwardAlarm bool `yaml:"forwardAlarm"`
SMProxy string `yaml:"smProxy"`
Email struct {
Smtp string `yaml:"smtp"`
Port uint16 `yaml:"port"`

View File

@@ -127,7 +127,8 @@ omc:
# Alarm module setting
# Forward interface:
# email/sms
# email/sms
# smProxy: sms(Short Message Service)/smsc(SMS Centre)
alarm:
forwardAlarm: true
email:
@@ -137,8 +138,9 @@ alarm:
password: "1000smtp@omc!"
# TLS skip verify: true/false
tlsSkipVerify: true
smProxy: smsc
sms:
apiURL: http://smsc.xxx.com.cn/
apiURL: http://smsc.xxx.com/
accessKeyID: xxxx
accessKeySecret: xxxx
signName: xxx SMSC

View File

@@ -1,7 +1,7 @@
# Makefile for rest agent project
PROJECT = OMC
VERSION = 2.2404.4
VERSION = 2.2404.6
PLATFORM = amd64
ARMPLATFORM = aarch64
BUILDDIR = ../../build

View File

@@ -1,7 +1,7 @@
# 项目信息
framework:
name: "CN EMS"
version: "2.2404.4"
version: "2.2404.6"
# 应用服务配置
server:

View File

@@ -25,8 +25,9 @@ type BarProcessor struct {
type BarParams struct {
Duration int `json:"duration"`
TableName string `json:"tableName"`
ColName string `json:"colName"` // column name of time string
Extras string `json:"extras"` // extras condition for where
ColName string `json:"colName"` // column name of time string
Extras string `json:"extras"` // extras condition for where
SessFlag bool `json:"sessFlag"` // session flag, true: session model, false: no session
}
func (s *BarProcessor) Execute(data any) (any, error) {
@@ -74,10 +75,19 @@ func (s *BarProcessor) Execute(data any) (any, error) {
where = fmt.Sprintf("NOW()>ADDDATE(`%s`,interval %d day) and %s", params.ColName, params.Duration, params.Extras)
}
affected, err := dborm.XormDeleteDataByWhere(where, params.TableName)
if err != nil {
// panic(fmt.Sprintf("Failed to XormDeleteDataByWhere:%v", err))
return nil, err
var affected int64 = 0
if params.SessFlag {
affected, err = dborm.XormDeleteDataByWhere(where, params.TableName)
if err != nil {
// panic(fmt.Sprintf("Failed to XormDeleteDataByWhere:%v", err))
return nil, err
}
} else {
affected, err = dborm.XormDeleteDataByWhereNoSession(where, params.TableName)
if err != nil {
// panic(fmt.Sprintf("Failed to XormDeleteDataByWhere:%v", err))
return nil, err
}
}
// 返回结果,用于记录执行结果

View File

@@ -121,7 +121,7 @@ func (s *BarProcessor) Execute(data any) (any, error) {
}
if len(*neState) == 0 {
log.Warn("Not found record in ne_state:")
continue
//continue
}
//log.Debug("neState:", *neState)
@@ -150,7 +150,7 @@ func (s *BarProcessor) Execute(data any) (any, error) {
var timestamp string
if len(*neState) == 0 {
log.Infof("Not found ne_state neType:%s, neId:%s", ne.NeType, ne.NeId)
timestamp = ne.UpdateTime
timestamp = ne.UpdateTime.Format(time.DateTime)
} else {
timestamp = (*neState)[0]["timestamp"]
}
@@ -208,6 +208,7 @@ func (s *BarProcessor) Execute(data any) (any, error) {
log.Debug("requestURL: POST ", requestURL)
response, err = client.R().
EnableTrace().
//SetHeaders(map[string]string{tokenConst.HEADER_KEY: r.Header.Get(tokenConst.HEADER_KEY)}).
SetHeaders(map[string]string{"User-Agent": config.GetDefaultUserAgent()}).
SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}).
SetBody(body).

View File

@@ -40,7 +40,7 @@ func (r *NeInfoImpl) SelectNeInfoByNeTypeAndNeID(neType, neID string) model.NeIn
}
} else {
neInfo = r.neInfoRepository.SelectNeInfoByNeTypeAndNeID(neType, neID)
if neInfo.NeId == neID {
if neInfo.ID != "" && neInfo.NeId == neID {
redis.Del("", key)
values, _ := json.Marshal(neInfo)
redis.Set("", key, string(values))
@@ -55,7 +55,7 @@ func (r *NeInfoImpl) RefreshByNeTypeAndNeID(neType, neID string) model.NeInfo {
key := fmt.Sprintf("%s%s:%s", cachekey.NE_KEY, strings.ToUpper(neType), neID)
redis.Del("", key)
neInfo = r.neInfoRepository.SelectNeInfoByNeTypeAndNeID(neType, neID)
if neInfo.NeId == neID {
if neInfo.ID != "" && neInfo.NeId == neID {
values, _ := json.Marshal(neInfo)
redis.Set("", key, string(values))
}

View File

@@ -143,7 +143,8 @@ func (s *TcpdumpImpl) DumpUPF(neType, neId, cmdStr string) (string, string, erro
timeStr := date.ParseDateToStr(time.Now(), date.YYYYMMDDHHMMSS)
fileName := fmt.Sprintf("%s_%s", timeStr, neTypeID)
// UPF标准版本telnet脚本
scriptStr := "set pcapCmd [lindex $argv 0]\nspawn telnet localhost 5002\nexpect \"upfd1# \"\nsend \"$pcapCmd\\n\"\nexpect \"upfd1# \"\nsend \"quit\\n\"\nexpect \"eof\""
scriptStr := "set pcapCmd [lindex $argv 0]\nspawn telnet " + neInfo.IP + " 5002\nexpect \"upfd1# \"\nsend \"$pcapCmd\\n\"\nexpect \"upfd1# \"\nsend \"quit\\n\"\nexpect \"eof\""
// scriptStr := "set pcapCmd [lindex $argv 0]\nspawn telnet localhost 5002\nexpect \"upfd1# \"\nsend \"$pcapCmd\\n\"\nexpect \"upfd1# \"\nsend \"quit\\n\"\nexpect \"eof\""
writePcapFile := fmt.Sprintf("echo '%s' > pcapUPF.sh\n %s chmod +x pcapUPF.sh", scriptStr, withSudo)
writeLogFile := fmt.Sprintf("> %s.log 2>&1 \ncat %s.log", fileName, fileName)

View File

@@ -1,7 +1,7 @@
# Makefile for OMC-OMC-crontask project
PROJECT = OMC
VERSION = 2.2404.4
VERSION = 2.2404.6
LIBDIR = be.ems/lib
BINNAME = sshsvc