Merge remote-tracking branch 'origin/main' into lichang
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# Makefile for rest agent project
|
||||
|
||||
PROJECT = OMC
|
||||
VERSION = 2.2405.1
|
||||
VERSION = 2.2405.2
|
||||
PLATFORM = amd64
|
||||
ARMPLATFORM = aarch64
|
||||
BUILDDIR = ../../build
|
||||
|
||||
@@ -839,7 +839,7 @@
|
||||
"end": "(Number of results = %d)\n\n"
|
||||
}
|
||||
|
||||
"northbound_cm": {
|
||||
"nbi_cm": {
|
||||
"retFmt": "GetDB",
|
||||
"retMsg": "RetCode = %d operation succeeded\n\n",
|
||||
"errMsg": "ErrorCode = %d operation failed: %s\n\n",
|
||||
|
||||
@@ -211,18 +211,18 @@ func XormGetNorthboundPm(date string, index int, neType string, pms *[]Northboun
|
||||
log.Debug("XormGetNorthboundPm processing... ")
|
||||
|
||||
pm := new(NorthboundPm)
|
||||
rows, err := dbClient.xEngine.Table("northbound_pm").
|
||||
rows, err := dbClient.xEngine.Table("nbi_pm").
|
||||
Where("`ne_type` = ? AND `date` = ? AND `index` = ?", neType, date, index).
|
||||
Rows(pm)
|
||||
if err != nil {
|
||||
log.Error("Failed to get table northbound_pm from database:", err)
|
||||
log.Error("Failed to get table nbi_pm from database:", err)
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
err := rows.Scan(pm)
|
||||
if err != nil {
|
||||
log.Error("Failed to get table northbound_pm from database:", err)
|
||||
log.Error("Failed to get table nbi_pm from database:", err)
|
||||
return nil, err
|
||||
}
|
||||
*pms = append(*pms, *pm)
|
||||
|
||||
@@ -82,7 +82,7 @@ func (t *TaskFunc) GenNFPMXmlFile(neType string) error {
|
||||
var pmResults []NorthboundPm
|
||||
_, err = XormGetNorthboundPm(date, index, neType, &pmResults)
|
||||
if err != nil {
|
||||
log.Error("Failed to get northbound_pm:", err)
|
||||
log.Error("Failed to get nbi_pm:", err)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Makefile for OMC-OMC-crontask project
|
||||
|
||||
PROJECT = OMC
|
||||
VERSION = 2.2405.1
|
||||
VERSION = 2.2405.2
|
||||
LIBDIR = be.ems/lib
|
||||
BINNAME = crontask
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Makefile for rest agent project
|
||||
|
||||
PROJECT = OMC
|
||||
VERSION = 2.2405.1
|
||||
VERSION = 2.2405.2
|
||||
RelDate = `date +%Y%m%d`
|
||||
Release = $(RelDate)
|
||||
RelVer = $(VERSION)-$(RelDate)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
Target Server Version : 100338 (10.3.38-MariaDB)
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 19/04/2024 15:26:46
|
||||
Date: 14/05/2024 11:57:19
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,53 +1,81 @@
|
||||
-- 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 `trace_info`
|
||||
--
|
||||
Target Server Type : MariaDB
|
||||
Target Server Version : 100338 (10.3.38-MariaDB)
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 14/05/2024 15:00:46
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
SET FOREIGN_KEY_CHECKS = 0;
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for trace_info
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `trace_info`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `trace_info` (
|
||||
`ne_type` varchar(32) NOT NULL,
|
||||
CREATE TABLE `trace_info` (
|
||||
`ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
|
||||
`interface` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
|
||||
`message_type` tinyint(4) NOT NULL,
|
||||
`message_title` varchar(64) DEFAULT NULL,
|
||||
PRIMARY KEY (`ne_type`,`interface`,`message_type`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
`message_title` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`ne_type`, `interface`, `message_type`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
--
|
||||
-- Dumping data for table `trace_info`
|
||||
--
|
||||
-- ----------------------------
|
||||
-- Records of trace_info
|
||||
-- ----------------------------
|
||||
INSERT INTO `trace_info` VALUES ('AMF', 'N1', 1, NULL);
|
||||
INSERT INTO `trace_info` VALUES ('AMF', 'N11', 1, NULL);
|
||||
INSERT INTO `trace_info` VALUES ('AMF', 'N12', 1, NULL);
|
||||
INSERT INTO `trace_info` VALUES ('AMF', 'N14', 1, NULL);
|
||||
INSERT INTO `trace_info` VALUES ('AMF', 'N15', 1, NULL);
|
||||
INSERT INTO `trace_info` VALUES ('AMF', 'N2', 1, NULL);
|
||||
INSERT INTO `trace_info` VALUES ('AMF', 'N8', 1, NULL);
|
||||
INSERT INTO `trace_info` VALUES ('AUSF', 'N12', 1, 'Nausf_AUTH_Post ue-authentications');
|
||||
INSERT INTO `trace_info` VALUES ('AUSF', 'N12', 2, 'Nausf_AUTH_Put 5g-aka-confirmation');
|
||||
INSERT INTO `trace_info` VALUES ('AUSF', 'N12', 3, 'Nausf_AUTH_Delete 5g-aka-confirmation');
|
||||
INSERT INTO `trace_info` VALUES ('AUSF', 'N12', 4, 'Nausf_AUTH_Post eap-session');
|
||||
INSERT INTO `trace_info` VALUES ('AUSF', 'N12', 5, 'Nausf_AUTH_Delete eap-session');
|
||||
INSERT INTO `trace_info` VALUES ('SMF', 'N10', 1, NULL);
|
||||
INSERT INTO `trace_info` VALUES ('SMF', 'N11', 1, NULL);
|
||||
INSERT INTO `trace_info` VALUES ('SMF', 'N4', 1, NULL);
|
||||
INSERT INTO `trace_info` VALUES ('SMF', 'N7', 1, NULL);
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N10', 1, 'Nudm_SDM_Get sm-data');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N10', 2, 'Nudm_SDM_Post sdm-subscriptions');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N10', 3, 'Nudm_SDM_Patch sdm-subscriptions');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N10', 4, 'Nudm_SDM_Delete sdm-subscriptions');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N10', 5, 'Nudm_SDM_Get id-translation-result');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N10', 6, 'Nudm_UECM_Get smf-registrations');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N10', 7, 'Nudm_UECM_Put smf-registrations');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N10', 8, 'Nudm_UECM_Patch smf-3gpp-access');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N10', 9, 'Nudm_UECM_Get smf-3gpp-access');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N10', 10, 'Nudm_UECM_Delete smf-3gpp-access');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N13', 1, 'Nudm_UEAU_Post generate-auth-data');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N13', 2, 'Nudm_UEAU_Post auth-events');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N8', 1, 'Nudm_SDM_Get supi');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N8', 2, 'Nudm_SDM_Get nssai');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N8', 3, 'Nudm_SDM_Get am-data');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N8', 4, 'Nudm_SDM_Put am-data cag-ack');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N8', 5, 'Nudm_SDM_Get smf-select-data');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N8', 6, 'Nudm_SDM_Post sdm-subscriptions');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N8', 7, 'Nudm_SDM_Patch sdm-subscriptions');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N8', 8, 'Nudm_SDM_Delete sdm-subscriptions');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N8', 9, 'Nudm_SDM_Get id-translation-result');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N8', 10, 'Nudm_UECM_Put amf-3gpp-access');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N8', 11, 'Nudm_UECM_Patch amf-3gpp-access');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N8', 12, 'Nudm_UECM_Get amf-3gpp-access');
|
||||
INSERT INTO `trace_info` VALUES ('UDM', 'N8', 13, 'Namf_Callback Deregistraion');
|
||||
INSERT INTO `trace_info` VALUES ('UPF', 'N3', 1, NULL);
|
||||
INSERT INTO `trace_info` VALUES ('UPF', 'N4', 1, NULL);
|
||||
INSERT INTO `trace_info` VALUES ('UPF', 'N6', 1, NULL);
|
||||
INSERT INTO `trace_info` VALUES ('UPF', 'N9', 1, NULL);
|
||||
|
||||
LOCK TABLES `trace_info` WRITE;
|
||||
/*!40000 ALTER TABLE `trace_info` DISABLE KEYS */;
|
||||
INSERT INTO `trace_info` VALUES ('AMF','N1',1,NULL),('AMF','N11',1,NULL),('AMF','N12',1,NULL),('AMF','N14',1,NULL),('AMF','N15',1,NULL),('AMF','N2',1,NULL),('AMF','N8',1,NULL),('AUSF','N12',1,'Nausf_AUTH_Post ue-authentications'),('AUSF','N12',2,'Nausf_AUTH_Put 5g-aka-confirmation'),('AUSF','N12',3,'Nausf_AUTH_Delete 5g-aka-confirmation'),('AUSF','N12',4,'Nausf_AUTH_Post eap-session'),('AUSF','N12',5,'Nausf_AUTH_Delete eap-session'),('SMF','N10',1,NULL),('SMF','N11',1,NULL),('SMF','N4',1,NULL),('SMF','N7',1,NULL),('UDM','N10',1,'Nudm_SDM_Get sm-data'),('UDM','N10',2,'Nudm_SDM_Post sdm-subscriptions'),('UDM','N10',3,'Nudm_SDM_Patch sdm-subscriptions'),('UDM','N10',4,'Nudm_SDM_Delete sdm-subscriptions'),('UDM','N10',5,'Nudm_SDM_Get id-translation-result'),('UDM','N10',6,'Nudm_UECM_Get smf-registrations'),('UDM','N10',7,'Nudm_UECM_Put smf-registrations'),('UDM','N10',8,'Nudm_UECM_Patch smf-3gpp-access'),('UDM','N10',9,'Nudm_UECM_Get smf-3gpp-access'),('UDM','N10',10,'Nudm_UECM_Delete smf-3gpp-access'),('UDM','N13',1,'Nudm_UEAU_Post generate-auth-data'),('UDM','N13',2,'Nudm_UEAU_Post auth-events'),('UDM','N8',1,'Nudm_SDM_Get supi'),('UDM','N8',2,'Nudm_SDM_Get nssai'),('UDM','N8',3,'Nudm_SDM_Get am-data'),('UDM','N8',4,'Nudm_SDM_Put am-data cag-ack'),('UDM','N8',5,'Nudm_SDM_Get smf-select-data'),('UDM','N8',6,'Nudm_SDM_Post sdm-subscriptions'),('UDM','N8',7,'Nudm_SDM_Patch sdm-subscriptions'),('UDM','N8',8,'Nudm_SDM_Delete sdm-subscriptions'),('UDM','N8',9,'Nudm_SDM_Get id-translation-result'),('UDM','N8',10,'Nudm_UECM_Put amf-3gpp-access'),('UDM','N8',11,'Nudm_UECM_Patch amf-3gpp-access'),('UDM','N8',12,'Nudm_UECM_Get amf-3gpp-access'),('UDM','N8',13,'Namf_Callback Deregistraion'),('UPF','N3',1,NULL),('UPF','N4',1,NULL),('UPF','N6',1,NULL),('UPF','N9',1,NULL);
|
||||
/*!40000 ALTER TABLE `trace_info` 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:05
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
@@ -65,16 +65,16 @@ type GoldKpi struct {
|
||||
}
|
||||
|
||||
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'"`
|
||||
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 string `json:"startTime" xorm:"start_time"`
|
||||
EndTime string `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'"`
|
||||
}
|
||||
@@ -190,7 +190,7 @@ func GetDateTimeFromTimeString(fmtString string, timeString string) string {
|
||||
return t.Format(global.DateTime)
|
||||
}
|
||||
|
||||
// process alarm post message from NFs
|
||||
// process KPI report post message from NFs
|
||||
func PostKPIReportFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
log.Debug("PostKPIReportFromNF processing... ")
|
||||
|
||||
@@ -202,6 +202,91 @@ func PostKPIReportFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// body, err := io.ReadAll(io.LimitReader(r.Body, global.RequestBodyMaxLen))
|
||||
body, err := io.ReadAll(io.LimitReader(r.Body, global.RequestBodyMaxLen))
|
||||
if err != nil {
|
||||
log.Error("Faile to io.ReadAll: ", err)
|
||||
services.ResponseNotFound404UriNotExist(w, r)
|
||||
return
|
||||
}
|
||||
//log.Trace("Request body:", string(body))
|
||||
kpiReport := new(KpiReport)
|
||||
_ = json.Unmarshal(body, &kpiReport)
|
||||
//log.Trace("kpiReport:", kpiReport)
|
||||
|
||||
layout := time.RFC3339Nano
|
||||
//kpiDate := GetDateFromTimeString(layout, kpiReport.Task.Period.StartTime)
|
||||
kpiIndex, _ := strconv.Atoi(vars["index"])
|
||||
startTime := global.GetFmtTimeString(layout, kpiReport.Task.Period.StartTime, time.DateTime)
|
||||
endTime := global.GetFmtTimeString(layout, kpiReport.Task.Period.EndTime, time.DateTime)
|
||||
// get time granularity from startTime and endTime
|
||||
seconds, _ := global.GetSecondDuration(startTime, endTime)
|
||||
var granularity int8 = 60
|
||||
if seconds != 0 && seconds <= math.MaxInt8 && seconds >= math.MinInt8 {
|
||||
granularity = int8(seconds)
|
||||
}
|
||||
|
||||
// 黄金指标事件对象
|
||||
kpiEvent := map[string]any{
|
||||
// kip_id ...
|
||||
"neType": kpiReport.Task.NE.NeType,
|
||||
"neName": kpiReport.Task.NE.NEName,
|
||||
"startIndex": kpiIndex,
|
||||
"timeGroup": startTime,
|
||||
}
|
||||
// insert into new kpi_report_xxx table
|
||||
kpiData := new(KpiData)
|
||||
kpiData.Date = startTime
|
||||
kpiData.Index = kpiIndex
|
||||
//stime, _ := time.ParseInLocation(time.RFC3339Nano, kpiReport.Task.Period.StartTime, time.Local)
|
||||
//etime, _ := time.ParseInLocation(time.RFC3339Nano, kpiReport.Task.Period.EndTime, time.Local)
|
||||
kpiData.StartTime = startTime
|
||||
kpiData.EndTime = endTime
|
||||
kpiData.Granularity = granularity
|
||||
kpiData.NEName = kpiReport.Task.NE.NEName
|
||||
kpiData.NEType = kpiReport.Task.NE.NeType
|
||||
kpiData.RmUid = kpiReport.Task.NE.RmUID
|
||||
kpiVal := new(KPIVal)
|
||||
kpiData.CreatedAt = time.Now().UnixMilli()
|
||||
for _, k := range kpiReport.Task.NE.KPIs {
|
||||
kpiEvent[k.KPIID] = k.Value // kip_id
|
||||
|
||||
kpiVal.KPIID = k.KPIID
|
||||
kpiVal.Value = int64(k.Value)
|
||||
kpiVal.Err = k.Err
|
||||
kpiData.KPIValues = append(kpiData.KPIValues, *kpiVal)
|
||||
}
|
||||
|
||||
// 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 kpiReport.Task.NE.NeType == "UPF" {
|
||||
wsService.NewWSSendImpl.ByGroupID(wsService.GROUP_KPI_UPF, kpiEvent)
|
||||
}
|
||||
|
||||
services.ResponseStatusOK204NoContent(w)
|
||||
}
|
||||
|
||||
// post kpi report from NEs, insert insto gold_kpi table, discard...
|
||||
func PostGoldKPIFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
log.Debug("PostKPIReportFromNF processing... ")
|
||||
|
||||
vars := mux.Vars(r)
|
||||
apiVer := vars["apiVersion"]
|
||||
if apiVer != global.ApiVersionV1 {
|
||||
log.Error("Uri api version is invalid. apiVersion:", apiVer)
|
||||
services.ResponseNotFound404UriNotExist(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
// body, err := io.ReadAll(io.LimitReader(r.Body, global.RequestBodyMaxLen))
|
||||
body, err := io.ReadAll(io.LimitReader(r.Body, global.RequestBodyMaxLen))
|
||||
if err != nil {
|
||||
@@ -244,12 +329,10 @@ func PostKPIReportFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
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
|
||||
//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.Granularity = goldKpi.Granularity
|
||||
kpiData.NEName = goldKpi.NEName
|
||||
kpiData.NEType = goldKpi.NEType
|
||||
@@ -969,9 +1052,9 @@ func PostMeasurementFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
layout := time.RFC3339
|
||||
measurement.Date = GetDateFromTimeString(layout, measurement.StartTime)
|
||||
measurement.StartTime = GetDateTimeFromTimeString(layout, measurement.StartTime)
|
||||
affected, err := session.Table("northbound_pm").Insert(measurement)
|
||||
affected, err := session.Table("nbi_pm").Insert(measurement)
|
||||
if err != nil && affected <= 0 {
|
||||
log.Error("Failed to insert northbound_pm:", err)
|
||||
log.Error("Failed to insert nbi_pm:", err)
|
||||
services.ResponseInternalServerError500DatabaseOperationFailed(w)
|
||||
return
|
||||
}
|
||||
@@ -1052,9 +1135,9 @@ func GetMeasurementFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
layout := time.RFC3339
|
||||
measurement.Date = GetDateFromTimeString(layout, measurement.StartTime)
|
||||
measurement.StartTime = GetDateTimeFromTimeString(layout, measurement.StartTime)
|
||||
affected, err := session.Table("northbound_pm").Insert(measurement)
|
||||
affected, err := session.Table("nbi_pm").Insert(measurement)
|
||||
if err != nil && affected <= 0 {
|
||||
log.Error("Failed to insert northbound_pm:", err)
|
||||
log.Error("Failed to insert nbi_pm:", err)
|
||||
services.ResponseInternalServerError500DatabaseOperationFailed(w)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1779,21 +1779,21 @@ func XormGetNorthboundCm(neType string, cmResults *[]NorthboundCm) error {
|
||||
log.Info("XormGetNorthboundCm processing... ")
|
||||
|
||||
cmResult := new(NorthboundCm)
|
||||
rows, err := xEngine.Table("northbound_cm").
|
||||
rows, err := xEngine.Table("nbi_cm").
|
||||
Distinct("object_type").
|
||||
Where("`ne_type` = ?", neType).
|
||||
Desc("timestamp").
|
||||
Cols("*").
|
||||
Rows(cmResult)
|
||||
if err != nil {
|
||||
log.Error("Failed to get table northbound_cm:", err)
|
||||
log.Error("Failed to get table nbi_cm:", err)
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
for rows.Next() {
|
||||
err := rows.Scan(cmResult)
|
||||
if err != nil {
|
||||
log.Error("Failed to get table northbound_cm:", err)
|
||||
log.Error("Failed to get table nbi_cm:", err)
|
||||
return err
|
||||
}
|
||||
*cmResults = append(*cmResults, *cmResult)
|
||||
@@ -1805,14 +1805,14 @@ func XormGetNorthboundCmLatestObject(neType, neID, objectType string) (*Northbou
|
||||
log.Info("XormGetNorthboundCmLatestObject processing... ")
|
||||
|
||||
cmResult := new(NorthboundCm)
|
||||
_, err := xEngine.Table("northbound_cm").
|
||||
_, err := xEngine.Table("nbi_cm").
|
||||
Where("`ne_type`=? and `ne_id`=? and `object_type`=?", neType, neID, objectType).
|
||||
Desc("timestamp").
|
||||
Cols("*").
|
||||
Limit(1).
|
||||
Get(cmResult)
|
||||
if err != nil {
|
||||
log.Error("Failed to get table northbound_cm:", err)
|
||||
log.Error("Failed to get table nbi_cm:", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
2
makefile
2
makefile
@@ -3,7 +3,7 @@
|
||||
ProjectL = omc
|
||||
ProjectU = OMC
|
||||
PROJECT = $(ProjectL)
|
||||
VERSION = 2.2405.1
|
||||
VERSION = 2.2405.2
|
||||
RelDate = `date +%Y%m%d`
|
||||
Release = $(RelDate)
|
||||
RelVer = $(VERSION)-$(RelDate)
|
||||
|
||||
2
mkpkg.sh
2
mkpkg.sh
@@ -2,7 +2,7 @@
|
||||
|
||||
ProcList="restagent crontask sshsvc captrace data2html"
|
||||
ProjectL=omc
|
||||
VERSION=2.2405.1
|
||||
VERSION=2.2405.2
|
||||
RelDate=`date +%Y%m%d`
|
||||
Release=${RelDate}
|
||||
RelVer=${VERSION}-${RelDate}
|
||||
|
||||
@@ -20,6 +20,11 @@ type YamlConfig struct {
|
||||
Count int `yaml:"count"`
|
||||
} `yaml:"logger"`
|
||||
|
||||
Pprof struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Addr string `yaml:"addr"`
|
||||
} `yaml:"pprof"`
|
||||
|
||||
// Rest []struct {
|
||||
// IPv4 string `yaml:"ipv4"`
|
||||
// IPv6 string `yaml:"ipv6"`
|
||||
|
||||
@@ -2,11 +2,16 @@
|
||||
# level: /trace/debug/info/warn/error/fatal, default: debug
|
||||
# duration: rotation time with xx hours, example: 1/12/24 hours
|
||||
# count: rotation count of log, default is 30 rotation
|
||||
# pprof: false(default)/true to disable/enable pprof
|
||||
logger:
|
||||
file: d:/local.git/be.ems/restagent/log/restagent.log
|
||||
level: trace
|
||||
duration: 24
|
||||
count: 2
|
||||
count: 2
|
||||
|
||||
pprof:
|
||||
enabled: true
|
||||
addr: :36060
|
||||
|
||||
# rest agent listen ipv4/v6 and port, support multiple routines
|
||||
# ip: 0.0.0.0 or ::0, support IPv4/v6
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Makefile for rest agent project
|
||||
|
||||
PROJECT = OMC
|
||||
VERSION = 2.2405.1
|
||||
VERSION = 2.2405.2
|
||||
PLATFORM = amd64
|
||||
ARMPLATFORM = aarch64
|
||||
BUILDDIR = ../../build
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
_ "net/http/pprof"
|
||||
|
||||
"be.ems/features/dbrest"
|
||||
"be.ems/features/event"
|
||||
"be.ems/features/fm"
|
||||
@@ -185,12 +187,20 @@ func HttpListenWebServer(addr string) {
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
// src 配置中心初始加载
|
||||
src.ConfigurationInit()
|
||||
app := src.AppEngine()
|
||||
|
||||
conf := config.GetYamlConfig()
|
||||
|
||||
if conf.Pprof.Enabled {
|
||||
// 启用pprof HTTP服务
|
||||
go func() {
|
||||
fmt.Println(http.ListenAndServe(conf.Pprof.Addr, nil))
|
||||
}()
|
||||
}
|
||||
|
||||
log.InitLogger(conf.Logger.File, conf.Logger.Duration, conf.Logger.Count, "omc:restagent", config.GetLogLevel())
|
||||
fmt.Printf("OMC restagent version: %s\n", global.Version)
|
||||
log.Infof("========================= OMC restagent startup =========================")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# 项目信息
|
||||
framework:
|
||||
name: "CN EMS"
|
||||
version: "2.2405.1"
|
||||
version: "2.2405.2"
|
||||
|
||||
# 应用服务配置
|
||||
server:
|
||||
|
||||
@@ -15,14 +15,16 @@ type CDREvent struct {
|
||||
|
||||
// CDREventQuery CDR会话对象查询参数结构体
|
||||
type CDREventQuery struct {
|
||||
NeType string `json:"neType" form:"neType" binding:"required"` // 网元类型, 暂时支持IMS
|
||||
NeID string `json:"neId" form:"neId" binding:"required"`
|
||||
RmUID string `json:"rmUID" form:"rmUID"`
|
||||
RecordType string `json:"recordType" form:"recordType"` // 记录行为 MOC MTC MOSM MTSM
|
||||
StartTime string `json:"startTime" form:"startTime"`
|
||||
EndTime string `json:"endTime" form:"endTime"`
|
||||
SortField string `json:"sortField" form:"sortField" binding:"omitempty,oneof=timestamp"` // 排序字段,填写结果字段
|
||||
SortOrder string `json:"sortOrder" form:"sortOrder" binding:"omitempty,oneof=asc desc"` // 排序升降序,asc desc
|
||||
PageNum int64 `json:"pageNum" form:"pageNum" binding:"required"`
|
||||
PageSize int64 `json:"pageSize" form:"pageSize" binding:"required"`
|
||||
NeType string `json:"neType" form:"neType" binding:"required"` // 网元类型, 暂时支持IMS
|
||||
NeID string `json:"neId" form:"neId" binding:"required"`
|
||||
RmUID string `json:"rmUID" form:"rmUID"`
|
||||
RecordType string `json:"recordType" form:"recordType"` // 记录行为 MOC MTC MOSM MTSM
|
||||
CallerParty string `json:"callerParty" form:"callerParty"` // 主叫号码
|
||||
CalledParty string `json:"calledParty" form:"calledParty"` // 被叫号码
|
||||
StartTime string `json:"startTime" form:"startTime"`
|
||||
EndTime string `json:"endTime" form:"endTime"`
|
||||
SortField string `json:"sortField" form:"sortField" binding:"omitempty,oneof=timestamp"` // 排序字段,填写结果字段
|
||||
SortOrder string `json:"sortOrder" form:"sortOrder" binding:"omitempty,oneof=asc desc"` // 排序升降序,asc desc
|
||||
PageNum int64 `json:"pageNum" form:"pageNum" binding:"required"`
|
||||
PageSize int64 `json:"pageSize" form:"pageSize" binding:"required"`
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ type UEEventQuery struct {
|
||||
NeID string `json:"neId" form:"neId" binding:"required"`
|
||||
RmUID string `json:"rmUID" form:"rmUID"`
|
||||
EventType string `json:"eventType" form:"eventType"` // 事件类型 auth-result detach cm-state
|
||||
IMSI string `json:"imsi" form:"imsi"` // imsi
|
||||
StartTime string `json:"startTime" form:"startTime"`
|
||||
EndTime string `json:"endTime" form:"endTime"`
|
||||
SortField string `json:"sortField" form:"sortField" binding:"omitempty,oneof=timestamp"` // 排序字段,填写结果字段
|
||||
|
||||
@@ -63,10 +63,6 @@ func (r *CDREventImpl) SelectPage(querys model.CDREventQuery) map[string]any {
|
||||
conditions = append(conditions, "rm_uid = ?")
|
||||
params = append(params, querys.RmUID)
|
||||
}
|
||||
if querys.RmUID != "" {
|
||||
conditions = append(conditions, "rm_uid = ?")
|
||||
params = append(params, querys.RmUID)
|
||||
}
|
||||
if querys.StartTime != "" {
|
||||
conditions = append(conditions, "timestamp >= ?")
|
||||
beginDate := date.ParseStrToDate(querys.StartTime, date.YYYY_MM_DD_HH_MM_SS)
|
||||
@@ -77,6 +73,14 @@ func (r *CDREventImpl) SelectPage(querys model.CDREventQuery) map[string]any {
|
||||
endDate := date.ParseStrToDate(querys.EndTime, date.YYYY_MM_DD_HH_MM_SS)
|
||||
params = append(params, endDate.Unix())
|
||||
}
|
||||
if querys.CallerParty != "" {
|
||||
conditions = append(conditions, "JSON_EXTRACT(cdr_json, '$.callerParty') = ?")
|
||||
params = append(params, querys.CallerParty)
|
||||
}
|
||||
if querys.CalledParty != "" {
|
||||
conditions = append(conditions, "JSON_EXTRACT(cdr_json, '$.calledParty') = ?")
|
||||
params = append(params, querys.CalledParty)
|
||||
}
|
||||
if querys.RecordType != "" {
|
||||
recordTypes := strings.Split(querys.RecordType, ",")
|
||||
placeholder := repo.KeyPlaceholderByQuery(len(recordTypes))
|
||||
|
||||
@@ -74,6 +74,10 @@ func (r *UEEventImpl) SelectPage(querys model.UEEventQuery) map[string]any {
|
||||
endDate := date.ParseStrToDate(querys.EndTime, date.YYYY_MM_DD_HH_MM_SS)
|
||||
params = append(params, endDate.Unix())
|
||||
}
|
||||
if querys.IMSI != "" {
|
||||
conditions = append(conditions, "JSON_EXTRACT(event_json, '$.imsi') = ?")
|
||||
params = append(params, querys.IMSI)
|
||||
}
|
||||
if querys.EventType != "" {
|
||||
eventTypes := strings.Split(querys.EventType, ",")
|
||||
placeholder := repo.KeyPlaceholderByQuery(len(eventTypes))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Makefile for OMC-OMC-crontask project
|
||||
|
||||
PROJECT = OMC
|
||||
VERSION = 2.2405.1
|
||||
VERSION = 2.2405.2
|
||||
LIBDIR = be.ems/lib
|
||||
BINNAME = sshsvc
|
||||
|
||||
|
||||
@@ -29,8 +29,6 @@ ne_pool
|
||||
ne_software
|
||||
ne_state
|
||||
ne_version
|
||||
northbound_cm
|
||||
northbound_pm
|
||||
operation_log
|
||||
param_value
|
||||
permission
|
||||
|
||||
Reference in New Issue
Block a user