package config import ( "cicv-data-closedloop/common/config/c_log" "cicv-data-closedloop/common/util" "encoding/json" "time" ) // 保存资源占用情况 func SendResourceUsage() { for { time.Sleep(time.Duration(5) * time.Second) top10Cpu, top10Mem := util.GetTop10CpuAndMem() top10CpuJson, _ := json.MarshalIndent(top10Cpu, "", " ") top10MemJson, _ := json.MarshalIndent(top10Mem, "", " ") requestMap := map[string]string{ "totalCpuUsage": util.ToString(util.GetCpuPercent()), "totalMemoryUsage": util.ToString(util.GetMemoryPercent()), "top10Process": string(top10CpuJson), "top10Cpu": string(top10CpuJson), "top10Mem": string(top10MemJson), "deviceNumber": LocalConfig.EquipmentNo, "socIp": LocalConfig.Node.Ip, } c_log.GlobalLogger.Infof("监控信息为:%v", requestMap) //responseString, err := util.HttpPostJsonWithHeaders( // CloudConfig.Monitor.Url, // map[string]string{"Authorization": "U9yKpD6kZZDDe4LFKK6myAxBUT1XRrDM"}, // requestMap, //) //if err != nil { // c_log.GlobalLogger.Errorf("发送数据监控信息报错%v,响应信息为:%v", err, responseString) //} //c_log.GlobalLogger.Infof("发送数据监控信息成功,响应信息为:%v", responseString) } }