diff --git a/src/service/host_manage.go b/src/service/host_manage.go index 42115d6aa25d9ce9bb225f511bffa3c2e539de7a..3db8b8c3bc275abb3b2373f1f526ada7417e4b6f 100644 --- a/src/service/host_manage.go +++ b/src/service/host_manage.go @@ -631,12 +631,11 @@ func StatusDetection(ip string) (ipConn int) { // ExportIpStr 结果导出 type ExportIpStr struct { - Ip string `json:"ip" index:"0"` // ip - Port string `json:"port" index:"1"` // 端口 - VoucherType string `json:"voucher_type" index:"2"` // 凭证类型 - UserName string `json:"user_name" index:"3"` // 用户名 - Password string `json:"password" index:"4"` // 密码 - ConnStatus string `json:"conn_status" index:"5" ` // 连接状态 + Ip string `json:"ip" index:"0"` // ip + Port string `json:"port" index:"1"` // 端口 + VoucherType string `json:"voucher_type" index:"2"` // 凭证类型 + UserName string `json:"user_name" index:"3"` // 用户名 + Password string `json:"password" index:"4"` // 密码 } // ExportIp 结果导出 @@ -678,20 +677,12 @@ func (h *HostManageSvc) ExportIp(id, uuid string, detectionType int) (fileName s case 1: voucherType = "密钥验证" } - connStatus := "" - switch v.ConnStatus { - case 0: - connStatus = "正常" - case 1: - connStatus = "异常" - } staff := ExportIpStr{ Ip: v.Ip, Port: v.Port, VoucherType: voucherType, UserName: v.UserName, Password: v.Password, - ConnStatus: connStatus, } push = append(push, staff) @@ -709,7 +700,7 @@ func generatePushExportXlsx(push []ExportIpStr) (string, error) { file := xlsx.NewFile() sheet, _ := file.AddSheet("Sheet1") - titles := []string{"IP", "端口", "凭证类型", "用户名", "密码", "状态"} + titles := []string{"IP", "端口", "凭证类型", "用户名", "密码"} row := sheet.AddRow() var cell *xlsx.Cell for _, title := range titles { @@ -763,25 +754,6 @@ func CronStatusDetection() { return } - //往hosts文件中写入主机组ip - //f, err := os.OpenFile("/etc/ansible/hosts", os.O_APPEND|os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0777) - //if err != nil { - // fmt.Println("CronStatusDetection err:", err.Error()) - // return - //} - //defer f.Close() - //_, err = f.Write([]byte(fmt.Sprintf("%s%d\n", AnsibleGroup, req.Id))) - //if err != nil { - // fmt.Println("CronStatusDetection err:", err.Error()) - // return - //} - //for _, v := range hostManageList { - // _, err = f.Write([]byte(fmt.Sprintf("%s ansible_ssh_host=%s ansible_ssh_port=%s ansible_ssh_user=\"%s\" ansible_ssh_pass=\"%s\"\n", v.Ip, v.Ip, v.Port, v.UserName, v.Password))) - // if err != nil { - // fmt.Println("CronStatusDetection err:", err.Error()) - // return - // } - //} for _, v := range hostManageList { connStatus := StatusDetection(v.Ip) //修改状态