Merge branch 'master' of https://gitee.com/red_Q/dt_automate
@ -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", "<rpc message-id='101' xmlns='urn:ietf:params:xml:ns:netconf:base:1.0' xmlns:web='urn:ietf:params:xml:ns:netconf:base:1.0'><get-bulk><filter type='subtree'><top xmlns='http://www.unis.cn/netconf/data:1.0' xmlns:web='http://www.unis.cn/netconf/base:1.0' xmlns:data='http://www.unis.cn/netconf/data:1.0'><NTOP><LogPaging><Log><LogType>1</LogType><UserID/><ID/><TimeFilter><StartTime>"+StartTime_1+"</StartTime><EndTime>"+EndTime_1+"</EndTime></TimeFilter><PageNo>"+strconv.Itoa(i)+"</PageNo><CountPerPage>200</CountPerPage><TotalCounts/><InputJSON>{"SrcZoneName":"Untrust","DestZoneName":"Trust"}</InputJSON><OutputJSON/></Log></LogPaging></NTOP></top></filter></get-bulk></rpc>")
|
||||
values_1.Add("xml", "<rpc message-id='101' xmlns='urn:ietf:params:xml:ns:netconf:base:1.0' xmlns:web='urn:ietf:params:xml:ns:netconf:base:1.0'><get-bulk><filter type='subtree'><top xmlns='http://www.unis.cn/netconf/data:1.0' xmlns:web='http://www.unis.cn/netconf/base:1.0' xmlns:data='http://www.unis.cn/netconf/data:1.0'><NTOP><LogPaging><Log><LogType>1</LogType><UserID/><ID/><TimeFilter><StartTime>"+StartTime_1+"</StartTime><EndTime>"+EndTime_1+"</EndTime></TimeFilter><PageNo>"+strconv.Itoa(nums)+"</PageNo><CountPerPage>200</CountPerPage><TotalCounts/><InputJSON>{"SrcZoneName":"Untrust","DestZoneName":"Trust"}</InputJSON><OutputJSON/></Log></LogPaging></NTOP></top></filter></get-bulk></rpc>")
|
||||
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", "<rpc message-id='101' xmlns='urn:ietf:params:xml:ns:netconf:base:1.0' xmlns:web='urn:ietf:params:xml:ns:netconf:base:1.0'><get-bulk><filter type='subtree'><top xmlns='http://www.unis.cn/netconf/data:1.0' xmlns:web='http://www.unis.cn/netconf/base:1.0' xmlns:data='http://www.unis.cn/netconf/data:1.0'><NTOP><LogPaging><Log><LogType>1</LogType><UserID/><ID/><TimeFilter><StartTime>"+StartTime+"</StartTime><EndTime>"+EndTime+"</EndTime></TimeFilter><PageNo>"+strconv.Itoa(i)+"</PageNo><CountPerPage>200</CountPerPage><TotalCounts/><InputJSON>{"SrcZoneName":"Untrust","DestZoneName":"Trust"}</InputJSON><OutputJSON/></Log></LogPaging></NTOP></top></filter></get-bulk></rpc>")
|
||||
values_1.Add("xml", "<rpc message-id='101' xmlns='urn:ietf:params:xml:ns:netconf:base:1.0' xmlns:web='urn:ietf:params:xml:ns:netconf:base:1.0'><get-bulk><filter type='subtree'><top xmlns='http://www.unis.cn/netconf/data:1.0' xmlns:web='http://www.unis.cn/netconf/base:1.0' xmlns:data='http://www.unis.cn/netconf/data:1.0'><NTOP><LogPaging><Log><LogType>1</LogType><UserID/><ID/><TimeFilter><StartTime>"+StartTime+"</StartTime><EndTime>"+EndTime+"</EndTime></TimeFilter><PageNo>"+strconv.Itoa(nums)+"</PageNo><CountPerPage>200</CountPerPage><TotalCounts/><InputJSON>{"SrcZoneName":"Untrust","DestZoneName":"Trust"}</InputJSON><OutputJSON/></Log></LogPaging></NTOP></top></filter></get-bulk></rpc>")
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
256
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 {
|
||||
|
Before Width: | Height: | Size: 182 KiB After Width: | Height: | Size: 182 KiB |
Before Width: | Height: | Size: 248 KiB After Width: | Height: | Size: 246 KiB |
BIN
img/capt.png
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 5.4 KiB |
BIN
img/hw_baolj.png
Before Width: | Height: | Size: 198 KiB After Width: | Height: | Size: 197 KiB |
Before Width: | Height: | Size: 270 KiB After Width: | Height: | Size: 270 KiB |
Before Width: | Height: | Size: 254 KiB After Width: | Height: | Size: 253 KiB |
Before Width: | Height: | Size: 242 KiB After Width: | Height: | Size: 231 KiB |
Before Width: | Height: | Size: 223 KiB After Width: | Height: | Size: 224 KiB |
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 105 KiB |
Before Width: | Height: | Size: 1.0 MiB After Width: | Height: | Size: 239 KiB |
Before Width: | Height: | Size: 176 KiB After Width: | Height: | Size: 176 KiB |
Before Width: | Height: | Size: 290 KiB After Width: | Height: | Size: 290 KiB |
BIN
img/hw_fw1.png
Before Width: | Height: | Size: 385 KiB After Width: | Height: | Size: 388 KiB |
BIN
img/hw_tsgz.png
Before Width: | Height: | Size: 229 KiB After Width: | Height: | Size: 319 KiB |
Before Width: | Height: | Size: 193 KiB After Width: | Height: | Size: 194 KiB |
Before Width: | Height: | Size: 259 KiB After Width: | Height: | Size: 260 KiB |
Before Width: | Height: | Size: 252 KiB After Width: | Height: | Size: 252 KiB |
Before Width: | Height: | Size: 259 KiB After Width: | Height: | Size: 243 KiB |
Before Width: | Height: | Size: 228 KiB After Width: | Height: | Size: 228 KiB |
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 114 KiB |
Before Width: | Height: | Size: 570 KiB After Width: | Height: | Size: 242 KiB |
Before Width: | Height: | Size: 657 KiB After Width: | Height: | Size: 175 KiB |
Before Width: | Height: | Size: 288 KiB After Width: | Height: | Size: 289 KiB |
BIN
img/zww_fw1.png
Before Width: | Height: | Size: 230 KiB After Width: | Height: | Size: 253 KiB |
BIN
img/zww_tsgz.png
Before Width: | Height: | Size: 158 KiB After Width: | Height: | Size: 185 KiB |
12
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文件中
|
||||
|