Merge branch 'main' of http://192.168.2.166:3180/OMC/ems_backend
This commit is contained in:
@@ -272,12 +272,12 @@ func TcpdumpNeUPFTask(w http.ResponseWriter, r *http.Request) {
|
|||||||
if body.RunType == "start_str" {
|
if body.RunType == "start_str" {
|
||||||
fileLogName := fmt.Sprintf("tmp_%s_%s.log", body.NeType, body.NeId)
|
fileLogName := fmt.Sprintf("tmp_%s_%s.log", body.NeType, body.NeId)
|
||||||
filePcapName := fmt.Sprintf("tmp_%s_%s.pcap", body.NeType, body.NeId)
|
filePcapName := fmt.Sprintf("tmp_%s_%s.pcap", body.NeType, body.NeId)
|
||||||
scriptStr := "#!/usr/bin/expect\nset capcmd [lindex $argv 0]\nspawn telnet localhost 5002\nexpect \"upfd1# \"\nsend \"$capcmd\\n\"\nexpect \"upfd1# \"\nsend \"quit\\n\"\nexpect \"eof\""
|
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
|
writeLog := fmt.Sprintf(" > %s 2>&1 \ncat %s", fileLogName, fileLogName) // 执行信息写入日志文件输出,避免弹出code 127
|
||||||
|
|
||||||
capCmdStr := fmt.Sprintf("%s file %s", body.Cmd, filePcapName)
|
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\n./cap.sh '%s'%s", scriptStr, capCmdStr, writeLog)
|
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 := conf.Get("ne.user").(string) // 网元统一用户
|
usernameNe := conf.Get("ne.user").(string) // 网元统一用户
|
||||||
sshHost := fmt.Sprintf("%s@%s", usernameNe, neInfo.Ip)
|
sshHost := fmt.Sprintf("%s@%s", usernameNe, neInfo.Ip)
|
||||||
msg, err := cmd.ExecWithCheck("ssh", sshHost, cmdStr)
|
msg, err := cmd.ExecWithCheck("ssh", sshHost, cmdStr)
|
||||||
@@ -303,12 +303,12 @@ func TcpdumpNeUPFTask(w http.ResponseWriter, r *http.Request) {
|
|||||||
if body.RunType == "stop_str" {
|
if body.RunType == "stop_str" {
|
||||||
fileLogName := fmt.Sprintf("tmp_%s_%s.log", body.NeType, body.NeId)
|
fileLogName := fmt.Sprintf("tmp_%s_%s.log", body.NeType, body.NeId)
|
||||||
filePcapName := fmt.Sprintf("tmp_%s_%s.pcap", body.NeType, body.NeId)
|
filePcapName := fmt.Sprintf("tmp_%s_%s.pcap", body.NeType, body.NeId)
|
||||||
scriptStr := "#!/usr/bin/expect\nset capcmd [lindex $argv 0]\nspawn telnet localhost 5002\nexpect \"upfd1# \"\nsend \"$capcmd\\n\"\nexpect \"upfd1# \"\nsend \"quit\\n\"\nexpect \"eof\""
|
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
|
writeLog := fmt.Sprintf(" > %s 2>&1 \ncat %s", fileLogName, fileLogName) // 执行信息写入日志文件输出,避免弹出code 127
|
||||||
|
|
||||||
capCmdStr := body.Cmd
|
capCmdStr := body.Cmd
|
||||||
|
|
||||||
cmdStr := fmt.Sprintf("cd /tmp\n\necho '%s' > cap.sh\n\nchmod +x cap.sh\n\n./cap.sh '%s'%s", scriptStr, capCmdStr, writeLog)
|
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 := conf.Get("ne.user").(string) // 网元统一用户
|
usernameNe := conf.Get("ne.user").(string) // 网元统一用户
|
||||||
sshHost := fmt.Sprintf("%s@%s", usernameNe, neInfo.Ip)
|
sshHost := fmt.Sprintf("%s@%s", usernameNe, neInfo.Ip)
|
||||||
|
|||||||
Reference in New Issue
Block a user