package config import ( "cicv-data-closedloop/common/config/c_log" "cicv-data-closedloop/common/util" "time" ) //type DeviceMonitor struct { // Id int `db:"id" json:"id"` // 自增id // TotalCpuUsage string `db:"total_cpu_usage" json:"totalCpuUsage"` // cpu总占用 // TotalMemoryUsage string `db:"total_memory_usage" json:"totalMemoryUsage"` // 内存总占用 // Top10Process string `db:"top10_process" json:"top10Process"` // cpu占用前十的进程信息 // DeviceNumber string `db:"device_number" json:"deviceNumber"` // cpu占用前十的进程信息 // SocIp string `db:"soc_ip" json:"socIp"` // cpu占用前十的进程信息 //} // SendResourceUsage 保存资源占用情况 func SendResourceUsage() { for { time.Sleep(time.Duration(2) * time.Second) responseString, err := util.HttpPostJsonWithHeaders( CloudConfig.Monitor.Url, map[string]string{"Authorization": "U9yKpD6kZZDDe4LFKK6myAxBUT1XRrDM"}, map[string]string{ "totalCpuUsage": util.ToString(util.GetCpuPercent()), "totalMemoryUsage": util.ToString(util.GetMemoryPercent()), "top10Process": util.ToString(util.GetTop10()), "deviceNumber": LocalConfig.EquipmentNo, "socIp": LocalConfig.Node.Ip, }, ) if err != nil { c_log.GlobalLogger.Errorf("发送数据监控信息报错%v,响应信息为:%v", err, responseString) } c_log.GlobalLogger.Infof("发送数据监控信息成功,响应信息为:%v", responseString) } }