Commit 4e5002f5 authored by 陈子龙's avatar 陈子龙

Merge branch 'dev-czl' into dev

parents 0efa5942 d1a56aa0
...@@ -631,12 +631,11 @@ func StatusDetection(ip string) (ipConn int) { ...@@ -631,12 +631,11 @@ func StatusDetection(ip string) (ipConn int) {
// ExportIpStr 结果导出 // ExportIpStr 结果导出
type ExportIpStr struct { type ExportIpStr struct {
Ip string `json:"ip" index:"0"` // ip Ip string `json:"ip" index:"0"` // ip
Port string `json:"port" index:"1"` // 端口 Port string `json:"port" index:"1"` // 端口
VoucherType string `json:"voucher_type" index:"2"` // 凭证类型 VoucherType string `json:"voucher_type" index:"2"` // 凭证类型
UserName string `json:"user_name" index:"3"` // 用户名 UserName string `json:"user_name" index:"3"` // 用户名
Password string `json:"password" index:"4"` // 密码 Password string `json:"password" index:"4"` // 密码
ConnStatus string `json:"conn_status" index:"5" ` // 连接状态
} }
// ExportIp 结果导出 // ExportIp 结果导出
...@@ -678,20 +677,12 @@ func (h *HostManageSvc) ExportIp(id, uuid string, detectionType int) (fileName s ...@@ -678,20 +677,12 @@ func (h *HostManageSvc) ExportIp(id, uuid string, detectionType int) (fileName s
case 1: case 1:
voucherType = "密钥验证" voucherType = "密钥验证"
} }
connStatus := ""
switch v.ConnStatus {
case 0:
connStatus = "正常"
case 1:
connStatus = "异常"
}
staff := ExportIpStr{ staff := ExportIpStr{
Ip: v.Ip, Ip: v.Ip,
Port: v.Port, Port: v.Port,
VoucherType: voucherType, VoucherType: voucherType,
UserName: v.UserName, UserName: v.UserName,
Password: v.Password, Password: v.Password,
ConnStatus: connStatus,
} }
push = append(push, staff) push = append(push, staff)
...@@ -709,7 +700,7 @@ func generatePushExportXlsx(push []ExportIpStr) (string, error) { ...@@ -709,7 +700,7 @@ func generatePushExportXlsx(push []ExportIpStr) (string, error) {
file := xlsx.NewFile() file := xlsx.NewFile()
sheet, _ := file.AddSheet("Sheet1") sheet, _ := file.AddSheet("Sheet1")
titles := []string{"IP", "端口", "凭证类型", "用户名", "密码", "状态"} titles := []string{"IP", "端口", "凭证类型", "用户名", "密码"}
row := sheet.AddRow() row := sheet.AddRow()
var cell *xlsx.Cell var cell *xlsx.Cell
for _, title := range titles { for _, title := range titles {
...@@ -763,25 +754,6 @@ func CronStatusDetection() { ...@@ -763,25 +754,6 @@ func CronStatusDetection() {
return 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 { for _, v := range hostManageList {
connStatus := StatusDetection(v.Ip) connStatus := StatusDetection(v.Ip)
//修改状态 //修改状态
......
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