diff --git a/attackevent/fw_data.go b/attackevent/fw_data.go index eb3dbe5..3d902c1 100644 --- a/attackevent/fw_data.go +++ b/attackevent/fw_data.go @@ -85,6 +85,7 @@ func Fw_event(cookieStr string) { //存储昨日攻击事件 num, _ := strconv.Atoi(Date_v(yesterday).NTOP.LogPaging[0].TotalCounts) if num > 200 { + var nums = 1 //页数 a, err := strconv.ParseFloat(Date_v(yesterday).NTOP.LogPaging[0].TotalCounts, 64) if err != nil { log.Println(err) @@ -94,61 +95,65 @@ func Fw_event(cookieStr string) { log.Println(totalPages) for i := 1; i < totalPages+1; i++ { values_1 := url.Values{} - values_1.Add("xml", "1"+StartTime_1+""+EndTime_1+""+strconv.Itoa(i)+"200{"SrcZoneName":"Untrust","DestZoneName":"Trust"}") + values_1.Add("xml", "1"+StartTime_1+""+EndTime_1+""+strconv.Itoa(nums)+"200{"SrcZoneName":"Untrust","DestZoneName":"Trust"}") values_1.Add("req_menu", "M_Monitor/M_AtkLog/M_ThreatLog") yesterday := conn.DT_POST("https://11.2.68.146/wnm/get.j", header, bytes.NewBufferString(values_1.Encode())) log.Println(values_1, i) - for v, k := range Date_v(yesterday).NTOP.LogPaging { - Con = v + 2 + var nums = 1 //页数 + for _, k := range Date_v(yesterday).NTOP.LogPaging { + log.Println(len(sheet.Rows())) + con := len(sheet.Rows()) + 1 // IP := conn.DT_GET("http://ip-api.com/json/"+k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string)+"?lang=zh-CN", nil, nil) - sheet.Cell("A" + strconv.Itoa(Con)).SetString(strconv.Itoa(Con)) // 第一列 (A1) - sheet.Cell("B" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["Time"].(string)) - sheet.Cell("C" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["SrcZoneName"].(string)) - sheet.Cell("D" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["DestZoneName"].(string)) - sheet.Cell("E" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string)) - sheet.Cell("F" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["DestIPAddr"].(string)) - sheet.Cell("G" + strconv.Itoa(Con)).SetString(strconv.FormatFloat(k.OutputJSON.(map[string]interface{})["DestPort"].(float64), 'f', -1, 64)) - sheet.Cell("H" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["ThreatName"].(string)) - sheet.Cell("I" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["MethodNameCN"].(string)) - sheet.Cell("J" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["MethodSubNameCN"].(string)) - sheet.Cell("K" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["Application"].(string)) - sheet.Cell("L" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["CVE"].(string)) - sheet.Cell("M" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["HttpHost"].(string)) - sheet.Cell("N" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["HttpFirstLine"].(string)) - sheet.Cell("O" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["Payload"].(string)) + sheet.Cell("A" + strconv.Itoa(con)).SetString(strconv.Itoa(con - 1)) // 第一列 (A1) + sheet.Cell("B" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["Time"].(string)) + sheet.Cell("C" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["SrcZoneName"].(string)) + sheet.Cell("D" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["DestZoneName"].(string)) + sheet.Cell("E" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string)) + sheet.Cell("F" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["DestIPAddr"].(string)) + sheet.Cell("G" + strconv.Itoa(con)).SetString(strconv.FormatFloat(k.OutputJSON.(map[string]interface{})["DestPort"].(float64), 'f', -1, 64)) + sheet.Cell("H" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["ThreatName"].(string)) + sheet.Cell("I" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["MethodNameCN"].(string)) + sheet.Cell("J" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["MethodSubNameCN"].(string)) + sheet.Cell("K" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["Application"].(string)) + sheet.Cell("L" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["CVE"].(string)) + sheet.Cell("M" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["HttpHost"].(string)) + sheet.Cell("N" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["HttpFirstLine"].(string)) + sheet.Cell("O" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["Payload"].(string)) // sheet.Cell("P" + strconv.Itoa(Con)).SetString(Date_get(IP).(map[string]interface{})["country"].(string) + "." + Date_get(IP).(map[string]interface{})["city"].(string) + "/" + Date_get(IP).(map[string]interface{})["isp"].(string)) log.Println("开始插入昨日数据:", Con, k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string)) } + nums++ } - } else { - for v, k := range Date_v(yesterday).NTOP.LogPaging { - Con = v + 2 + for _, k := range Date_v(yesterday).NTOP.LogPaging { + log.Println(len(sheet.Rows())) + con := len(sheet.Rows()) + 1 // IP := conn.DT_GET("http://ip-api.com/json/"+k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string)+"?lang=zh-CN", nil, nil) - sheet.Cell("A" + strconv.Itoa(Con)).SetString(strconv.Itoa(Con)) // 第一列 (A1) - sheet.Cell("B" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["Time"].(string)) - sheet.Cell("C" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["SrcZoneName"].(string)) - sheet.Cell("D" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["DestZoneName"].(string)) - sheet.Cell("E" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string)) - sheet.Cell("F" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["DestIPAddr"].(string)) - sheet.Cell("G" + strconv.Itoa(Con)).SetString(strconv.FormatFloat(k.OutputJSON.(map[string]interface{})["DestPort"].(float64), 'f', -1, 64)) - sheet.Cell("H" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["ThreatName"].(string)) - sheet.Cell("I" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["MethodNameCN"].(string)) - sheet.Cell("J" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["MethodSubNameCN"].(string)) - sheet.Cell("K" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["Application"].(string)) - sheet.Cell("L" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["CVE"].(string)) - sheet.Cell("M" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["HttpHost"].(string)) - sheet.Cell("N" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["HttpFirstLine"].(string)) - sheet.Cell("O" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["Payload"].(string)) + sheet.Cell("A" + strconv.Itoa(con)).SetString(strconv.Itoa(con - 1)) // 第一列 (A1) + sheet.Cell("B" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["Time"].(string)) + sheet.Cell("C" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["SrcZoneName"].(string)) + sheet.Cell("D" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["DestZoneName"].(string)) + sheet.Cell("E" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string)) + sheet.Cell("F" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["DestIPAddr"].(string)) + sheet.Cell("G" + strconv.Itoa(con)).SetString(strconv.FormatFloat(k.OutputJSON.(map[string]interface{})["DestPort"].(float64), 'f', -1, 64)) + sheet.Cell("H" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["ThreatName"].(string)) + sheet.Cell("I" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["MethodNameCN"].(string)) + sheet.Cell("J" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["MethodSubNameCN"].(string)) + sheet.Cell("K" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["Application"].(string)) + sheet.Cell("L" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["CVE"].(string)) + sheet.Cell("M" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["HttpHost"].(string)) + sheet.Cell("N" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["HttpFirstLine"].(string)) + sheet.Cell("O" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["Payload"].(string)) // sheet.Cell("P" + strconv.Itoa(Con)).SetString(Date_get(IP).(map[string]interface{})["country"].(string) + "." + Date_get(IP).(map[string]interface{})["city"].(string) + "/" + Date_get(IP).(map[string]interface{})["isp"].(string)) log.Println("开始插入昨日数据:", Con, k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string)) } } - Con = Con + 1 + //存储今日攻击事件 today := conn.DT_POST("https://11.2.68.146/wnm/get.j", header, bytes.NewBufferString(values.Encode())) - num_1, _ := strconv.Atoi(Date_v(today).NTOP.LogPaging[0].TotalCounts) + num_1, _ := strconv.Atoi(Date_v(today).NTOP.LogPaging[0].TotalCounts) //获取总页数 if num_1 > 200 { + a, err := strconv.ParseFloat(Date_v(today).NTOP.LogPaging[0].TotalCounts, 64) if err != nil { log.Println(err) @@ -156,55 +161,62 @@ func Fw_event(cookieStr string) { log.Println("今日查询到总条数:", a) totalPages := int(math.Floor(float64(a))/float64(200) + 1) log.Println(totalPages) + var nums = 1 //页数 for i := 1; i < totalPages+1; i++ { values_1 := url.Values{} - values_1.Add("xml", "1"+StartTime+""+EndTime+""+strconv.Itoa(i)+"200{"SrcZoneName":"Untrust","DestZoneName":"Trust"}") + values_1.Add("xml", "1"+StartTime+""+EndTime+""+strconv.Itoa(nums)+"200{"SrcZoneName":"Untrust","DestZoneName":"Trust"}") values_1.Add("req_menu", "M_Monitor/M_AtkLog/M_ThreatLog") today := conn.DT_POST("https://11.2.68.146/wnm/get.j", header, bytes.NewBufferString(values.Encode())) log.Println(values_1, i) - for v, k := range Date_v(today).NTOP.LogPaging { + for _, k := range Date_v(today).NTOP.LogPaging { + log.Println(len(sheet.Rows())) + con := len(sheet.Rows()) + 1 // IP := conn.DT_GET("http://ip-api.com/json/"+k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string)+"?lang=zh-CN", nil, nil) - sheet.Cell("A" + strconv.Itoa(Con+v)).SetString(strconv.Itoa(Con + v)) // 第一列 (A1) - sheet.Cell("B" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["Time"].(string)) - sheet.Cell("C" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["SrcZoneName"].(string)) - sheet.Cell("D" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["DestZoneName"].(string)) - sheet.Cell("E" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string)) - sheet.Cell("F" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["DestIPAddr"].(string)) - sheet.Cell("G" + strconv.Itoa(Con+v)).SetString(strconv.FormatFloat(k.OutputJSON.(map[string]interface{})["DestPort"].(float64), 'f', -1, 64)) - sheet.Cell("H" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["ThreatName"].(string)) - sheet.Cell("I" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["MethodNameCN"].(string)) - sheet.Cell("J" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["MethodSubNameCN"].(string)) - sheet.Cell("K" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["Application"].(string)) - sheet.Cell("L" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["CVE"].(string)) - sheet.Cell("M" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["HttpHost"].(string)) - sheet.Cell("N" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["HttpFirstLine"].(string)) - sheet.Cell("O" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["Payload"].(string)) + sheet.Cell("A" + strconv.Itoa(con)).SetString(strconv.Itoa(con - 1)) // 第一列 (A1) + sheet.Cell("B" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["Time"].(string)) + sheet.Cell("C" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["SrcZoneName"].(string)) + sheet.Cell("D" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["DestZoneName"].(string)) + sheet.Cell("E" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string)) + sheet.Cell("F" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["DestIPAddr"].(string)) + sheet.Cell("G" + strconv.Itoa(con)).SetString(strconv.FormatFloat(k.OutputJSON.(map[string]interface{})["DestPort"].(float64), 'f', -1, 64)) + sheet.Cell("H" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["ThreatName"].(string)) + sheet.Cell("I" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["MethodNameCN"].(string)) + sheet.Cell("J" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["MethodSubNameCN"].(string)) + sheet.Cell("K" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["Application"].(string)) + sheet.Cell("L" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["CVE"].(string)) + sheet.Cell("M" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["HttpHost"].(string)) + sheet.Cell("N" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["HttpFirstLine"].(string)) + sheet.Cell("O" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["Payload"].(string)) // sheet.Cell("P" + strconv.Itoa(Con+v)).SetString(Date_get(IP).(map[string]interface{})["country"].(string) + "." + Date_get(IP).(map[string]interface{})["city"].(string) + "/" + Date_get(IP).(map[string]interface{})["isp"].(string)) - log.Println("开始插入今日数据:", v+Con, k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string)) + log.Println("开始插入今日数据:", con, k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string)) } + nums++ // log.Println(Date_v(JsonStr).NTOP.LogPaging) } } else { - for v, k := range Date_v(today).NTOP.LogPaging { + for _, k := range Date_v(today).NTOP.LogPaging { + log.Println(len(sheet.Rows())) + con := len(sheet.Rows()) + 1 // IP := conn.DT_GET("http://ip-api.com/json/"+k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string)+"?lang=zh-CN", nil, nil) - sheet.Cell("A" + strconv.Itoa(Con+v)).SetString(strconv.Itoa(Con + v)) // 第一列 (A1) - sheet.Cell("B" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["Time"].(string)) - sheet.Cell("C" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["SrcZoneName"].(string)) - sheet.Cell("D" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["DestZoneName"].(string)) - sheet.Cell("E" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string)) - sheet.Cell("F" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["DestIPAddr"].(string)) - sheet.Cell("G" + strconv.Itoa(Con+v)).SetString(strconv.FormatFloat(k.OutputJSON.(map[string]interface{})["DestPort"].(float64), 'f', -1, 64)) - sheet.Cell("H" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["ThreatName"].(string)) - sheet.Cell("I" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["MethodNameCN"].(string)) - sheet.Cell("J" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["MethodSubNameCN"].(string)) - sheet.Cell("K" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["Application"].(string)) - sheet.Cell("L" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["CVE"].(string)) - sheet.Cell("M" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["HttpHost"].(string)) - sheet.Cell("N" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["HttpFirstLine"].(string)) - sheet.Cell("O" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["Payload"].(string)) + sheet.Cell("A" + strconv.Itoa(con)).SetString(strconv.Itoa(con - 1)) // 第一列 (A1) + sheet.Cell("B" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["Time"].(string)) + sheet.Cell("C" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["SrcZoneName"].(string)) + sheet.Cell("D" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["DestZoneName"].(string)) + sheet.Cell("E" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string)) + sheet.Cell("F" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["DestIPAddr"].(string)) + sheet.Cell("G" + strconv.Itoa(con)).SetString(strconv.FormatFloat(k.OutputJSON.(map[string]interface{})["DestPort"].(float64), 'f', -1, 64)) + sheet.Cell("H" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["ThreatName"].(string)) + sheet.Cell("I" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["MethodNameCN"].(string)) + sheet.Cell("J" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["MethodSubNameCN"].(string)) + sheet.Cell("K" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["Application"].(string)) + sheet.Cell("L" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["CVE"].(string)) + sheet.Cell("M" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["HttpHost"].(string)) + sheet.Cell("N" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["HttpFirstLine"].(string)) + sheet.Cell("O" + strconv.Itoa(con)).SetString(k.OutputJSON.(map[string]interface{})["Payload"].(string)) // sheet.Cell("P" + strconv.Itoa(Con+v)).SetString(Date_get(IP).(map[string]interface{})["country"].(string) + "." + Date_get(IP).(map[string]interface{})["city"].(string) + "/" + Date_get(IP).(map[string]interface{})["isp"].(string)) - log.Println("开始插入今日数据:", v+Con, k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string)) + log.Println("开始插入今日数据:", con, k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string)) } + // log.Println(Date_v(JsonStr).NTOP.LogPaging) } diff --git a/conf/test.yaml b/conf/test.yaml index 1ad67bc..26ed344 100644 --- a/conf/test.yaml +++ b/conf/test.yaml @@ -1,4 +1,4 @@ -cookie: vindex==3e=10=0AB00=0R;supportLang=cn%2Cen;lang=cn;sessionid=2000011e9f293bf23a1bee459ac4083c17cf;loginid=5d67c39dc9b75343831b85d599f3d06e;2000011e9f293bf23a1bee459ac4083c17cf=true;abcd1234=true;login=false; +cookie: vindex==3f=10=0AB00=0R;supportLang=cn%2Cen;lang=cn;sessionid=200001f4be302ec689309d258f6ee6c0d187;loginid=a72a7ae33c1374e7d9f70b68cacd62be;200001f4be302ec689309d258f6ee6c0d187=true;abcd1234=true;login=false; mysql: port: 3306 url: 127.0.0.1 diff --git a/dtcloud/hlw.go b/dtcloud/hlw.go index 15e901d..537c64a 100644 --- a/dtcloud/hlw.go +++ b/dtcloud/hlw.go @@ -1,11 +1,13 @@ package dtcloud import ( + "dt_automate/conn" "dt_automate/tool" "encoding/json" "fmt" "io/ioutil" "log" + "math" "strconv" "time" @@ -13,6 +15,8 @@ import ( "github.com/Esword618/unioffice/spreadsheet" ) +var cookieStr = `Hm_lvt_d980fb2543f406139975c7a72a5a0387=1739002779,1741256044; ea6ee7ef65afa3fa0312817d0b12190e=07085eba3fa17d4a9d05f56fdcecab2f; CECLOUD_OPS_CID=WkRBMU1USXlPRGd0WkdZellTMDBZek5pTFdFMll6Z3RNR0UyWm1OaE1qUmxZVFEzfGRYTmxjaTU2ZDNjdVpIUmpiRzkxWkM1amIyMD0=; CECLOUD_OPS_SID=TXpKbE16Um1NR010TkRrek5TMDBORGN4TFdJMU5UY3RPVEptWWpsaU16Z3lOMkprfGRYTmxjaTU2ZDNjdVpIUmpiRzkxWkM1amIyMD0=` + // 运营平台-获取单个ecs的cpu使用情况 func Cpu() { fileData, err := ioutil.ReadFile("dtcloud/cpu.json") @@ -59,37 +63,78 @@ func TenantList() { sheet.Cell("G1").SetString("使用状态") sheet.Cell("H1").SetString("创建时间") log.Println("生成表格列名完成") - fileData, err := ioutil.ReadFile("dtcloud/user.json") - if err != nil { - log.Fatal(err) + // fileData, err := ioutil.ReadFile("dtcloud/user.json") + // if err != nil { + // log.Fatal(err) + // } + var num = 1 //页数 + url := "https://user.zww.dtcloud.com/api/account-tenant/v1/tenant/pageList?pageSize=10&pageNum=" + strconv.Itoa(num) + "&tenantName=&id=&userAdminCode=&userAdminId=&isIdentity=&status=&tenantIdentity=&enterpriseName=&creator=" + header := map[string]string{ + "Content-Type": "application/json", + "cookie": cookieStr, } + ecslistStr := conn.DT_GET(url, header, nil) var data map[string]interface{} - err = json.Unmarshal(fileData, &data) + err := json.Unmarshal([]byte(ecslistStr), &data) if err != nil { log.Fatal(err) } - // log.Println(data) - for _, usr := range data["data"].(map[string]interface{})["list"].([]interface{}) { - log.Println(len(sheet.Rows())) - con := len(sheet.Rows()) + 1 - a, _ := strconv.ParseInt(usr.(map[string]interface{})["createTime"].(string), 10, 64) - sheet.Cell("A" + strconv.Itoa(con)).SetString(strconv.Itoa(len(sheet.Rows()) - 1)) - sheet.Cell("B" + strconv.Itoa(con)).SetString(usr.(map[string]interface{})["id"].(string)) - sheet.Cell("C" + strconv.Itoa(con)).SetString(usr.(map[string]interface{})["userAdminId"].(string)) - sheet.Cell("D" + strconv.Itoa(con)).SetString(usr.(map[string]interface{})["creator"].(string)) - sheet.Cell("E" + strconv.Itoa(con)).SetString(usr.(map[string]interface{})["tenantName"].(string)) - sheet.Cell("F" + strconv.Itoa(con)).SetString(usr.(map[string]interface{})["userAdminCode"].(string)) - if condition := usr.(map[string]interface{})["useStatus"].(float64); condition == 0 { - sheet.Cell("G" + strconv.Itoa(con)).SetString("正常") - } else { - sheet.Cell("G" + strconv.Itoa(con)).SetString("禁用") + if data["data"].(map[string]interface{})["total"].(float64) <= 10 { + for _, usr := range data["data"].(map[string]interface{})["list"].([]interface{}) { + log.Println(len(sheet.Rows())) + con := len(sheet.Rows()) + 1 + a, _ := strconv.ParseInt(usr.(map[string]interface{})["createTime"].(string), 10, 64) + sheet.Cell("A" + strconv.Itoa(con)).SetString(strconv.Itoa(len(sheet.Rows()) - 1)) + sheet.Cell("B" + strconv.Itoa(con)).SetString(usr.(map[string]interface{})["id"].(string)) + sheet.Cell("C" + strconv.Itoa(con)).SetString(usr.(map[string]interface{})["userAdminId"].(string)) + sheet.Cell("D" + strconv.Itoa(con)).SetString(usr.(map[string]interface{})["creator"].(string)) + sheet.Cell("E" + strconv.Itoa(con)).SetString(usr.(map[string]interface{})["tenantName"].(string)) + sheet.Cell("F" + strconv.Itoa(con)).SetString(usr.(map[string]interface{})["userAdminCode"].(string)) + if condition := usr.(map[string]interface{})["useStatus"].(float64); condition == 0 { + sheet.Cell("G" + strconv.Itoa(con)).SetString("正常") + } else { + sheet.Cell("G" + strconv.Itoa(con)).SetString("禁用") + } + sheet.Cell("H" + strconv.Itoa(con)).SetString(time.Unix(a/1000, 0).Format("2006-01-02 15:04:05")) + } + } else { + totalPages := int(math.Floor(data["data"].(map[string]interface{})["total"].(float64))/float64(10) + 1) + for i := 0; i < totalPages; i++ { + url := "https://user.zww.dtcloud.com/api/account-tenant/v1/tenant/pageList?pageSize=10&pageNum=" + strconv.Itoa(num) + "&tenantName=&id=&userAdminCode=&userAdminId=&isIdentity=&status=&tenantIdentity=&enterpriseName=&creator=" + header := map[string]string{ + "Content-Type": "application/json", + "cookie": cookieStr, + } + ecslistStr := conn.DT_GET(url, header, nil) + var data map[string]interface{} + err := json.Unmarshal([]byte(ecslistStr), &data) + if err != nil { + log.Fatal(err) + } + for _, usr := range data["data"].(map[string]interface{})["list"].([]interface{}) { + log.Println(len(sheet.Rows())) + con := len(sheet.Rows()) + 1 + a, _ := strconv.ParseInt(usr.(map[string]interface{})["createTime"].(string), 10, 64) + sheet.Cell("A" + strconv.Itoa(con)).SetString(strconv.Itoa(len(sheet.Rows()) - 1)) + sheet.Cell("B" + strconv.Itoa(con)).SetString(usr.(map[string]interface{})["id"].(string)) + sheet.Cell("C" + strconv.Itoa(con)).SetString(usr.(map[string]interface{})["userAdminId"].(string)) + sheet.Cell("D" + strconv.Itoa(con)).SetString(usr.(map[string]interface{})["creator"].(string)) + sheet.Cell("E" + strconv.Itoa(con)).SetString(usr.(map[string]interface{})["tenantName"].(string)) + sheet.Cell("F" + strconv.Itoa(con)).SetString(usr.(map[string]interface{})["userAdminCode"].(string)) + if condition := usr.(map[string]interface{})["useStatus"].(float64); condition == 0 { + sheet.Cell("G" + strconv.Itoa(con)).SetString("正常") + } else { + sheet.Cell("G" + strconv.Itoa(con)).SetString("禁用") + } + sheet.Cell("H" + strconv.Itoa(con)).SetString(time.Unix(a/1000, 0).Format("2006-01-02 15:04:05")) + } + num++ + } - sheet.Cell("H" + strconv.Itoa(con)).SetString(time.Unix(a/1000, 0).Format("2006-01-02 15:04:05")) } // 保存修改后的 Excel 文件 - if err := ss.Validate(); err != nil { log.Fatalf("验证文件时出错: %s", err) } @@ -152,64 +197,139 @@ func EcsList() { sheet.Cell("AB1").SetString("nodeName") sheet.Cell("AC1").SetString("cpu超出比率") log.Println("生成表格列名完成") - //加载json文件 - fileData, err := ioutil.ReadFile("dtcloud/ecs.json") - if err != nil { - log.Fatal(err) + // 加载json文件 + // fileData, err := ioutil.ReadFile("dtcloud/ecs.json") + // if err != nil { + // log.Fatal(err) + // } + // var data map[string]interface{} + // err = json.Unmarshal(fileData, &data) + + // if err != nil { + // log.Fatal(err) + // } + var num = 1 //页数 + url := "https://user.zww.dtcloud.com/api/ecs/v1/instances?requestInfo=dtcloud2&pageSize=10&pageNumber=" + strconv.Itoa(num) + "&filter=&orderBy=created_at:desc" + header := map[string]string{ + "Content-Type": "application/json", + "cookie": cookieStr, } + ecslistStr := conn.DT_GET(url, header, nil) var data map[string]interface{} - err = json.Unmarshal(fileData, &data) + err := json.Unmarshal([]byte(ecslistStr), &data) if err != nil { log.Fatal(err) } - for _, ecs := range data["data"].(map[string]interface{})["virtualMachines"].([]interface{}) { - log.Println(len(sheet.Rows())) - con := len(sheet.Rows()) + 1 - sheet.Cell("A" + strconv.Itoa(con)).SetString(strconv.Itoa(len(sheet.Rows()) - 1)) //序号 - sheet.Cell("B" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["createdAt"].(string)) //创建时间 - sheet.Cell("C" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["updatedAt"].(string)) //更新时间 - sheet.Cell("D" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["expiredAt"].(string)) //过期时间 - sheet.Cell("E" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["ecsId"].(string)) //ECS_ID - sheet.Cell("F" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["tenantId"].(string)) //租住ID - sheet.Cell("G" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["displayName"].(string)) //显示名称 - sheet.Cell("H" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["tenantName"].(string)) //租户名称 - sheet.Cell("I" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["region"].(string) + "/" + ecs.(map[string]interface{})["az"].(string) + "/" + ecs.(map[string]interface{})["cell"].(string)) //所属区域(X/X/X) - sheet.Cell("J" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["cpuArch"].(string)) //CPU架构 - sheet.Cell("K" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["osType"].(string)) //系统类型 - sheet.Cell("L" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["status"].(string)) //运行状态 - sheet.Cell("M" + strconv.Itoa(con)).SetString(strconv.Itoa(int(ecs.(map[string]interface{})["vCpus"].(float64))) + "核") //CPU核心数 - sheet.Cell("N" + strconv.Itoa(con)).SetString(strconv.Itoa(int(ecs.(map[string]interface{})["ram"].(float64))/1024/1024/1024) + "GB") //内存/GB - var diskStrsys string - var diskStrdata string - for _, disk := range ecs.(map[string]interface{})["blockDeviceMappings"].([]interface{}) { - if disk.(map[string]interface{})["isOSDisk"] != nil { - if condition := disk.(map[string]interface{})["isOSDisk"].(bool); condition == true { - diskStrsys += fmt.Sprintf("%sGB/", strconv.Itoa(int(disk.(map[string]interface{})["volumeSize"].(float64)))) //多块系统盘拼接 + if data["data"].(map[string]interface{})["totalCount"].(float64) <= 10 { + for _, ecs := range data["data"].(map[string]interface{})["virtualMachines"].([]interface{}) { + log.Println(len(sheet.Rows())) + con := len(sheet.Rows()) + 1 + sheet.Cell("A" + strconv.Itoa(con)).SetString(strconv.Itoa(len(sheet.Rows()) - 1)) //序号 + sheet.Cell("B" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["createdAt"].(string)) //创建时间 + sheet.Cell("C" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["updatedAt"].(string)) //更新时间 + sheet.Cell("D" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["expiredAt"].(string)) //过期时间 + sheet.Cell("E" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["ecsId"].(string)) //ECS_ID + sheet.Cell("F" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["tenantId"].(string)) //租住ID + sheet.Cell("G" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["displayName"].(string)) //显示名称 + sheet.Cell("H" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["tenantName"].(string)) //租户名称 + sheet.Cell("I" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["region"].(string) + "/" + ecs.(map[string]interface{})["az"].(string) + "/" + ecs.(map[string]interface{})["cell"].(string)) //所属区域(X/X/X) + sheet.Cell("J" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["cpuArch"].(string)) //CPU架构 + sheet.Cell("K" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["osType"].(string)) //系统类型 + sheet.Cell("L" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["status"].(string)) //运行状态 + sheet.Cell("M" + strconv.Itoa(con)).SetString(strconv.Itoa(int(ecs.(map[string]interface{})["vCpus"].(float64))) + "核") //CPU核心数 + sheet.Cell("N" + strconv.Itoa(con)).SetString(strconv.Itoa(int(ecs.(map[string]interface{})["ram"].(float64))/1024/1024/1024) + "GB") //内存/GB + var diskStrsys string + var diskStrdata string + for _, disk := range ecs.(map[string]interface{})["blockDeviceMappings"].([]interface{}) { + if disk.(map[string]interface{})["isOSDisk"] != nil { + if condition := disk.(map[string]interface{})["isOSDisk"].(bool); condition == true { + diskStrsys += fmt.Sprintf("%sGB/", strconv.Itoa(int(disk.(map[string]interface{})["volumeSize"].(float64)))) //多块系统盘拼接 + } else { + diskStrdata += fmt.Sprintf("%sGB/", strconv.Itoa(int(disk.(map[string]interface{})["volumeSize"].(float64)))) //多块存储盘拼接 + } } else { diskStrdata += fmt.Sprintf("%sGB/", strconv.Itoa(int(disk.(map[string]interface{})["volumeSize"].(float64)))) //多块存储盘拼接 } - } else { - diskStrdata += fmt.Sprintf("%sGB/", strconv.Itoa(int(disk.(map[string]interface{})["volumeSize"].(float64)))) //多块存储盘拼接 } + sheet.Cell("O" + strconv.Itoa(con)).SetString(diskStrsys) //系统磁盘/GB + sheet.Cell("P" + strconv.Itoa(con)).SetString(diskStrdata) //存储磁盘/GB + sheet.Cell("Q" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["networkMappings"].([]interface{})[0].(map[string]interface{})["ipv4Address"].(string)) //宿主机IP + sheet.Cell("R" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["networkMappings"].([]interface{})[0].(map[string]interface{})["macAddress"].(string)) //MAC地址 + sheet.Cell("S" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["networkMappings"].([]interface{})[0].(map[string]interface{})["portType"].(string)) //安全组 + sheet.Cell("T" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["networkMappings"].([]interface{})[0].(map[string]interface{})["networkType"].(string)) //网络类型 + sheet.Cell("U" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["eipMappings"].([]interface{})[0].(map[string]interface{})["ipAddress"].(string)) //EIP + sheet.Cell("V" + strconv.Itoa(con)).SetString(strconv.Itoa(int(ecs.(map[string]interface{})["eipMappings"].([]interface{})[0].(map[string]interface{})["bandwidthInSize"].(float64))) + "/" + strconv.Itoa(int(ecs.(map[string]interface{})["eipMappings"].([]interface{})[0].(map[string]interface{})["bandwidthOutSize"].(float64)))) //带宽大小(入/出) + sheet.Cell("W" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["departmentName"].(string)) //部门名称 + sheet.Cell("X" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["departmentId"].(string)) //部门ID + sheet.Cell("Y" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["flavor"].(map[string]interface{})["flavorType"].(map[string]interface{})["name"].(string)) //主机型号 + sheet.Cell("Z" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["flavor"].(map[string]interface{})["flavorType"].(map[string]interface{})["cpuModel"].(string)) //CPU型号 + sheet.Cell("AA" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["vcpuType"].(string)) //CPU模式 + sheet.Cell("AB" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["nodeName"].(string)) + sheet.Cell("AC" + strconv.Itoa(con)).SetString(strconv.Itoa(int(ecs.(map[string]interface{})["cpuExceedRatio"].(float64)))) //cpu超出比率 + } + } else { + totalPages := int(math.Floor(data["data"].(map[string]interface{})["totalCount"].(float64))/float64(10) + 1) + for i := 0; i < totalPages; i++ { + url := "https://user.zww.dtcloud.com/api/ecs/v1/instances?requestInfo=dtcloud2&pageSize=10&pageNumber=" + strconv.Itoa(num) + "&filter=&orderBy=created_at:desc" + header := map[string]string{ + "Content-Type": "application/json", + "cookie": cookieStr, + } + ecslistStr := conn.DT_GET(url, header, nil) + var data map[string]interface{} + err := json.Unmarshal([]byte(ecslistStr), &data) + if err != nil { + log.Fatal(err) + } + for _, ecs := range data["data"].(map[string]interface{})["virtualMachines"].([]interface{}) { + log.Println(len(sheet.Rows())) + con := len(sheet.Rows()) + 1 + sheet.Cell("A" + strconv.Itoa(con)).SetString(strconv.Itoa(len(sheet.Rows()) - 1)) //序号 + sheet.Cell("B" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["createdAt"].(string)) //创建时间 + sheet.Cell("C" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["updatedAt"].(string)) //更新时间 + sheet.Cell("D" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["expiredAt"].(string)) //过期时间 + sheet.Cell("E" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["ecsId"].(string)) //ECS_ID + sheet.Cell("F" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["tenantId"].(string)) //租住ID + sheet.Cell("G" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["displayName"].(string)) //显示名称 + sheet.Cell("H" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["tenantName"].(string)) //租户名称 + sheet.Cell("I" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["region"].(string) + "/" + ecs.(map[string]interface{})["az"].(string) + "/" + ecs.(map[string]interface{})["cell"].(string)) //所属区域(X/X/X) + sheet.Cell("J" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["cpuArch"].(string)) //CPU架构 + sheet.Cell("K" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["osType"].(string)) //系统类型 + sheet.Cell("L" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["status"].(string)) //运行状态 + sheet.Cell("M" + strconv.Itoa(con)).SetString(strconv.Itoa(int(ecs.(map[string]interface{})["vCpus"].(float64))) + "核") //CPU核心数 + sheet.Cell("N" + strconv.Itoa(con)).SetString(strconv.Itoa(int(ecs.(map[string]interface{})["ram"].(float64))/1024/1024/1024) + "GB") //内存/GB + var diskStrsys string + var diskStrdata string + for _, disk := range ecs.(map[string]interface{})["blockDeviceMappings"].([]interface{}) { + if disk.(map[string]interface{})["isOSDisk"] != nil { + if condition := disk.(map[string]interface{})["isOSDisk"].(bool); condition == true { + diskStrsys += fmt.Sprintf("%sGB/", strconv.Itoa(int(disk.(map[string]interface{})["volumeSize"].(float64)))) //多块系统盘拼接 + } else { + diskStrdata += fmt.Sprintf("%sGB/", strconv.Itoa(int(disk.(map[string]interface{})["volumeSize"].(float64)))) //多块存储盘拼接 + } + } else { + diskStrdata += fmt.Sprintf("%sGB/", strconv.Itoa(int(disk.(map[string]interface{})["volumeSize"].(float64)))) //多块存储盘拼接 + } + } + sheet.Cell("O" + strconv.Itoa(con)).SetString(diskStrsys) //系统磁盘/GB + sheet.Cell("P" + strconv.Itoa(con)).SetString(diskStrdata) //存储磁盘/GB + sheet.Cell("Q" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["networkMappings"].([]interface{})[0].(map[string]interface{})["ipv4Address"].(string)) //宿主机IP + sheet.Cell("R" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["networkMappings"].([]interface{})[0].(map[string]interface{})["macAddress"].(string)) //MAC地址 + sheet.Cell("S" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["networkMappings"].([]interface{})[0].(map[string]interface{})["portType"].(string)) //安全组 + sheet.Cell("T" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["networkMappings"].([]interface{})[0].(map[string]interface{})["networkType"].(string)) //网络类型 + sheet.Cell("U" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["eipMappings"].([]interface{})[0].(map[string]interface{})["ipAddress"].(string)) //EIP + sheet.Cell("V" + strconv.Itoa(con)).SetString(strconv.Itoa(int(ecs.(map[string]interface{})["eipMappings"].([]interface{})[0].(map[string]interface{})["bandwidthInSize"].(float64))) + "/" + strconv.Itoa(int(ecs.(map[string]interface{})["eipMappings"].([]interface{})[0].(map[string]interface{})["bandwidthOutSize"].(float64)))) //带宽大小(入/出) + sheet.Cell("W" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["departmentName"].(string)) //部门名称 + sheet.Cell("X" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["departmentId"].(string)) //部门ID + sheet.Cell("Y" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["flavor"].(map[string]interface{})["flavorType"].(map[string]interface{})["name"].(string)) //主机型号 + sheet.Cell("Z" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["flavor"].(map[string]interface{})["flavorType"].(map[string]interface{})["cpuModel"].(string)) //CPU型号 + sheet.Cell("AA" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["vcpuType"].(string)) //CPU模式 + sheet.Cell("AB" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["nodeName"].(string)) + sheet.Cell("AC" + strconv.Itoa(con)).SetString(strconv.Itoa(int(ecs.(map[string]interface{})["cpuExceedRatio"].(float64)))) //cpu超出比率 + } + num++ } - sheet.Cell("O" + strconv.Itoa(con)).SetString(diskStrsys) //系统磁盘/GB - sheet.Cell("P" + strconv.Itoa(con)).SetString(diskStrdata) //存储磁盘/GB - sheet.Cell("Q" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["networkMappings"].([]interface{})[0].(map[string]interface{})["ipv4Address"].(string)) //宿主机IP - sheet.Cell("R" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["networkMappings"].([]interface{})[0].(map[string]interface{})["macAddress"].(string)) //MAC地址 - sheet.Cell("S" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["networkMappings"].([]interface{})[0].(map[string]interface{})["portType"].(string)) //安全组 - sheet.Cell("T" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["networkMappings"].([]interface{})[0].(map[string]interface{})["networkType"].(string)) //网络类型 - sheet.Cell("U" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["eipMappings"].([]interface{})[0].(map[string]interface{})["ipAddress"].(string)) //EIP - sheet.Cell("V" + strconv.Itoa(con)).SetString(strconv.Itoa(int(ecs.(map[string]interface{})["eipMappings"].([]interface{})[0].(map[string]interface{})["bandwidthInSize"].(float64))) + "/" + strconv.Itoa(int(ecs.(map[string]interface{})["eipMappings"].([]interface{})[0].(map[string]interface{})["bandwidthOutSize"].(float64)))) //带宽大小(入/出) - sheet.Cell("W" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["departmentName"].(string)) //部门名称 - sheet.Cell("X" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["departmentId"].(string)) //部门ID - sheet.Cell("Y" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["flavor"].(map[string]interface{})["flavorType"].(map[string]interface{})["name"].(string)) //主机型号 - sheet.Cell("Z" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["flavor"].(map[string]interface{})["flavorType"].(map[string]interface{})["cpuModel"].(string)) //CPU型号 - sheet.Cell("AA" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["vcpuType"].(string)) //CPU模式 - sheet.Cell("AB" + strconv.Itoa(con)).SetString(ecs.(map[string]interface{})["nodeName"].(string)) - sheet.Cell("AC" + strconv.Itoa(con)).SetString(strconv.Itoa(int(ecs.(map[string]interface{})["cpuExceedRatio"].(float64)))) //cpu超出比率 - } - // 保存修改后的 Excel 文件 if err := ss.Validate(); err != nil { diff --git a/img/afc2000_1.png b/img/afc2000_1.png index ee45e07..2dd615a 100644 Binary files a/img/afc2000_1.png and b/img/afc2000_1.png differ diff --git a/img/afc2000_2.png b/img/afc2000_2.png index 31b0e7f..159fc3b 100644 Binary files a/img/afc2000_2.png and b/img/afc2000_2.png differ diff --git a/img/capt.png b/img/capt.png index 608c5c8..2e6eccc 100644 Binary files a/img/capt.png and b/img/capt.png differ diff --git a/img/hw_baolj.png b/img/hw_baolj.png index a88865f..30e37d4 100644 Binary files a/img/hw_baolj.png and b/img/hw_baolj.png differ diff --git a/img/hw_dtcloud_01.png b/img/hw_dtcloud_01.png index 555a6e2..d2a1535 100644 Binary files a/img/hw_dtcloud_01.png and b/img/hw_dtcloud_01.png differ diff --git a/img/hw_dtcloud_02.png b/img/hw_dtcloud_02.png index ca3aa6c..09a4fa0 100644 Binary files a/img/hw_dtcloud_02.png and b/img/hw_dtcloud_02.png differ diff --git a/img/hw_dtcloud_03.png b/img/hw_dtcloud_03.png index 5e7fe44..17b3353 100644 Binary files a/img/hw_dtcloud_03.png and b/img/hw_dtcloud_03.png differ diff --git a/img/hw_dtcloud_04.png b/img/hw_dtcloud_04.png index c618ad0..9c4e060 100644 Binary files a/img/hw_dtcloud_04.png and b/img/hw_dtcloud_04.png differ diff --git a/img/hw_dtcloud_05.png b/img/hw_dtcloud_05.png index 4a37313..5bbc8dd 100644 Binary files a/img/hw_dtcloud_05.png and b/img/hw_dtcloud_05.png differ diff --git a/img/hw_dtcloud_06.png b/img/hw_dtcloud_06.png index 7f4eb60..125ca67 100644 Binary files a/img/hw_dtcloud_06.png and b/img/hw_dtcloud_06.png differ diff --git a/img/hw_dtcloud_07.png b/img/hw_dtcloud_07.png index 6c21a3e..3d87efe 100644 Binary files a/img/hw_dtcloud_07.png and b/img/hw_dtcloud_07.png differ diff --git a/img/hw_dtcloud_man.png b/img/hw_dtcloud_man.png index a3a588e..d4651a4 100644 Binary files a/img/hw_dtcloud_man.png and b/img/hw_dtcloud_man.png differ diff --git a/img/hw_fw1.png b/img/hw_fw1.png index 238cef3..1bb9a04 100644 Binary files a/img/hw_fw1.png and b/img/hw_fw1.png differ diff --git a/img/hw_tsgz.png b/img/hw_tsgz.png index 69042f2..8de0289 100644 Binary files a/img/hw_tsgz.png and b/img/hw_tsgz.png differ diff --git a/img/zww_baolj.png b/img/zww_baolj.png index 4f48c40..d21c17d 100644 Binary files a/img/zww_baolj.png and b/img/zww_baolj.png differ diff --git a/img/zww_dtcloud_01.png b/img/zww_dtcloud_01.png index 474dd84..354d178 100644 Binary files a/img/zww_dtcloud_01.png and b/img/zww_dtcloud_01.png differ diff --git a/img/zww_dtcloud_02.png b/img/zww_dtcloud_02.png index 5331906..75b9210 100644 Binary files a/img/zww_dtcloud_02.png and b/img/zww_dtcloud_02.png differ diff --git a/img/zww_dtcloud_03.png b/img/zww_dtcloud_03.png index afd49f3..e142458 100644 Binary files a/img/zww_dtcloud_03.png and b/img/zww_dtcloud_03.png differ diff --git a/img/zww_dtcloud_04.png b/img/zww_dtcloud_04.png index 53978b5..34bbd5a 100644 Binary files a/img/zww_dtcloud_04.png and b/img/zww_dtcloud_04.png differ diff --git a/img/zww_dtcloud_05.png b/img/zww_dtcloud_05.png index 70d9d36..f585b40 100644 Binary files a/img/zww_dtcloud_05.png and b/img/zww_dtcloud_05.png differ diff --git a/img/zww_dtcloud_06.png b/img/zww_dtcloud_06.png index c52f0c9..edc2396 100644 Binary files a/img/zww_dtcloud_06.png and b/img/zww_dtcloud_06.png differ diff --git a/img/zww_dtcloud_07.png b/img/zww_dtcloud_07.png index 47ad227..c866ffe 100644 Binary files a/img/zww_dtcloud_07.png and b/img/zww_dtcloud_07.png differ diff --git a/img/zww_dtcloud_man.png b/img/zww_dtcloud_man.png index 8e1ae9f..95b9ad7 100644 Binary files a/img/zww_dtcloud_man.png and b/img/zww_dtcloud_man.png differ diff --git a/img/zww_fw1.png b/img/zww_fw1.png index 0ed9873..676c126 100644 Binary files a/img/zww_fw1.png and b/img/zww_fw1.png differ diff --git a/img/zww_tsgz.png b/img/zww_tsgz.png index 15b965e..ea6fdc3 100644 Binary files a/img/zww_tsgz.png and b/img/zww_tsgz.png differ diff --git a/main.go b/main.go index 4953a03..b804516 100644 --- a/main.go +++ b/main.go @@ -67,23 +67,23 @@ func main() { } else { log.Printf("授权未到期,剩余时间:%d天 %d小时 %d分钟 %d秒", days, hours, minutes, secod) //可执行程序位置 - // // 互联网区截图 + // 互联网区截图 // method.HW_FAC1() //截取流量清洗的图片 - // method.HW_FW1() //截取防火墙的图片 + // method.HW_FW1() //截取防火墙的图片 // method.HW_TSGZ() //截取态势感知的图片 // method.HW_DTCLOUD() //截取运维中心的图片 // method.HW_BAOLJ() //截取堡垒机的图片 - // // // //政务网区截图 + //政务网区截图 // method.ZWW_FW1() //截取防火墙的图片 - // method.ZWW_TSGZ() //截取态势感知的图片 + // method.ZWW_TSGZ() //截取态势感知的图片 // method.ZWW_DTCLOUD() //截取运维中心的图片 // method.ZWWW_BAOLJ() //截取堡垒机的图片 // 互联网区运维巡检文档生成 // wps.HW_SYS_Word() //运维平台word文档生成 - // //政务网区运维巡检文档生成 + // // //政务网区运维巡检文档生成 // wps.ZWW_SYS_Word() //运维平台word文档生成 - // //安全巡检文档生成 + // // //安全巡检文档生成 // wps.SAFET_Word() //安全巡检文档生成 //安全事件表格生成(需要先执行互联网区防火墙截图) // attackevent.Fw_event(attackevent.HW_fw1_cookie()) //将防火墙安全事件存放到xlsx文件中 diff --git a/互联网区-运营平台ECS列表20250306.xlsx b/互联网区-运营平台ECS列表20250306.xlsx deleted file mode 100644 index f957c78..0000000 Binary files a/互联网区-运营平台ECS列表20250306.xlsx and /dev/null differ diff --git a/互联网区-运营平台ECS列表20250307.xlsx b/互联网区-运营平台ECS列表20250307.xlsx new file mode 100644 index 0000000..c96b0ec Binary files /dev/null and b/互联网区-运营平台ECS列表20250307.xlsx differ diff --git a/互联网区-运营平台租户列表20250306.xlsx b/互联网区-运营平台租户列表20250306.xlsx deleted file mode 100644 index f6e1f50..0000000 Binary files a/互联网区-运营平台租户列表20250306.xlsx and /dev/null differ diff --git a/互联网区-运营平台租户列表20250307.xlsx b/互联网区-运营平台租户列表20250307.xlsx new file mode 100644 index 0000000..1180dd5 Binary files /dev/null and b/互联网区-运营平台租户列表20250307.xlsx differ