fix: 抓包sudo执行
This commit is contained in:
@@ -64,7 +64,7 @@ func TcpdumpNeTask(w http.ResponseWriter, r *http.Request) {
|
|||||||
filePcapName := fmt.Sprintf("tmp_%s_%s_%d.pcap", body.NeType, body.NeId, time.Now().UnixMilli())
|
filePcapName := fmt.Sprintf("tmp_%s_%s_%d.pcap", body.NeType, body.NeId, time.Now().UnixMilli())
|
||||||
fileLogName := fmt.Sprintf("tmp_%s_%s_%d.log", body.NeType, body.NeId, time.Now().UnixMilli())
|
fileLogName := fmt.Sprintf("tmp_%s_%s_%d.log", body.NeType, body.NeId, time.Now().UnixMilli())
|
||||||
writeLog := fmt.Sprintf(" >> %s 2>&1 \ncat %s", fileLogName, fileLogName) // 执行信息写入日志文件,放置弹出code 127
|
writeLog := fmt.Sprintf(" >> %s 2>&1 \ncat %s", fileLogName, fileLogName) // 执行信息写入日志文件,放置弹出code 127
|
||||||
cmdStr := fmt.Sprintf("cd /tmp \ntimeout %d tcpdump -i any %s -s0 -w %s", body.Timeout, body.Cmd, filePcapName)
|
cmdStr := fmt.Sprintf("cd /tmp \n%stimeout %d tcpdump -i any %s -s0 -w %s", cmd.SudoHandleCmd(), body.Timeout, body.Cmd, filePcapName)
|
||||||
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+writeLog)
|
msg, err := cmd.ExecWithCheck("ssh", sshHost, cmdStr+writeLog)
|
||||||
|
|||||||
Reference in New Issue
Block a user