From 44536f34d480b18bc3ff47de7ebde4c6339581f6 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Mon, 28 Oct 2024 16:41:55 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E7=9B=B4=E8=BF=9E=E7=BD=91?= =?UTF-8?q?=E5=85=83=E4=BF=A1=E6=81=AF=E5=8F=96=E5=BE=97hostname/os?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/network_element/fetch_link/ne_state.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/network_element/fetch_link/ne_state.go b/src/modules/network_element/fetch_link/ne_state.go index 9a5feb39..9da0547d 100644 --- a/src/modules/network_element/fetch_link/ne_state.go +++ b/src/modules/network_element/fetch_link/ne_state.go @@ -49,6 +49,8 @@ func NeState(neInfo model.NeInfo) (map[string]any, error) { "capability": resData["capability"], "sn": resData["serialNum"], "expire": resData["expiryDate"], + "hostname": resData["hostName"], + "os": resData["osInfo"], "cpu": resData["cpuUsage"], "mem": resData["memUsage"], "disk": resData["diskSpace"], From c6c40e55d944a7b833417e58ad02e0854fb2e66e Mon Sep 17 00:00:00 2001 From: lai <371757574@qq.com> Date: Tue, 29 Oct 2024 15:03:57 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=8B=86=E5=88=86=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=88=97=E4=BB=A5=E5=8F=8A=E6=96=B0=E5=A2=9E=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/network_data/controller/smf.go | 66 +++++++++++++++++----- 1 file changed, 51 insertions(+), 15 deletions(-) diff --git a/src/modules/network_data/controller/smf.go b/src/modules/network_data/controller/smf.go index d944f813..48bdee05 100644 --- a/src/modules/network_data/controller/smf.go +++ b/src/modules/network_data/controller/smf.go @@ -130,7 +130,16 @@ func (s *SMFController) CDRExport(c *gin.Context) { "G1": "Data Total Volume", "H1": "Duration", "I1": "Invocation Time", - "J1": "PDU Session Charging Information", + "J1": "User Identifier", + "K1": "SSC Mode", + "L1": "DNN ID", + "M1": "PDU Type", + "N1": "RAT Type", + "O1": "PDU IPv4 Address", + "P1": "PDU IPv6 Address Swith Prefix", + "Q1": "Record Network Function ID", + "R1": "Record Type", + "S1": "Record Opening Time", } // 从第二行开始的数据 dataCells := make([]map[string]any, 0) @@ -164,6 +173,7 @@ func (s *SMFController) CDRExport(c *gin.Context) { dataVolumeDownlink := []string{} // 数据总量 dataTotalVolume := []string{} + if v, ok := cdrJSON["listOfMultipleUnitUsage"]; ok && v != nil { usageList := v.([]any) if len(usageList) > 0 { @@ -198,32 +208,31 @@ func (s *SMFController) CDRExport(c *gin.Context) { invocationTimestamp = v.(string) } // 记录打开时间 - pduSessionChargingInformation := "" + User_Identifier := "" + SSC_Mode := "" + RAT_Type := "" + DNN_ID := "" + PDU_Type := "" + PDU_IPv4 := "" + PDU_IPv6 := "" if v, ok := cdrJSON["pDUSessionChargingInformation"]; ok && v != nil { pduInfo := v.(map[string]any) - User_Identifier := "" if v, ok := pduInfo["userIdentifier"]; ok && v != nil { User_Identifier = v.(string) } - SSC_Mode := "" if v, ok := pduInfo["sSCMode"]; ok && v != nil { SSC_Mode = v.(string) } - RAT_Type := "" if v, ok := pduInfo["rATType"]; ok && v != nil { RAT_Type = v.(string) } - DNN_ID := "" if v, ok := pduInfo["dNNID"]; ok && v != nil { DNN_ID = v.(string) } - PDU_Type := "" if v, ok := pduInfo["pDUType"]; ok && v != nil { PDU_Type = v.(string) } - PDU_IPv4 := "" - PDU_IPv6 := "" if v, ok := pduInfo["pDUAddress"]; ok && v != nil { pDUAddress := v.(map[string]any) if addr, ok := pDUAddress["pDUIPv4Address"]; ok && addr != nil { @@ -234,11 +243,29 @@ func (s *SMFController) CDRExport(c *gin.Context) { } } - pduSessionChargingInformation = fmt.Sprintf(`User Identifier: %s -SSC Mode: %s RAT Type: %s DNN ID: %s -PDU Type: %s -PDU IPv4 Address: %s -PDU IPv6 Addres Swith Prefix: %s`, User_Identifier, SSC_Mode, RAT_Type, DNN_ID, PDU_Type, PDU_IPv4, PDU_IPv6) + // pduSessionChargingInformation = fmt.Sprintf(`User Identifier: %s + // SSC Mode: %s RAT Type: %s DNN ID: %s + // PDU Type: %s + // PDU IPv4 Address: %s + // PDU IPv6 Addres Swith Prefix: %s`, User_Identifier, SSC_Mode, RAT_Type, DNN_ID, PDU_Type, PDU_IPv4, PDU_IPv6) + } + + // 记录网络参数ID + recordNFID := "" + if v, ok := cdrJSON["recordingNetworkFunctionID"]; ok && v != nil { + recordNFID = v.(string) + } + + //记录开始时间 + recordOpeningTime := "" + if v, ok := cdrJSON["recordOpeningTime"]; ok && v != nil { + recordOpeningTime = v.(string) + } + + //记录类型 + recordType := "" + if v, ok := cdrJSON["recordType"]; ok && v != nil { + recordType = v.(string) } dataCells = append(dataCells, map[string]any{ @@ -251,7 +278,16 @@ PDU IPv6 Addres Swith Prefix: %s`, User_Identifier, SSC_Mode, RAT_Type, DNN_ID, "G" + idx: strings.Join(dataTotalVolume, ","), "H" + idx: duration, "I" + idx: invocationTimestamp, - "J" + idx: pduSessionChargingInformation, + "J" + idx: User_Identifier, + "K" + idx: SSC_Mode, + "L" + idx: DNN_ID, + "M" + idx: PDU_Type, + "N" + idx: RAT_Type, + "O" + idx: PDU_IPv4, + "P" + idx: PDU_IPv6, + "Q" + idx: recordNFID, + "R" + idx: recordType, + "S" + idx: recordOpeningTime, }) } From 32852c95d813a9433092cf56d9864caea8ab6e37 Mon Sep 17 00:00:00 2001 From: lai <371757574@qq.com> Date: Tue, 29 Oct 2024 19:32:00 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/network_data/controller/smf.go | 84 +++++++++++++--------- 1 file changed, 50 insertions(+), 34 deletions(-) diff --git a/src/modules/network_data/controller/smf.go b/src/modules/network_data/controller/smf.go index 48bdee05..094b4843 100644 --- a/src/modules/network_data/controller/smf.go +++ b/src/modules/network_data/controller/smf.go @@ -123,26 +123,30 @@ func (s *SMFController) CDRExport(c *gin.Context) { headerCells := map[string]string{ "A1": "ID", "B1": "Charging ID", - "C1": "Subscriber ID Data", - "D1": "Subscriber ID Type", - "E1": "Data Volume Uplink", - "F1": "Data Volume Downlink", - "G1": "Data Total Volume", - "H1": "Duration", - "I1": "Invocation Time", - "J1": "User Identifier", - "K1": "SSC Mode", - "L1": "DNN ID", - "M1": "PDU Type", - "N1": "RAT Type", - "O1": "PDU IPv4 Address", - "P1": "PDU IPv6 Address Swith Prefix", - "Q1": "Record Network Function ID", - "R1": "Record Type", - "S1": "Record Opening Time", + "C1": "NE Name", + "D1": "Resource Unique ID", + "E1": "Subscriber ID Data", + "F1": "Subscriber ID Type", + "G1": "Data Volume Uplink", + "H1": "Data Volume Downlink", + "I1": "Data Total Volume", + "J1": "Duration", + "K1": "Invocation Time", + "L1": "User Identifier", + "M1": "SSC Mode", + "N1": "DNN ID", + "O1": "PDU Type", + "P1": "RAT Type", + "Q1": "PDU IPv4 Address", + "R1": "Network Function IPv4", + "S1": "PDU IPv6 Address Swith Prefix", + "T1": "Record Network Function ID", + "U1": "Record Type", + "V1": "Record Opening Time", } // 从第二行开始的数据 dataCells := make([]map[string]any, 0) + for i, row := range rows { idx := strconv.Itoa(i + 2) // 解析 JSON 字符串为 map @@ -167,6 +171,15 @@ func (s *SMFController) CDRExport(c *gin.Context) { subscriptionIDData = sub["subscriptionIDData"].(string) } } + + // 网络功能 IPv4 地址 + networkFunctionIPv4Address := "" + if v, ok := cdrJSON["nFunctionConsumerInformation"]; ok && v != nil { + if conInfo, conInfoOk := v.(map[string]any); conInfoOk && conInfo != nil { + networkFunctionIPv4Address = conInfo["networkFunctionIPv4Address"].(string) + } + } + // 数据量上行链路 dataVolumeUplink := []string{} // 数据量下行链路 @@ -271,23 +284,26 @@ func (s *SMFController) CDRExport(c *gin.Context) { dataCells = append(dataCells, map[string]any{ "A" + idx: row.ID, "B" + idx: chargingID, - "C" + idx: subscriptionIDData, - "D" + idx: subscriptionIDType, - "E" + idx: strings.Join(dataVolumeUplink, ","), - "F" + idx: strings.Join(dataVolumeDownlink, ","), - "G" + idx: strings.Join(dataTotalVolume, ","), - "H" + idx: duration, - "I" + idx: invocationTimestamp, - "J" + idx: User_Identifier, - "K" + idx: SSC_Mode, - "L" + idx: DNN_ID, - "M" + idx: PDU_Type, - "N" + idx: RAT_Type, - "O" + idx: PDU_IPv4, - "P" + idx: PDU_IPv6, - "Q" + idx: recordNFID, - "R" + idx: recordType, - "S" + idx: recordOpeningTime, + "C" + idx: row.NeName, + "D" + idx: row.RmUID, + "E" + idx: subscriptionIDData, + "F" + idx: subscriptionIDType, + "G" + idx: strings.Join(dataVolumeUplink, ","), + "H" + idx: strings.Join(dataVolumeDownlink, ","), + "I" + idx: strings.Join(dataTotalVolume, ","), + "J" + idx: duration, + "K" + idx: invocationTimestamp, + "L" + idx: User_Identifier, + "M" + idx: SSC_Mode, + "N" + idx: DNN_ID, + "O" + idx: PDU_Type, + "P" + idx: RAT_Type, + "Q" + idx: PDU_IPv4, + "R" + idx: networkFunctionIPv4Address, + "S" + idx: PDU_IPv6, + "T" + idx: recordNFID, + "U" + idx: recordType, + "V" + idx: recordOpeningTime, }) } From a1010c84e5f6c71f533a34388b1a330128ed19dc Mon Sep 17 00:00:00 2001 From: simonzhangsz Date: Tue, 29 Oct 2024 19:40:04 +0800 Subject: [PATCH 4/4] dpkg debian package for general and BA tag --- makefile | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/makefile b/makefile index 27d00ccd..8e0abff1 100644 --- a/makefile +++ b/makefile @@ -12,14 +12,17 @@ ARMPLATFORM = aarch64 GitLocalRoot = $(HOME)/omc.git EmsBuildRoot=$(GitLocalRoot)/build.ems BuildDir = $(EmsBuildRoot)/build +CustomizedDir = $(EmsBuildRoot)/customized BuildOMCDir = $(BuildDir)/usr/local/omc BuildOMCBinDir = $(BuildOMCDir)/bin BuildOMCEtcDir = $(BuildOMCDir)/etc BuildLibDir = $(BuildDir)/lib BuildLibSystemDir = $(BuildLibDir)/systemd/system DebBuildDir = $(EmsBuildRoot)/debbuild +DebBuildOMCDir = $(EmsBuildRoot)/debbuild/usr/local/omc DebFEBuildDir = $(EmsBuildRoot)/debbuild/usr/local/omc/htdocs DebBuild2204Dir = $(EmsBuildRoot)/debbuild/22.04 +DebBuild2204OMCDir = $(EmsBuildRoot)/debbuild/22.04/usr/local/omc DebFEBuild2204Dir = $(EmsBuildRoot)/debbuild/22.04/usr/local/omc/htdocs RpmBuildDir = $(EmsBuildRoot)/rpmbuild RpmFEBuildDir = $(RpmBuildDir)/BUILD/usr/local/omc/htdocs @@ -54,11 +57,14 @@ RestagentSize = 29525312 BinWriterDir = $(HOME)/bin ifeq ($(shell grep VERSION_ID /etc/os-release), VERSION_ID="22.04") DebBuildDir := $(DebBuild2204Dir) +DebBuildOMCDir := $(DebBuild2204OMCDir) DebFEBuildDir := $(DebFEBuild2204Dir) #DebPkgFile := $(PROJECT)-$(VERSION)-22.04-$(Release).$(PLATFORM).deb DebPkgFile := $(PROJECT)-r$(VERSION)-$(Release)-ub22.deb +DebPkgFileBA := $(PROJECT)-r$(VERSION)-$(Release)-ub22-ba.deb else ifeq ($(shell grep VERSION_ID /etc/os-release), VERSION_ID="18.04") DebPkgFile := $(PROJECT)-r$(VERSION)-$(Release)-ub18.deb +DebPkgFileBA := $(PROJECT)-r$(VERSION)-$(Release)-ub18-ba.deb endif .PHONY: all $(RESTAGENT) $(CRONTASK) $(SshSvcBin) $(CapTraceBin) $(Data2htmlBin) @@ -101,7 +107,7 @@ dist: --exclude=../crontask/crontask \ --exclude=../initems/initems -deb: $(BINNAME) +prep_deb: $(BINNAME) # clear build cache rm -rf $(FrontBuildDir)/front/* rm -rf $(DebFEBuildDir)/front/* @@ -123,6 +129,14 @@ deb: $(BINNAME) chmod 755 $(DebBuildDir)/DEBIAN/postinst chmod 755 $(DebBuildDir)/DEBIAN/postrm cp -rf $(BuildDir)/* $(DebBuildDir)/ + +replace_chinese: + @find $(DebBuildOMCDir)/etc/db -type f -name '*.sql' -exec sed -i '' 's/[一-龥]//g' {} + + @echo "Replace all chinese charecter." + +deb: prep_deb + cp -rf $(CustomizedDir)/agt.d $(DebBuildOMCDir)/static + cp -rf $(CustomizedDir)/omc.d $(DebBuildOMCDir)/static #cp -rf $(BuildDir)/nginx/* $(DebBuildDir)/etc/nginx/conf.d #cp -rf $(BuildDir)/systemd/*.service $(DebBuildDir)/lib/systemd/system/ chmod +x $(DebBuildDir)/usr/local/omc/bin/* @@ -131,6 +145,16 @@ deb: $(BINNAME) perl -0777 -i -pe 's/ne:\n user: root/ne:\n user: omcuser/g' $(DebBuildDir)/usr/local/omc/etc/default/restconf.yaml dpkg -b $(DebBuildDir) $(ReleaseDebs)/$(DebPkgFile) +ba-deb: prep_deb replace_chinese + cp -rf $(CustomizedDir)/ba.d $(DebBuildOMCDir)/static + #cp -rf $(BuildDir)/nginx/* $(DebBuildDir)/etc/nginx/conf.d + #cp -rf $(BuildDir)/systemd/*.service $(DebBuildDir)/lib/systemd/system/ + chmod +x $(DebBuildDir)/usr/local/omc/bin/* + #sed -i.bak 's/YYYYMMDD/$(shell date +"%Y%m%d")/g' $(DebBuildDir)/DEBIAN/control + sed -i 's/YYYYMMDD/$(shell date +"%Y%m%d")/g' $(DebBuildDir)/DEBIAN/control + perl -0777 -i -pe 's/ne:\n user: root/ne:\n user: omcuser/g' $(DebBuildDir)/usr/local/omc/etc/default/restconf.yaml + dpkg -b $(DebBuildDir) $(ReleaseDebs)/$(DebPkgFileBA) + rpm: $(BINNAME) # clear build cache rm -rf $(FrontBuildDir)/front/*