marge: 合并代码
This commit is contained in:
59
features/cdr/cdrevent.go
Normal file
59
features/cdr/cdrevent.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package cdr
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"ems.agt/lib/dborm"
|
||||
"ems.agt/lib/global"
|
||||
"ems.agt/lib/log"
|
||||
"ems.agt/lib/services"
|
||||
"ems.agt/restagent/config"
|
||||
)
|
||||
|
||||
var (
|
||||
UriCDREvent = config.DefaultUriPrefix + "/cdrManagement/v1/elementType/{elementTypeValue}/objectType/cdrEvent"
|
||||
UriCDRFile = config.DefaultUriPrefix + "/cdrManagement/v1/elementType/{elementTypeValue}/objectType/cdrFile"
|
||||
|
||||
CustomUriCDREvent = config.UriPrefix + "/cdrManagement/v1/elementType/{elementTypeValue}/objectType/cdrEvent"
|
||||
CustomUriCDRFile = config.UriPrefix + "/cdrManagement/v1/elementType/{elementTypeValue}/objectType/cdrFile"
|
||||
)
|
||||
|
||||
type CDREvent struct {
|
||||
NeType string `json:"neType" xorm:"ne_type"`
|
||||
NeName string `json:"neName" xorm:"ne_name"`
|
||||
RmUID string `json:"rmUID" xorm:"rm_uid"`
|
||||
Timestamp int `json:"timestamp" xorm:"timestamp"`
|
||||
CDR map[string]any `json:"CDR" xorm:"cdr_json"`
|
||||
}
|
||||
|
||||
func PostCDREventFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
log.Info("PostCDREventFromNF processing... ")
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
cdrEvent := new(CDREvent)
|
||||
err = json.Unmarshal(body, &cdrEvent)
|
||||
if err != nil {
|
||||
log.Error("Failed to Unmarshal cdrEvent:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
log.Trace("cdrEvent:", cdrEvent)
|
||||
|
||||
affected, err := dborm.XormInsertTableOne("cdr_event", cdrEvent)
|
||||
if err != nil && affected <= 0 {
|
||||
log.Error("Failed to insert cdr_event:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
services.ResponseStatusOK204NoContent(w)
|
||||
}
|
||||
@@ -527,7 +527,7 @@ func DistributeSoftwareToNF(w http.ResponseWriter, r *http.Request) {
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
log.Debug("neSoftware:", neSoftware)
|
||||
log.Trace("neSoftware:", neSoftware)
|
||||
|
||||
sql = fmt.Sprintf("select * from ne_version where ne_type='%s' and ne_id='%s'", neTypeUpper, neId)
|
||||
neVersion, err := dborm.XormGetDataBySQL(sql)
|
||||
@@ -536,13 +536,13 @@ func DistributeSoftwareToNF(w http.ResponseWriter, r *http.Request) {
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
log.Debug("neVersion:", neVersion)
|
||||
log.Trace("neVersion:", neVersion)
|
||||
|
||||
sshHost := fmt.Sprintf("%s@%s", config.GetYamlConfig().NE.User, neInfo.Ip)
|
||||
mkdirCmd := fmt.Sprintf("sudo mkdir -p %s/software/%s", config.GetYamlConfig().NE.OmcDir, neTypeLower)
|
||||
cmd := exec.Command("ssh", sshHost, mkdirCmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Debugf("Exec output: %v", string(out))
|
||||
log.Tracef("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("Faile to mkdir:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
@@ -557,7 +557,7 @@ func DistributeSoftwareToNF(w http.ResponseWriter, r *http.Request) {
|
||||
neInfo.Ip, config.GetYamlConfig().NE.ScpDir)
|
||||
cmd = exec.Command("scp", "-r", srcFile, scpDir)
|
||||
out, err = cmd.CombinedOutput()
|
||||
log.Debugf("Exec output: %v", string(out))
|
||||
log.Tracef("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Errorf("Faile to scp NF: neType=%s, neId=%s, ip=%s", neType, neId, neInfo.Ip)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
@@ -568,7 +568,7 @@ func DistributeSoftwareToNF(w http.ResponseWriter, r *http.Request) {
|
||||
config.GetYamlConfig().NE.OmcDir, neTypeLower)
|
||||
cmd = exec.Command("ssh", sshHost, cpCmd)
|
||||
out, err = cmd.CombinedOutput()
|
||||
log.Debugf("Exec output: %v", string(out))
|
||||
log.Tracef("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("Faile to execute cp command:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
@@ -667,7 +667,7 @@ func ActiveSoftwareToNF(w http.ResponseWriter, r *http.Request) {
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
log.Debug("neVersion:", neSoftware)
|
||||
log.Trace("neSoftware:", neSoftware)
|
||||
|
||||
sql = fmt.Sprintf("select * from ne_version where ne_type='%s' and ne_id='%s' and version='%s'", neTypeUpper, neId, version)
|
||||
neVersion, err := dborm.XormGetDataBySQL(sql)
|
||||
@@ -681,62 +681,104 @@ func ActiveSoftwareToNF(w http.ResponseWriter, r *http.Request) {
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
log.Debug("neVersion:", neVersion)
|
||||
log.Trace("neVersion:", neVersion)
|
||||
|
||||
if !config.GetYamlConfig().OMC.TestMode {
|
||||
filePath := (*neVersion)[0]["file_path"]
|
||||
sshHost := fmt.Sprintf("%s@%s", config.GetYamlConfig().NE.User, neInfo.Ip)
|
||||
fileType := global.IsRpmOrDebPackage(filePath)
|
||||
if fileType == 1 {
|
||||
rpmCmd := fmt.Sprintf("sudo rpm -Uvh '%s'", filePath)
|
||||
cmd := exec.Command("ssh", sshHost, rpmCmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Debugf("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("Faile to execute rpm command:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
} else if fileType == 2 {
|
||||
dpkgCmd := fmt.Sprintf("sudo dpkg -i --force-all '%s'", filePath)
|
||||
err := RunSSHCmd(sshHost, dpkgCmd)
|
||||
if err != nil {
|
||||
log.Error("Faile to execute dpkg command:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
// timeout := time.Duration(config.GetYamlConfig().OMC.CmdTimeout) * time.Second
|
||||
// ctx, cancel := context.WithTimeout(context.Background(), timeout) // 设置超时
|
||||
// defer cancel()
|
||||
// cmd := exec.CommandContext(ctx, "ssh", sshHost, dpkgCmd)
|
||||
// var stdout, stderr bytes.Buffer
|
||||
// cmd.Stdout = &stdout
|
||||
// cmd.Stderr = &stderr
|
||||
// err := cmd.Start()
|
||||
// if err != nil {
|
||||
// log.Error("Faile to execute dpkg command: %v, err: %s", err, stderr.String())
|
||||
// services.ResponseInternalServerError500ProcessError(w, err)
|
||||
// return
|
||||
// }
|
||||
// out, err := cmd.CombinedOutput()
|
||||
// log.Debugf("Exec output: %v", string(out))
|
||||
// if err != nil {
|
||||
// log.Error("Faile to execute dpkg command:", err)
|
||||
// services.ResponseInternalServerError500ProcessError(w, err)
|
||||
// return
|
||||
// }
|
||||
} else {
|
||||
err := global.ErrCMUnknownSoftwareFormat
|
||||
log.Error(err)
|
||||
srcFile := fmt.Sprintf("%s/actpkg.sh", config.GetYamlConfig().OMC.BinDir)
|
||||
|
||||
scpDir := fmt.Sprintf("%s@%s:%s", config.GetYamlConfig().NE.User,
|
||||
neInfo.Ip, config.GetYamlConfig().NE.ScpDir)
|
||||
cmd := exec.Command("scp", "-r", srcFile, scpDir)
|
||||
_, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
log.Errorf("Faile to scp NF: neType=%s, neId=%s, ip=%s", neType, neId, neInfo.Ip)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
runCmd := fmt.Sprintf("sudo %s/actpkg.sh '%s' %s",
|
||||
config.GetYamlConfig().NE.ScpDir, filePath, neTypeUpper)
|
||||
if neTypeLower == "omc" {
|
||||
idNeVersion, _ := strconv.Atoi((*neVersion)[0]["id"])
|
||||
neVersionData := dborm.NeVersion{
|
||||
Status: SoftwareStatusActive,
|
||||
}
|
||||
|
||||
_, err = dborm.XormUpdateTableById(idNeVersion, "ne_version", neVersionData)
|
||||
if err != nil {
|
||||
log.Error("Faile to UpdateTableById:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
services.ResponseStatusOK204NoContent(w)
|
||||
go RunSSHCmd(sshHost, runCmd)
|
||||
return
|
||||
}
|
||||
err = RunSSHCmd(sshHost, runCmd)
|
||||
if err != nil {
|
||||
log.Errorf("Faile to execute command: %s, error: %v", runCmd, err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
// fileType := global.IsRpmOrDebPackage(filePath)
|
||||
// if fileType == 1 {
|
||||
// srcFile := fmt.Sprintf("%s/spawnrpm.sh", config.GetYamlConfig().OMC.BinDir)
|
||||
|
||||
// scpDir := fmt.Sprintf("%s@%s:%s", config.GetYamlConfig().NE.User,
|
||||
// neInfo.Ip, config.GetYamlConfig().NE.ScpDir)
|
||||
// cmd := exec.Command("scp", "-r", srcFile, scpDir)
|
||||
// _, err := cmd.CombinedOutput()
|
||||
// if err != nil {
|
||||
// log.Errorf("Faile to scp NF: neType=%s, neId=%s, ip=%s", neType, neId, neInfo.Ip)
|
||||
// services.ResponseInternalServerError500ProcessError(w, err)
|
||||
// return
|
||||
// }
|
||||
|
||||
// dpkgCmd := fmt.Sprintf("sudo %s/spawnrpm.sh '%s'",
|
||||
// config.GetYamlConfig().NE.ScpDir, filePath)
|
||||
// err = RunSSHCmd(sshHost, dpkgCmd)
|
||||
// if err != nil {
|
||||
// log.Errorf("Faile to execute dpkg command: %s, error: %v", dpkgCmd, err)
|
||||
// services.ResponseInternalServerError500ProcessError(w, err)
|
||||
// return
|
||||
// }
|
||||
// } else if fileType == 2 {
|
||||
// srcFile := fmt.Sprintf("%s/spawndpkg.sh", config.GetYamlConfig().OMC.BinDir)
|
||||
|
||||
// scpDir := fmt.Sprintf("%s@%s:%s", config.GetYamlConfig().NE.User,
|
||||
// neInfo.Ip, config.GetYamlConfig().NE.ScpDir)
|
||||
// cmd := exec.Command("scp", "-r", srcFile, scpDir)
|
||||
// _, err := cmd.CombinedOutput()
|
||||
// if err != nil {
|
||||
// log.Errorf("Faile to scp NF: neType=%s, neId=%s, ip=%s", neType, neId, neInfo.Ip)
|
||||
// services.ResponseInternalServerError500ProcessError(w, err)
|
||||
// return
|
||||
// }
|
||||
|
||||
// dpkgCmd := fmt.Sprintf("sudo %s/spawndpkg.sh '%s'",
|
||||
// config.GetYamlConfig().NE.ScpDir, filePath)
|
||||
// err = RunSSHCmd(sshHost, dpkgCmd)
|
||||
// if err != nil {
|
||||
// log.Errorf("Faile to execute dpkg command: %s, error: %v", dpkgCmd, err)
|
||||
// services.ResponseInternalServerError500ProcessError(w, err)
|
||||
// return
|
||||
// }
|
||||
// } else {
|
||||
// err := global.ErrCMUnknownSoftwareFormat
|
||||
// log.Error(err)
|
||||
// services.ResponseInternalServerError500ProcessError(w, err)
|
||||
// return
|
||||
// }
|
||||
switch neTypeLower {
|
||||
case "omc":
|
||||
restartCmd := fmt.Sprintf("sudo %s/bin/omcsvc.sh restart", config.GetYamlConfig().NE.OmcDir)
|
||||
cmd := exec.Command("ssh", sshHost, restartCmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Debugf("Exec output: %v", string(out))
|
||||
log.Tracef("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("Faile to execute ssh restart omc:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
@@ -746,9 +788,9 @@ func ActiveSoftwareToNF(w http.ResponseWriter, r *http.Request) {
|
||||
restartCmd := "sudo ims-stop && sudo ims-start"
|
||||
cmd := exec.Command("ssh", sshHost, restartCmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Debugf("Exec output: %v", string(out))
|
||||
log.Tracef("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("Faile to execute ssh sudo systemctl command:", err)
|
||||
log.Error("Faile to execute ssh command: %s, error: %v", restartCmd, err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
@@ -756,7 +798,7 @@ func ActiveSoftwareToNF(w http.ResponseWriter, r *http.Request) {
|
||||
restartCmd := fmt.Sprintf("sudo systemctl restart %s.service", neTypeLower)
|
||||
cmd := exec.Command("ssh", sshHost, restartCmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Debugf("Exec output: %v", string(out))
|
||||
log.Tracef("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("Faile to execute ssh sudo systemctl command:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
@@ -844,39 +886,94 @@ func RollBackSoftwareToNF(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if !config.GetYamlConfig().OMC.TestMode {
|
||||
sshHost := fmt.Sprintf("%s@%s", config.GetYamlConfig().NE.User, neInfo.Ip)
|
||||
fileType := global.IsRpmOrDebPackage(filePath)
|
||||
if fileType == 1 {
|
||||
rpmCmd := fmt.Sprintf("sudo rpm -Uvh --oldpackage '%s'", filePath)
|
||||
cmd := exec.Command("ssh", sshHost, rpmCmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Debugf("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("Faile to execute rpm command:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
} else if fileType == 2 {
|
||||
dpkgCmd := fmt.Sprintf("sudo dpkg -i --force-all '%s'", filePath)
|
||||
cmd := exec.Command("ssh", sshHost, dpkgCmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Debugf("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("Faile to execute dpkg command:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
err := global.ErrCMUnknownSoftwareFormat
|
||||
log.Error(err)
|
||||
srcFile := fmt.Sprintf("%s/rbkpkg.sh", config.GetYamlConfig().OMC.BinDir)
|
||||
|
||||
scpDir := fmt.Sprintf("%s@%s:%s", config.GetYamlConfig().NE.User,
|
||||
neInfo.Ip, config.GetYamlConfig().NE.ScpDir)
|
||||
cmd := exec.Command("scp", "-r", srcFile, scpDir)
|
||||
_, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
log.Errorf("Faile to scp NF: neType=%s, neId=%s, ip=%s", neType, neId, neInfo.Ip)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
runCmd := fmt.Sprintf("sudo %s/rbkpkg.sh '%s' %s",
|
||||
config.GetYamlConfig().NE.ScpDir, filePath, neTypeUpper)
|
||||
if neTypeLower == "omc" {
|
||||
idNeVersion, _ := strconv.Atoi((*neVersion)[0]["id"])
|
||||
neVersionData := dborm.NeVersion{
|
||||
Version: (*neVersion)[0]["pre_version"],
|
||||
FilePath: (*neVersion)[0]["pre_file"],
|
||||
PreVersion: "-",
|
||||
PreFile: "-",
|
||||
NewVersion: (*neVersion)[0]["version"],
|
||||
NewFile: (*neVersion)[0]["file_path"],
|
||||
Status: SoftwareStatusActive,
|
||||
}
|
||||
|
||||
_, err = dborm.XormUpdateTableById(idNeVersion, "ne_version", neVersionData)
|
||||
if err != nil {
|
||||
log.Error("Faile to UpdateTableById:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
services.ResponseStatusOK204NoContent(w)
|
||||
RunSSHCmd(sshHost, runCmd)
|
||||
return
|
||||
}
|
||||
err = RunSSHCmd(sshHost, runCmd)
|
||||
if err != nil {
|
||||
log.Errorf("Faile to execute command: %s, error: %v", runCmd, err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
// fileType := global.IsRpmOrDebPackage(filePath)
|
||||
// if fileType == 1 {
|
||||
// rpmCmd := fmt.Sprintf("sudo rpm -Uvh --oldpackage '%s'", filePath)
|
||||
// cmd := exec.Command("ssh", sshHost, rpmCmd)
|
||||
// _, err := cmd.CombinedOutput()
|
||||
// if err != nil {
|
||||
// log.Error("Faile to execute rpm command:", err)
|
||||
// services.ResponseInternalServerError500ProcessError(w, err)
|
||||
// return
|
||||
// }
|
||||
// } else if fileType == 2 {
|
||||
// srcFile := fmt.Sprintf("%s/spawndpkg.sh", config.GetYamlConfig().OMC.BinDir)
|
||||
|
||||
// scpDir := fmt.Sprintf("%s@%s:%s", config.GetYamlConfig().NE.User,
|
||||
// neInfo.Ip, config.GetYamlConfig().NE.ScpDir)
|
||||
// cmd := exec.Command("scp", "-r", srcFile, scpDir)
|
||||
// _, err := cmd.CombinedOutput()
|
||||
// if err != nil {
|
||||
// log.Errorf("Faile to scp NF: neType=%s, neId=%s, ip=%s", neType, neId, neInfo.Ip)
|
||||
// services.ResponseInternalServerError500ProcessError(w, err)
|
||||
// return
|
||||
// }
|
||||
// var inputStr string = "n"
|
||||
// if config.GetYamlConfig().NE.DpkgOverwrite {
|
||||
// inputStr = "y"
|
||||
// }
|
||||
// dpkgCmd := fmt.Sprintf("sudo %s/spawndpkg.sh %s '%s'",
|
||||
// config.GetYamlConfig().NE.ScpDir, inputStr, filePath)
|
||||
// err = RunSSHCmd(sshHost, dpkgCmd)
|
||||
// if err != nil {
|
||||
// log.Errorf("Faile to execute dpkg command: %s, error: %v", dpkgCmd, err)
|
||||
// services.ResponseInternalServerError500ProcessError(w, err)
|
||||
// return
|
||||
// }
|
||||
// } else {
|
||||
// err := global.ErrCMUnknownSoftwareFormat
|
||||
// log.Error(err)
|
||||
// services.ResponseInternalServerError500ProcessError(w, err)
|
||||
// return
|
||||
// }
|
||||
switch neTypeLower {
|
||||
case "omc":
|
||||
restartCmd := fmt.Sprintf("sudo %s/bin/omcsvc.sh restart", config.GetYamlConfig().NE.OmcDir)
|
||||
cmd := exec.Command("ssh", sshHost, restartCmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Debugf("Exec output: %v", string(out))
|
||||
log.Tracef("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("Faile to execute ssh restart omc:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
@@ -886,9 +983,9 @@ func RollBackSoftwareToNF(w http.ResponseWriter, r *http.Request) {
|
||||
restartCmd := "sudo ims-stop && sudo ims-start"
|
||||
cmd := exec.Command("ssh", sshHost, restartCmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Debugf("Exec output: %v", string(out))
|
||||
log.Tracef("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("Faile to execute ssh sudo systemctl command:", err)
|
||||
log.Error("Faile to execute ssh command: %s, error: %v", restartCmd, err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
@@ -896,7 +993,7 @@ func RollBackSoftwareToNF(w http.ResponseWriter, r *http.Request) {
|
||||
restartCmd := fmt.Sprintf("sudo systemctl restart %s.service", neTypeLower)
|
||||
cmd := exec.Command("ssh", sshHost, restartCmd)
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Debugf("Exec output: %v", string(out))
|
||||
log.Tracef("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("Faile to execute ssh sudo systemctl command:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
|
||||
@@ -528,7 +528,7 @@ func PostMMLToOMC(w http.ResponseWriter, r *http.Request) {
|
||||
services.ResponseNotFound404UriNotExist(w, r)
|
||||
return
|
||||
}
|
||||
log.Debug("Body:", string(body))
|
||||
log.Trace("Body:", string(body))
|
||||
|
||||
hostUri := fmt.Sprintf("http://%s:%s", neInfo.Ip, neInfo.Port)
|
||||
|
||||
|
||||
@@ -169,10 +169,10 @@ func PostKPIReportFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
services.ResponseNotFound404UriNotExist(w, r)
|
||||
return
|
||||
}
|
||||
log.Debug("Request body:", string(body))
|
||||
log.Trace("Request body:", string(body))
|
||||
kpiReport := new(KpiReport)
|
||||
_ = json.Unmarshal(body, &kpiReport)
|
||||
log.Debug("kpiReport:", kpiReport)
|
||||
log.Trace("kpiReport:", kpiReport)
|
||||
|
||||
session := xEngine.NewSession()
|
||||
defer session.Close()
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/shirou/gopsutil/v3/net"
|
||||
|
||||
"github.com/go-resty/resty/v2"
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
@@ -726,6 +728,112 @@ func GetAllSysinfoFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
func GetStateFromNF(w http.ResponseWriter, r *http.Request) {
|
||||
log.Debug("GetStateFromNF processing... ")
|
||||
|
||||
vars := mux.Vars(r)
|
||||
neType := vars["elementTypeValue"]
|
||||
neType = strings.ToLower(neType)
|
||||
|
||||
if neType == "" {
|
||||
services.ResponseNotFound404UriNotExist(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
if neType == "all" {
|
||||
var neList []dborm.NeInfo
|
||||
_, err := dborm.XormGetAllNeInfo(&neList)
|
||||
if err != nil {
|
||||
log.Error("Failed to get all ne info:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
data := make([]map[string]interface{}, 0)
|
||||
for _, ne := range neList {
|
||||
result := make(map[string]interface{})
|
||||
hostUri := fmt.Sprintf("http://%s:%v", ne.Ip, ne.Port)
|
||||
requestURI2NF := fmt.Sprintf("%s/api/rest/systemManagement/v1/elementType/%s/objectType/systemState",
|
||||
hostUri, strings.ToLower(ne.NeType))
|
||||
log.Debug("requestURI2NF:", requestURI2NF)
|
||||
|
||||
result["ipAddress"] = ne.Ip
|
||||
resp, err := client.R().
|
||||
EnableTrace().
|
||||
SetHeaders(map[string]string{"User-Agent": config.GetDefaultUserAgent()}).
|
||||
SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}).
|
||||
Get(requestURI2NF)
|
||||
if err != nil {
|
||||
log.Error("Get system state from NF is failed:", err)
|
||||
errorMessage := services.ErrorMessage{
|
||||
ErrorCode: "1", ErrorInfo: "Internal server error, NF connnect refused",
|
||||
}
|
||||
result["error"] = errorMessage
|
||||
SN, Version, _ := dborm.XormGetNEStateInfo(ne.NeType, ne.NeId)
|
||||
result["serialNum"] = SN
|
||||
result["version"] = Version
|
||||
} else {
|
||||
systemState := make(map[string]interface{})
|
||||
_ = json.Unmarshal(resp.Body(), &systemState)
|
||||
result["systemState"] = systemState
|
||||
}
|
||||
|
||||
neItem := strings.ToUpper(ne.NeType) + "/" + ne.NeId
|
||||
mapState := make(map[string]interface{})
|
||||
mapState[neItem] = result
|
||||
data = append(data, mapState)
|
||||
log.Trace("data:", data)
|
||||
}
|
||||
var response Response
|
||||
response.Data = data
|
||||
services.ResponseWithJson(w, http.StatusOK, response)
|
||||
return
|
||||
}
|
||||
|
||||
if neType == "omc" {
|
||||
emsState := GetEMSState("127.0.0.1")
|
||||
services.ResponseWithJson(w, http.StatusOK, emsState)
|
||||
return
|
||||
}
|
||||
|
||||
var neList []dborm.NeInfo
|
||||
err := dborm.XormGetNeInfoByNeType(neType, &neList)
|
||||
if err != nil {
|
||||
log.Error("Failed to dborm.XormGetNeInfoByNeType:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
data := make([]map[string]interface{}, 0)
|
||||
for _, ne := range neList {
|
||||
hostUri := fmt.Sprintf("http://%s:%v", ne.Ip, ne.Port)
|
||||
requestURI2NF := fmt.Sprintf("%s/api/rest/systemManagement/v1/elementType/%s/objectType/systemState",
|
||||
hostUri, strings.ToLower(ne.NeType))
|
||||
log.Debug("requestURI2NF:", requestURI2NF)
|
||||
|
||||
resp, err := client.R().
|
||||
EnableTrace().
|
||||
SetHeaders(map[string]string{"User-Agent": config.GetDefaultUserAgent()}).
|
||||
SetHeaders(map[string]string{"Content-Type": "application/json;charset=UTF-8"}).
|
||||
Get(requestURI2NF)
|
||||
if err != nil {
|
||||
log.Error("Get system state from NF is failed:", err)
|
||||
} else {
|
||||
systemState := make(map[string]interface{})
|
||||
_ = json.Unmarshal(resp.Body(), &systemState)
|
||||
data = append(data, systemState)
|
||||
}
|
||||
}
|
||||
|
||||
if len(data) == 1 {
|
||||
services.ResponseWithJson(w, http.StatusOK, data[0])
|
||||
return
|
||||
}
|
||||
var response Response
|
||||
response.Data = data
|
||||
services.ResponseWithJson(w, http.StatusOK, response)
|
||||
}
|
||||
|
||||
// GetStateFromNF 旧函数
|
||||
// Get system state from NF/NFs
|
||||
func GetStateFromNFOld(w http.ResponseWriter, r *http.Request) {
|
||||
log.Debug("GetStateFromNF processing... ")
|
||||
|
||||
data := make([]map[string]interface{}, 0)
|
||||
|
||||
vars := mux.Vars(r)
|
||||
@@ -876,6 +984,35 @@ func GetEMSState(ip string) *SysState {
|
||||
PartitionInfo: sysInfo.PartitionInfo,
|
||||
}
|
||||
|
||||
// 获取主机的 IP 地址列表
|
||||
ipAddrs := []string{ip}
|
||||
if ip == "" || ip == "127.0.0.1" {
|
||||
ipAddrs = []string{}
|
||||
interfaces, err := net.Interfaces()
|
||||
if err == nil {
|
||||
for _, iface := range interfaces {
|
||||
for _, v := range iface.Addrs {
|
||||
name := iface.Name
|
||||
if name[len(name)-1] == '0' {
|
||||
name = name[0 : len(name)-1]
|
||||
name = strings.Trim(name, "")
|
||||
}
|
||||
// ignore localhost
|
||||
if name == "lo" {
|
||||
continue
|
||||
}
|
||||
prefix := strings.Split(v.Addr, "/")[0]
|
||||
if strings.Contains(prefix, "::") {
|
||||
ipAddrs = append(ipAddrs, prefix)
|
||||
}
|
||||
if strings.Contains(prefix, ".") {
|
||||
ipAddrs = append(ipAddrs, prefix)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
version := "16.1.1"
|
||||
if global.Version != "" {
|
||||
version = global.Version
|
||||
@@ -886,7 +1023,7 @@ func GetEMSState(ip string) *SysState {
|
||||
HostName: hostName,
|
||||
OsInfo: getUnameStr(),
|
||||
DbInfo: dbInfo,
|
||||
IpAddr: []string{ip},
|
||||
IpAddr: ipAddrs,
|
||||
Port: config.GetYamlConfig().Rest[0].Port,
|
||||
Version: version,
|
||||
Capability: 9999999,
|
||||
|
||||
@@ -276,7 +276,7 @@ func XormGetAllNeInfo(nes *[]NeInfo) (*[]NeInfo, error) {
|
||||
}
|
||||
*nes = append(*nes, *ne)
|
||||
}
|
||||
log.Debug("nes:", nes)
|
||||
log.Trace("nes:", nes)
|
||||
return nes, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
// "log"
|
||||
|
||||
"ems.agt/features/aaaa"
|
||||
"ems.agt/features/cdr"
|
||||
"ems.agt/features/cm"
|
||||
"ems.agt/features/dbrest"
|
||||
"ems.agt/features/file"
|
||||
@@ -299,6 +300,9 @@ func init() {
|
||||
Register("GET", ue.UriNSSFSubscriptions, ue.GetSubscriptionsFromNSSF, nil)
|
||||
Register("GET", ue.CustomUriNSSFSubscriptions, ue.GetSubscriptionsFromNSSF, nil)
|
||||
|
||||
Register("POST", cdr.UriCDREvent, cdr.PostCDREventFromNF, nil)
|
||||
Register("POST", cdr.CustomUriCDREvent, cdr.PostCDREventFromNF, nil)
|
||||
|
||||
// 进程网络
|
||||
Register("GET", psnet.UriWs, psnet.ProcessWs, nil)
|
||||
Register("POST", psnet.UriStop, psnet.StopProcess, nil)
|
||||
|
||||
@@ -123,6 +123,8 @@ type YamlConfig struct {
|
||||
LicenseDir string `yaml:"licensedir"`
|
||||
EtcListIMS string `yaml:"etcListIMS"`
|
||||
EtcListDefault string `yaml:"etcListDefault"`
|
||||
DpkgOverwrite bool `yaml:"dpkgOverwrite"`
|
||||
DpkgTimeout int `yaml:"dpkgTimeout"`
|
||||
} `yaml:"ne"`
|
||||
|
||||
Auth struct {
|
||||
|
||||
@@ -41,23 +41,23 @@ webServer:
|
||||
database:
|
||||
type: mysql
|
||||
user: root
|
||||
# password: "1000omc@kp!"
|
||||
# host: "192.168.2.166"
|
||||
# password: 1000omc@kp!
|
||||
# host: 127.0.0.1
|
||||
# port: 33066
|
||||
# name: omc_db
|
||||
name: omc_db
|
||||
backup: d:/local.git/ems.agt/restagent/database
|
||||
password: "root@1234"
|
||||
host: "192.168.5.57"
|
||||
host: "192.168.5.59"
|
||||
port: 3306
|
||||
name: "omc_db"
|
||||
|
||||
# Redis 缓存数据,数据源声明全小写
|
||||
redis:
|
||||
dataSource:
|
||||
# OMC系统使用库
|
||||
default:
|
||||
port: 6379 # Redis port
|
||||
host: "192.168.5.57" # Redis host
|
||||
password: ""
|
||||
host: "192.168.5.59" # Redis host
|
||||
password: "redis@1234"
|
||||
db: 10 # Redis db_num
|
||||
# UDM网元用户库
|
||||
udmuser:
|
||||
@@ -66,7 +66,7 @@ redis:
|
||||
password: ""
|
||||
db: 0 # Redis db_num
|
||||
# 多个数据源时可以用这个指定默认的数据源
|
||||
defaultDataSourceName: "default"
|
||||
defaultDataSourceName: "default"
|
||||
|
||||
# sleep: time delay for after write buffer (millisecond)
|
||||
# deadLine: timeout for io read and write (second)
|
||||
@@ -81,7 +81,7 @@ mml:
|
||||
|
||||
# NE config
|
||||
ne:
|
||||
user: root
|
||||
user: agtuser
|
||||
etcdir: /usr/local/etc
|
||||
bindir: /usr/local/bin
|
||||
omcdir: /usr/local/omc
|
||||
@@ -90,6 +90,10 @@ ne:
|
||||
# backup etc list of IMS,no space
|
||||
etcListIMS: '{*.yaml,mmtel,vars.cfg}'
|
||||
etcListDefault: '{*.yaml,*.conf,*.cfg}'
|
||||
# true/false to overwrite config file when dpkg ne software
|
||||
dpkgOverwrite: false
|
||||
# dpkg timeout (second)
|
||||
dpkgTimeout: 180
|
||||
|
||||
# chk2ne: true/false, if put OmcNeConfig parameters to NE
|
||||
omc:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Makefile for rest agent project
|
||||
|
||||
PROJECT = OMC
|
||||
VERSION = 2.2401.2
|
||||
VERSION = 2.2401.3
|
||||
PLATFORM = amd64
|
||||
ARMPLATFORM = aarch64
|
||||
BUILDDIR = ../../build
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"crypto/x509"
|
||||
"fmt"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -187,11 +186,6 @@ func main() {
|
||||
uriGroup.Use(libSession.SessionHeader())
|
||||
uriGroup.Any("/*any", gin.WrapH(routes.NewRouter()))
|
||||
|
||||
// 注册 pprof 路由
|
||||
go func() {
|
||||
http.ListenAndServe("0.0.0.0:6060", nil)
|
||||
}()
|
||||
|
||||
// 开启监控采集
|
||||
// monitor.StartMonitor(false, "")
|
||||
|
||||
|
||||
@@ -167,6 +167,7 @@ func ExecScript(scriptPath, workDir string) (string, error) {
|
||||
return stdout.String(), nil
|
||||
}
|
||||
|
||||
// CheckIllegal 检查传入的字符串参数中是否包含一些特殊字符
|
||||
func CheckIllegal(args ...string) bool {
|
||||
if args == nil {
|
||||
return false
|
||||
@@ -181,20 +182,23 @@ func CheckIllegal(args ...string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// HasNoPasswordSudo 检查当前用户是否拥有sudo权限
|
||||
func HasNoPasswordSudo() bool {
|
||||
cmd2 := exec.Command("sudo", "-n", "ls")
|
||||
cmd2 := exec.Command("sudo", "-n", "uname")
|
||||
err2 := cmd2.Run()
|
||||
return err2 == nil
|
||||
}
|
||||
|
||||
// SudoHandleCmd 是否拥有sudo权限并拼接
|
||||
func SudoHandleCmd() string {
|
||||
cmd := exec.Command("sudo", "-n", "ls")
|
||||
cmd := exec.Command("sudo", "-n", "uname")
|
||||
if err := cmd.Run(); err == nil {
|
||||
return "sudo "
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// Which 可执行文件是否在系统的PATH环境变量中
|
||||
func Which(name string) bool {
|
||||
_, err := exec.LookPath(name)
|
||||
return err == nil
|
||||
|
||||
@@ -7,23 +7,23 @@ import (
|
||||
|
||||
// 实例化服务层 NeInfoImpl 结构体
|
||||
var NewNeInfoImpl = &NeInfoImpl{
|
||||
NeInfoRepository: repository.NewNeInfoImpl,
|
||||
neInfoRepository: repository.NewNeInfoImpl,
|
||||
}
|
||||
|
||||
// 网元信息 服务层处理
|
||||
type NeInfoImpl struct {
|
||||
// 网元信息数据信息
|
||||
NeInfoRepository repository.INeInfo
|
||||
neInfoRepository repository.INeInfo
|
||||
}
|
||||
|
||||
// SelectNeInfoByNeTypeAndNeID 通过ne_type和ne_id查询网元信息
|
||||
func (r *NeInfoImpl) SelectNeInfoByNeTypeAndNeID(neType, neID string) model.NeInfo {
|
||||
return r.NeInfoRepository.SelectNeInfoByNeTypeAndNeID(neType, neID)
|
||||
return r.neInfoRepository.SelectNeInfoByNeTypeAndNeID(neType, neID)
|
||||
}
|
||||
|
||||
// SelectNeList 查询网元列表
|
||||
func (r *NeInfoImpl) SelectNeList(ne model.NeInfo, bandStatus bool) []model.NeInfo {
|
||||
list := r.NeInfoRepository.SelectNeList(ne)
|
||||
list := r.neInfoRepository.SelectNeList(ne)
|
||||
|
||||
// 网元直连读取网元服务状态
|
||||
if bandStatus {
|
||||
@@ -32,9 +32,12 @@ func (r *NeInfoImpl) SelectNeList(ne model.NeInfo, bandStatus bool) []model.NeIn
|
||||
v := (*neList)[i]
|
||||
result, err := NeState(v)
|
||||
if err != nil {
|
||||
(*neList)[i].ServerState = map[string]any{}
|
||||
(*neList)[i].ServerState = map[string]any{
|
||||
"online": false,
|
||||
}
|
||||
continue
|
||||
}
|
||||
result["online"] = true
|
||||
(*neList)[i].ServerState = result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +97,8 @@ func (r *SysDictDataImpl) DeleteDictDataByCodes(dictCodes []string) (int64, erro
|
||||
func (r *SysDictDataImpl) InsertDictData(sysDictData model.SysDictData) string {
|
||||
insertId := r.sysDictDataRepository.InsertDictData(sysDictData)
|
||||
if insertId != "" {
|
||||
// 刷新缓存
|
||||
r.sysDictTypeService.ClearDictCache(sysDictData.DictType)
|
||||
r.sysDictTypeService.LoadingDictCache(sysDictData.DictType)
|
||||
}
|
||||
return insertId
|
||||
@@ -106,6 +108,8 @@ func (r *SysDictDataImpl) InsertDictData(sysDictData model.SysDictData) string {
|
||||
func (r *SysDictDataImpl) UpdateDictData(sysDictData model.SysDictData) int64 {
|
||||
rows := r.sysDictDataRepository.UpdateDictData(sysDictData)
|
||||
if rows > 0 {
|
||||
// 刷新缓存
|
||||
r.sysDictTypeService.ClearDictCache(sysDictData.DictType)
|
||||
r.sysDictTypeService.LoadingDictCache(sysDictData.DictType)
|
||||
}
|
||||
return rows
|
||||
|
||||
@@ -1,16 +1,9 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"ems.agt/src/framework/cmd"
|
||||
"ems.agt/src/framework/config"
|
||||
"ems.agt/src/framework/i18n"
|
||||
"ems.agt/src/framework/utils/ctx"
|
||||
"ems.agt/src/framework/utils/ssh"
|
||||
"ems.agt/src/framework/vo/result"
|
||||
netElementService "ems.agt/src/modules/network_element/service"
|
||||
traceService "ems.agt/src/modules/trace/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
@@ -18,7 +11,6 @@ import (
|
||||
|
||||
// 实例化控制层 TcpdumpController 结构体
|
||||
var NewTcpdump = &TcpdumpController{
|
||||
NeInfoService: netElementService.NewNeInfoImpl,
|
||||
TcpdumpService: traceService.NewTcpdumpImpl,
|
||||
}
|
||||
|
||||
@@ -26,23 +18,19 @@ var NewTcpdump = &TcpdumpController{
|
||||
//
|
||||
// PATH /tcpdump
|
||||
type TcpdumpController struct {
|
||||
// 网元信息服务
|
||||
NeInfoService netElementService.INeInfo
|
||||
// 信令抓包服务
|
||||
TcpdumpService traceService.ITcpdump
|
||||
}
|
||||
|
||||
// 网元发送执行 pcap
|
||||
// 网元抓包PACP 开始
|
||||
//
|
||||
// POST /ne
|
||||
func (s *TcpdumpController) NeTask(c *gin.Context) {
|
||||
// POST /start
|
||||
func (s *TcpdumpController) DumpStart(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var body struct {
|
||||
NeType string `json:"neType" binding:"required"` // 网元类型
|
||||
NeId string `json:"neId" binding:"required"` // 网元ID
|
||||
Timeout int `json:"timeout" binding:"required"` // 超时时间
|
||||
Cmd string `json:"cmd" binding:"required"` // 命令
|
||||
Timestamp string `json:"timestamp" binding:"required"` // 时间戳
|
||||
NeType string `json:"neType" binding:"required"` // 网元类型
|
||||
NeId string `json:"neId" binding:"required"` // 网元ID
|
||||
Cmd string `json:"cmd" binding:"required"` // 命令 "-n -s 0 -v -w"
|
||||
}
|
||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||
if err != nil {
|
||||
@@ -50,47 +38,32 @@ func (s *TcpdumpController) NeTask(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 检查网元信息
|
||||
neInfo := s.NeInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, body.NeId)
|
||||
if neInfo.NeId != body.NeId {
|
||||
// 找不到 %s %s 对应网元信息
|
||||
msg := i18n.TTemplate(language, "trace.tcpdump.noData", map[string]any{"type": body.NeType, "id": body.NeId})
|
||||
fileName, err := s.TcpdumpService.DumpStart(body.NeType, body.NeId, body.Cmd)
|
||||
if err != nil {
|
||||
msg := err.Error()
|
||||
if msg == "noData" {
|
||||
// 找不到 %s %s 对应网元信息
|
||||
msg = i18n.TTemplate(language, "trace.tcpdump.noData", map[string]any{"type": body.NeType, "id": body.NeId})
|
||||
}
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
|
||||
filePcapName := fmt.Sprintf("%s_%s_%s.pcap", body.Timestamp, body.NeType, body.NeId)
|
||||
fileLogName := fmt.Sprintf("%s_%s_%s.log", body.Timestamp, body.NeType, body.NeId)
|
||||
writeLog := fmt.Sprintf(" > %s 2>&1 \ncat %s", fileLogName, fileLogName) // 执行信息写入日志文件,放置弹出code 127
|
||||
cmdStr := fmt.Sprintf("cd /tmp \nsudo timeout %d tcpdump -i any %s -s0 -w %s", body.Timeout, body.Cmd, filePcapName)
|
||||
usernameNe := config.Get("ne.user").(string) // 网元统一用户
|
||||
sshHost := fmt.Sprintf("%s@%s", usernameNe, neInfo.IP)
|
||||
msg, err := cmd.ExecWithCheck("ssh", sshHost, cmdStr+writeLog)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
if strings.Contains(msg, "command not found") {
|
||||
c.JSON(200, result.ErrMsg("Command [tcpdump] Not Found"))
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, result.OkData(map[string]any{
|
||||
"cmd": cmdStr,
|
||||
"msg": msg,
|
||||
"fileName": filePcapName,
|
||||
"msg": "tcpdump started",
|
||||
"out": fileName,
|
||||
"log": "",
|
||||
}))
|
||||
}
|
||||
|
||||
// 网元抓包pcap文件下载
|
||||
// 网元抓包PACP 结束
|
||||
//
|
||||
// POST /download
|
||||
func (s *TcpdumpController) Download(c *gin.Context) {
|
||||
// POST /stop
|
||||
func (s *TcpdumpController) DumpStop(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var body struct {
|
||||
NeType string `json:"neType" binding:"required"` // 网元类型
|
||||
NeId string `json:"neId" binding:"required"` // 网元ID
|
||||
FileName string `form:"fileName" ` // 文件名
|
||||
FileName string `json:"fileName"` // 文件名 查看日志信息
|
||||
}
|
||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||
if err != nil {
|
||||
@@ -98,37 +71,34 @@ func (s *TcpdumpController) Download(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 检查网元信息
|
||||
neInfo := s.NeInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, body.NeId)
|
||||
if neInfo.NeId != body.NeId {
|
||||
// 找不到 %s %s 对应网元信息
|
||||
msg := i18n.TTemplate(language, "trace.tcpdump.noData", map[string]any{"type": body.NeType, "id": body.NeId})
|
||||
logMsg, err := s.TcpdumpService.DumpStop(body.NeType, body.NeId, body.FileName)
|
||||
if err != nil {
|
||||
msg := err.Error()
|
||||
if msg == "noData" {
|
||||
// 找不到 %s %s 对应网元信息
|
||||
msg := i18n.TTemplate(language, "trace.tcpdump.noData", map[string]any{"type": body.NeType, "id": body.NeId})
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
|
||||
nePath := fmt.Sprintf("/tmp/%s", body.FileName)
|
||||
localPath := fmt.Sprintf("/tmp/omc/tcpdump/%s", body.FileName)
|
||||
err = ssh.FileSCPNeToLocal(neInfo.IP, nePath, localPath)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
c.FileAttachment(localPath, body.FileName)
|
||||
c.JSON(200, result.OkData(map[string]any{
|
||||
"msg": "tcpdump stopped",
|
||||
"out": body.FileName,
|
||||
"log": logMsg,
|
||||
}))
|
||||
}
|
||||
|
||||
// 网元发送执行 pcap
|
||||
// UPF标准版内部抓包
|
||||
//
|
||||
// POST /neUPF
|
||||
func (s *TcpdumpController) NeUPFTask(c *gin.Context) {
|
||||
// POST /traceUPF
|
||||
func (s *TcpdumpController) TraceUPF(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var body struct {
|
||||
NeType string `json:"neType" binding:"required"` // 网元类型
|
||||
NeId string `json:"neId" binding:"required"` // 网元ID
|
||||
RunType string `json:"runType" binding:"required"` // 执行开始start还是停止stop
|
||||
Cmd string `json:"cmd" binding:"required"` // 命令
|
||||
Timestamp string `json:"timestamp" binding:"required"` // 时间戳
|
||||
NeType string `json:"neType" binding:"required"` // 网元类型
|
||||
NeId string `json:"neId" binding:"required"` // 网元ID
|
||||
Cmd string `json:"cmd" binding:"required"` // 命令
|
||||
}
|
||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||
if err != nil {
|
||||
@@ -136,154 +106,19 @@ func (s *TcpdumpController) NeUPFTask(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 检查网元信息
|
||||
neInfo := s.NeInfoService.SelectNeInfoByNeTypeAndNeID(body.NeType, body.NeId)
|
||||
if neInfo.NeId != body.NeId {
|
||||
msg := i18n.TTemplate(language, "trace.tcpdump.noData", map[string]any{"type": body.NeType, "id": body.NeId})
|
||||
fileName, logMsg, err := s.TcpdumpService.DumpUPF(body.NeType, body.NeId, body.Cmd)
|
||||
if err != nil {
|
||||
msg := err.Error()
|
||||
if msg == "noData" {
|
||||
// 找不到 %s %s 对应网元信息
|
||||
msg = i18n.TTemplate(language, "trace.tcpdump.noData", map[string]any{"type": body.NeType, "id": body.NeId})
|
||||
}
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
|
||||
// 开始telnet
|
||||
if body.RunType == "start_telnet" {
|
||||
filePcapName := fmt.Sprintf("%s_%s_%s.pcap", body.Timestamp, body.NeType, body.NeId)
|
||||
cmdStr := fmt.Sprintf("%s file %s", body.Cmd, filePcapName)
|
||||
// 进行连接telnet
|
||||
resultStr, err := s.TcpdumpService.UPFTelnet(neInfo.IP, cmdStr)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
// 处理结果
|
||||
s := strings.Index(resultStr, "pcap dispatch trace:")
|
||||
if s == -1 {
|
||||
s = strings.Index(resultStr, "Write ")
|
||||
}
|
||||
if s != -1 {
|
||||
e := strings.Index(resultStr, "\r\nupfd1#")
|
||||
resultStr = resultStr[s:e]
|
||||
} else {
|
||||
resultStr = "No stoppable found"
|
||||
}
|
||||
c.JSON(200, result.OkData(map[string]any{
|
||||
"cmd": cmdStr,
|
||||
"msg": resultStr,
|
||||
"fileName": filePcapName,
|
||||
}))
|
||||
return
|
||||
}
|
||||
// 停止telnet
|
||||
if body.RunType == "stop_telnet" {
|
||||
filePcapName := fmt.Sprintf("%s_%s_%s.pcap", body.Timestamp, body.NeType, body.NeId)
|
||||
cmdStr := "pcap dispatch trace off"
|
||||
// 进行连接telnet
|
||||
resultStr, err := s.TcpdumpService.UPFTelnet(neInfo.IP, cmdStr)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
// 处理结果
|
||||
s := strings.Index(resultStr, "pcap dispatch trace:")
|
||||
if s != -1 {
|
||||
e := strings.Index(resultStr, "\r\nupfd1#")
|
||||
resultStr = resultStr[s:e]
|
||||
} else {
|
||||
resultStr = "Executed, please stop before proceeding"
|
||||
}
|
||||
c.JSON(200, result.OkData(map[string]any{
|
||||
"cmd": cmdStr,
|
||||
"msg": resultStr,
|
||||
"fileName": filePcapName,
|
||||
}))
|
||||
return
|
||||
}
|
||||
|
||||
// 开始-脚本字符串
|
||||
if body.RunType == "start_str" {
|
||||
fileLogName := fmt.Sprintf("%s_%s_%s.log", body.Timestamp, body.NeType, body.NeId)
|
||||
filePcapName := fmt.Sprintf("%s_%s_%s.pcap", body.Timestamp, body.NeType, body.NeId)
|
||||
scriptStr := "set capcmd [lindex $argv 0]\nspawn telnet localhost 5002\nexpect \"upfd1# \"\nsend \"$capcmd\\n\"\nexpect \"upfd1# \"\nsend \"quit\\n\"\nexpect \"eof\""
|
||||
writeLog := fmt.Sprintf(" > %s 2>&1 \ncat %s", fileLogName, fileLogName) // 执行信息写入日志文件输出,避免弹出code 127
|
||||
|
||||
capCmdStr := fmt.Sprintf("%s file %s", body.Cmd, filePcapName)
|
||||
|
||||
cmdStr := fmt.Sprintf("cd /tmp\n\necho '%s' > cap.sh\n\nchmod +x cap.sh\n\nexpect ./cap.sh '%s'%s", scriptStr, capCmdStr, writeLog)
|
||||
usernameNe := config.Get("ne.user").(string) // 网元统一用户
|
||||
sshHost := fmt.Sprintf("%s@%s", usernameNe, neInfo.IP)
|
||||
msg, err := cmd.ExecWithCheck("ssh", sshHost, cmdStr)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
if strings.Contains(msg, "command not found") {
|
||||
c.JSON(200, result.ErrMsg("Command [expect] Not Found"))
|
||||
return
|
||||
}
|
||||
if strings.Contains(msg, "Unable to connect to remote host") {
|
||||
c.JSON(200, result.ErrMsg("Connection Refused"))
|
||||
return
|
||||
}
|
||||
s := strings.Index(msg, "pcap dispatch trace:")
|
||||
if s != -1 {
|
||||
e := strings.Index(msg, "\r\nupfd1#")
|
||||
msg = msg[s:e]
|
||||
} else {
|
||||
msg = "Executed, please stop before proceeding"
|
||||
}
|
||||
c.JSON(200, result.OkData(map[string]any{
|
||||
"cmd": capCmdStr,
|
||||
"msg": msg,
|
||||
"fileName": filePcapName,
|
||||
}))
|
||||
return
|
||||
}
|
||||
// 停止-脚本字符串
|
||||
if body.RunType == "stop_str" {
|
||||
fileLogName := fmt.Sprintf("%s_%s_%s.log", body.Timestamp, body.NeType, body.NeId)
|
||||
filePcapName := fmt.Sprintf("%s_%s_%s.pcap", body.Timestamp, body.NeType, body.NeId)
|
||||
scriptStr := "set capcmd [lindex $argv 0]\nspawn telnet localhost 5002\nexpect \"upfd1# \"\nsend \"$capcmd\\n\"\nexpect \"upfd1# \"\nsend \"quit\\n\"\nexpect \"eof\""
|
||||
writeLog := fmt.Sprintf(" > %s 2>&1 \ncat %s", fileLogName, fileLogName) // 执行信息写入日志文件输出,避免弹出code 127
|
||||
|
||||
capCmdStr := body.Cmd
|
||||
|
||||
cmdStr := fmt.Sprintf("cd /tmp\n\necho '%s' > cap.sh\n\nchmod +x cap.sh\n\nexpect ./cap.sh '%s'%s", scriptStr, capCmdStr, writeLog)
|
||||
|
||||
usernameNe := config.Get("ne.user").(string) // 网元统一用户
|
||||
sshHost := fmt.Sprintf("%s@%s", usernameNe, neInfo.IP)
|
||||
msg, err := cmd.ExecWithCheck("ssh", sshHost, cmdStr)
|
||||
if err != nil {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
if strings.Contains(msg, "command not found") {
|
||||
c.JSON(200, result.ErrMsg("Command [expect] Not Found"))
|
||||
return
|
||||
}
|
||||
if strings.Contains(msg, "Unable to connect to remote host") {
|
||||
c.JSON(200, result.ErrMsg("Connection Refused"))
|
||||
return
|
||||
}
|
||||
s := strings.Index(msg, "pcap dispatch trace:")
|
||||
if s == -1 {
|
||||
s = strings.Index(msg, "Write ")
|
||||
// 停止写入的文件名
|
||||
startIndex := strings.LastIndex(msg, "/") + 1
|
||||
endIndex := strings.LastIndex(msg, ",")
|
||||
filePcapName = msg[startIndex:endIndex]
|
||||
}
|
||||
if s != -1 {
|
||||
e := strings.Index(msg, "\r\nupfd1#")
|
||||
msg = msg[s:e]
|
||||
} else {
|
||||
msg = "No stoppable found"
|
||||
}
|
||||
c.JSON(200, result.OkData(map[string]any{
|
||||
"cmd": capCmdStr,
|
||||
"msg": msg,
|
||||
"fileName": filePcapName,
|
||||
}))
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(200, result.ErrMsg("Please select RunType to execute: start_telnet/stop_telnet/start_str/stop_str"))
|
||||
c.JSON(200, result.OkData(map[string]any{
|
||||
"msg": "trace UPF dump pacp",
|
||||
"out": fileName,
|
||||
"log": logMsg,
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
package service
|
||||
|
||||
// 通用请求 服务层接口
|
||||
// 信令抓包 服务层接口
|
||||
type ITcpdump interface {
|
||||
// UPFTelnetStart UPF进行telnet抓包
|
||||
UPFTelnet(neIp, cmdStr string) (string, error)
|
||||
// DumpStart 触发tcpdump开始抓包 filePcapName, err
|
||||
DumpStart(neType, neId, cmdStr string) (string, error)
|
||||
|
||||
// DumpStop 停止已存在抓包句柄
|
||||
DumpStop(neType, neId, fileName string) (string, error)
|
||||
|
||||
// DumpUPF UPF标准版抓包
|
||||
DumpUPF(neType, neId, cmdStr string) (string, string, error)
|
||||
}
|
||||
|
||||
@@ -2,40 +2,184 @@ package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"ems.agt/src/framework/cmd"
|
||||
"ems.agt/src/framework/config"
|
||||
"ems.agt/src/framework/logger"
|
||||
"ems.agt/src/framework/utils/date"
|
||||
neService "ems.agt/src/modules/network_element/service"
|
||||
)
|
||||
|
||||
// 实例化服务层 TcpdumpImpl 结构体
|
||||
var NewTcpdumpImpl = &TcpdumpImpl{
|
||||
neInfoService: neService.NewNeInfoImpl,
|
||||
tcpdumpPIDMap: map[string]string{},
|
||||
}
|
||||
|
||||
// 通用请求 服务层处理
|
||||
// 信令抓包 服务层处理
|
||||
type TcpdumpImpl struct {
|
||||
// 网元信息服务
|
||||
neInfoService neService.INeInfo
|
||||
// 抓包进程PID
|
||||
tcpdumpPIDMap map[string]string
|
||||
}
|
||||
|
||||
// UPFTelnetStart UPF进行telnet抓包
|
||||
func (s *TcpdumpImpl) UPFTelnet(neIp, cmdStr string) (string, error) {
|
||||
// 创建TCP连接
|
||||
conn, err := net.Dial("tcp", fmt.Sprintf("%s:%d", neIp, 5002))
|
||||
if err != nil {
|
||||
// DumpStart 触发tcpdump开始抓包 filePcapName, err
|
||||
func (s *TcpdumpImpl) DumpStart(neType, neId, cmdStr string) (string, error) {
|
||||
// 检查网元信息
|
||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(neType, neId)
|
||||
if neInfo.NeId != neId {
|
||||
return "", fmt.Errorf("noData")
|
||||
}
|
||||
|
||||
// SSH命令
|
||||
usernameNe := config.Get("ne.user").(string) // 网元统一用户
|
||||
sshHost := fmt.Sprintf("%s@%s", usernameNe, neInfo.IP)
|
||||
|
||||
// 是否拥有sudo权限并拼接
|
||||
withSudo := ""
|
||||
if _, err := cmd.ExecWithCheck("ssh", sshHost, "sudo -n uname"); err == nil {
|
||||
withSudo = "sudo "
|
||||
}
|
||||
|
||||
if msg, err := cmd.ExecWithCheck("ssh", sshHost, fmt.Sprintf("%s tcpdump --version", withSudo)); err != nil {
|
||||
// stderr: bash: tcpdump:未找到命令 => exit status 127
|
||||
msg = strings.TrimSpace(msg)
|
||||
logger.Warnf("DumpStart err: %s => %s", msg, err.Error())
|
||||
return "", fmt.Errorf(msg)
|
||||
}
|
||||
|
||||
// 拼装命令
|
||||
neTypeID := fmt.Sprintf("%s_%s", neInfo.NeType, neInfo.NeId)
|
||||
timeStr := date.ParseDateToStr(time.Now(), date.YYYYMMDDHHMMSS)
|
||||
fileName := fmt.Sprintf("%s_%s", timeStr, neTypeID)
|
||||
sendCmd := fmt.Sprintf("cd /tmp \n %s nohup timeout 30m tcpdump -i any %s -s0 -w %s.pcap > %s.log 2>&1 & \necho $!", withSudo, cmdStr, fileName, fileName)
|
||||
// cd /tmp
|
||||
// sudo nohup timeout 60m tcpdump -i any -n -s 0 -v -w -s0 -w 20240115140822_UDM_001.pcap > 20240115140822_UDM_001.log 2>&1 & echo $!
|
||||
msg, err := cmd.ExecWithCheck("ssh", sshHost, sendCmd)
|
||||
msg = strings.TrimSpace(msg)
|
||||
if err != nil || strings.HasPrefix(msg, "stderr:") {
|
||||
logger.Warnf("DumpStart err: %s => %s", msg, err.Error())
|
||||
return "", err
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
fmt.Fprintln(conn, cmdStr)
|
||||
|
||||
// 读取内容
|
||||
time.Sleep(time.Duration(300) * time.Millisecond)
|
||||
buf := make([]byte, 1024*8)
|
||||
n, err := conn.Read(buf)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(buf[0:n]), nil
|
||||
// 检查进程 ps aux | grep tcpdump
|
||||
// 强杀 sudo pkill tcpdump
|
||||
s.tcpdumpPIDMap[neTypeID] = msg
|
||||
return fileName, err
|
||||
}
|
||||
|
||||
// DumpStop 停止已存在抓包句柄
|
||||
func (s *TcpdumpImpl) DumpStop(neType, neId, fileName string) (string, error) {
|
||||
// 检查网元信息
|
||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(neType, neId)
|
||||
if neInfo.NeId != neId {
|
||||
return "", fmt.Errorf("noData")
|
||||
}
|
||||
|
||||
// SSH命令
|
||||
usernameNe := config.Get("ne.user").(string) // 网元统一用户
|
||||
sshHost := fmt.Sprintf("%s@%s", usernameNe, neInfo.IP)
|
||||
|
||||
// 是否拥有sudo权限并拼接
|
||||
withSudo := ""
|
||||
if _, err := cmd.ExecWithCheck("ssh", sshHost, "sudo -n uname"); err == nil {
|
||||
withSudo = "sudo "
|
||||
}
|
||||
|
||||
// 是否存在进程
|
||||
neTypeID := fmt.Sprintf("%s_%s", neInfo.NeType, neInfo.NeId)
|
||||
pid, ok := s.tcpdumpPIDMap[neTypeID]
|
||||
if !ok || pid == "" {
|
||||
return "", fmt.Errorf("tcpdump is not running")
|
||||
}
|
||||
|
||||
// 查看日志
|
||||
viewLogFile := ""
|
||||
if fileName != "" && strings.Contains(fileName, neTypeID) {
|
||||
viewLogFile = fmt.Sprintf("\n cat %s.log", fileName)
|
||||
}
|
||||
|
||||
// 拼装命令
|
||||
sendCmd := fmt.Sprintf("cd /tmp \n %s kill %s %s", withSudo, pid, viewLogFile)
|
||||
msg, err := cmd.ExecWithCheck("ssh", sshHost, sendCmd)
|
||||
delete(s.tcpdumpPIDMap, neTypeID)
|
||||
if err != nil || strings.HasPrefix(msg, "stderr:") {
|
||||
logger.Warnf("DumpStop err: %s => %s", strings.TrimSpace(msg), err.Error())
|
||||
return "", err
|
||||
}
|
||||
return msg, nil
|
||||
}
|
||||
|
||||
// DumpUPF UPF标准版抓包
|
||||
func (s *TcpdumpImpl) DumpUPF(neType, neId, cmdStr string) (string, string, error) {
|
||||
// 检查网元信息
|
||||
neInfo := s.neInfoService.SelectNeInfoByNeTypeAndNeID(neType, neId)
|
||||
if neInfo.NeId != neId {
|
||||
return "", "", fmt.Errorf("noData")
|
||||
}
|
||||
|
||||
// SSH命令
|
||||
usernameNe := config.Get("ne.user").(string) // 网元统一用户
|
||||
sshHost := fmt.Sprintf("%s@%s", usernameNe, neInfo.IP)
|
||||
|
||||
// 是否拥有sudo权限并拼接
|
||||
withSudo := ""
|
||||
if _, err := cmd.ExecWithCheck("ssh", sshHost, "sudo -n uname"); err == nil {
|
||||
withSudo = "sudo "
|
||||
}
|
||||
|
||||
if msg, err := cmd.ExecWithCheck("ssh", sshHost, fmt.Sprintf("%s expect -version", withSudo)); err != nil {
|
||||
// stderr: bash: expect:未找到命令 => exit status 127
|
||||
msg = strings.TrimSpace(msg)
|
||||
logger.Warnf("DumpUPF err: %s => %s", msg, err.Error())
|
||||
return "", "", fmt.Errorf(msg)
|
||||
}
|
||||
|
||||
// 拼装命令
|
||||
neTypeID := fmt.Sprintf("%s_%s", neInfo.NeType, neInfo.NeId)
|
||||
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\""
|
||||
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)
|
||||
|
||||
// 以off结尾是停止抓包,不需要写文件
|
||||
pcapCmd := cmdStr
|
||||
if !strings.HasSuffix(pcapCmd, "off") {
|
||||
pcapCmd = fmt.Sprintf("%s file %s.pcap", cmdStr, fileName)
|
||||
}
|
||||
sendCmd := fmt.Sprintf("cd /tmp \n%s\n expect ./pcapUPF.sh '%s' %s", writePcapFile, pcapCmd, writeLogFile)
|
||||
// cd /tmp
|
||||
// echo '' >
|
||||
// expect ./cap.sh > pcapUPF.sh
|
||||
// sudo chmod +x pcapUPF.sh
|
||||
// expect ./cap.sh 'pcap dispatch trace off' > 20240115165701_UDM_001.log 2>&1
|
||||
// cat 20240115165701_UDM_001.log
|
||||
msg, err := cmd.ExecWithCheck("ssh", sshHost, sendCmd)
|
||||
msg = strings.TrimSpace(msg)
|
||||
if err != nil || strings.HasPrefix(msg, "stderr:") {
|
||||
logger.Warnf("DumpUPF err: %s => %s", msg, err.Error())
|
||||
return "", "", err
|
||||
}
|
||||
if strings.Contains(msg, "Unable to connect to remote host") {
|
||||
return "", "", fmt.Errorf("connection refused")
|
||||
}
|
||||
// 以off结尾是停止抓包,不需要写文件
|
||||
if strings.HasSuffix(pcapCmd, "off") {
|
||||
if strings.Contains(msg, "Write ") {
|
||||
lastTmpIndex := strings.LastIndex(msg, "/tmp/")
|
||||
text := msg[lastTmpIndex+5:]
|
||||
extensionIndex := strings.LastIndex(text, ".pcap")
|
||||
if extensionIndex != -1 {
|
||||
fileName = text[:extensionIndex]
|
||||
}
|
||||
} else {
|
||||
fileName = ""
|
||||
}
|
||||
}
|
||||
return fileName, msg, err
|
||||
}
|
||||
|
||||
@@ -16,20 +16,20 @@ func Setup(router *gin.Engine) {
|
||||
// 信令抓包
|
||||
tcpdumpGroup := router.Group("/tcpdump")
|
||||
{
|
||||
tcpdumpGroup.POST("/ne",
|
||||
tcpdumpGroup.POST("/start",
|
||||
middleware.PreAuthorize(nil),
|
||||
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.tcpdump", collectlogs.BUSINESS_TYPE_OTHER)),
|
||||
controller.NewTcpdump.NeTask,
|
||||
controller.NewTcpdump.DumpStart,
|
||||
)
|
||||
tcpdumpGroup.POST("/neUPF",
|
||||
tcpdumpGroup.POST("/stop",
|
||||
middleware.PreAuthorize(nil),
|
||||
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.tcpdump", collectlogs.BUSINESS_TYPE_OTHER)),
|
||||
controller.NewTcpdump.NeUPFTask,
|
||||
controller.NewTcpdump.DumpStop,
|
||||
)
|
||||
tcpdumpGroup.POST("/download",
|
||||
tcpdumpGroup.POST("/traceUPF",
|
||||
middleware.PreAuthorize(nil),
|
||||
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.tcpdump", collectlogs.BUSINESS_TYPE_IMPORT)),
|
||||
controller.NewTcpdump.Download,
|
||||
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.tcpdump", collectlogs.BUSINESS_TYPE_OTHER)),
|
||||
controller.NewTcpdump.TraceUPF,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user