1
0

feat: 更新代码

This commit is contained in:
TsMask
2023-10-20 20:12:11 +08:00
parent bbdced9633
commit d63db9dd6c
14 changed files with 274 additions and 60 deletions

View File

@@ -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())
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
cmdStr := fmt.Sprintf("cd /tmp \n%stimeout %d tcpdump -i any %s -s0 -w %s", cmd.SudoHandleCmd(), body.Timeout, body.Cmd, filePcapName)
cmdStr := fmt.Sprintf("cd /tmp \nsudo timeout %d tcpdump -i any %s -s0 -w %s", body.Timeout, body.Cmd, filePcapName)
usernameNe := conf.Get("ne.user").(string) // 网元统一用户
sshHost := fmt.Sprintf("%s@%s", usernameNe, neInfo.Ip)
msg, err := cmd.ExecWithCheck("ssh", sshHost, cmdStr+writeLog)