Commit 2ade0c91 authored by 陈子龙's avatar 陈子龙

Merge branch 'dev-czl' into dev

parents 38a2f5b3 0dc7a0c7
...@@ -465,7 +465,7 @@ func (h *HostManageSvc) ListStateHostManage(req request.StateHostManageReq) (err ...@@ -465,7 +465,7 @@ func (h *HostManageSvc) ListStateHostManage(req request.StateHostManageReq) (err
for i := 0; i < len(hostManageList); i++ { for i := 0; i < len(hostManageList); i++ {
go func(i int) { go func(i int) {
//检测ip连通性 //检测ip连通性
connStatus := StatusDetection(hostManageList[i].Ip) connStatus := StatusDetection(cast.ToString(hostManageList[i].Id))
if connStatus == 1 { if connStatus == 1 {
lock.Lock() lock.Lock()
fail = append(fail, hostManageList[i].Id) fail = append(fail, hostManageList[i].Id)
...@@ -679,25 +679,13 @@ func (h *HostManageSvc) SaveIpExceptionList(req request.HostIpExceptionListReq) ...@@ -679,25 +679,13 @@ func (h *HostManageSvc) SaveIpExceptionList(req request.HostIpExceptionListReq)
func StatusDetection(ip string) (ipConn int) { func StatusDetection(ip string) (ipConn int) {
var cmd *exec.Cmd var cmd *exec.Cmd
cmd = exec.Command("ansible", fmt.Sprintf("%s", AnsibleIp+ip), "-m", "ping") cmd = exec.Command("ansible", fmt.Sprintf("%s", AnsibleIp+ip), "-m", "ping")
err := cmd.Run() output, err := cmd.Output()
if err != nil { if err != nil {
conf.Logger.Error("测试 "+ip+" 连通性失败", zap.Error(err)) conf.Logger.Error("测试 "+ip+" 连通性失败", zap.Error(err))
return 1 return 1
} }
if cmd.ProcessState.Success() { conf.Logger.Debug("测试 "+ip+" 连通性成功", zap.String("output", string(output)))
return 0 return 0
} else {
return 1
}
//output, err := cmd.Output()
//if err != nil {
// fmt.Println("ping:", string(output))
// fmt.Println("err:", err)
// return 1
//}
//fmt.Println("ping:", string(output))
//return 0
} }
// ExportIpStr 结果导出 // ExportIpStr 结果导出
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment