main.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. package main
  2. import (
  3. "cicv-data-closedloop/common/util"
  4. "fmt"
  5. )
  6. //type DeviceMonitor struct {
  7. // Id int `db:"id" json:"id"` // 自增id
  8. // TotalCpuUsage string `db:"total_cpu_usage" json:"totalCpuUsage"` // cpu总占用
  9. // TotalMemoryUsage string `db:"total_memory_usage" json:"totalMemoryUsage"` // 内存总占用
  10. // Top10Process string `db:"top10_process" json:"top10Process"` // cpu占用前十的进程信息
  11. // DeviceNumber string `db:"device_number" json:"deviceNumber"` // cpu占用前十的进程信息
  12. // SocIp string `db:"soc_ip" json:"socIp"` // cpu占用前十的进程信息
  13. //}
  14. // 保存资源占用情况
  15. func main() {
  16. responseString, err := util.HttpPostJsonWithHeaders(
  17. "http://36.110.106.142:12341/web_server/monitor/insert",
  18. map[string]string{"Authorization": "U9yKpD6kZZDDe4LFKK6myAxBUT1XRrDM"},
  19. map[string]string{
  20. "totalCpuUsage": "util.ToString(util.GetCpuPercent())",
  21. "totalMemoryUsage": " util.ToString(util.GetMemoryPercent())",
  22. "top10Process": " util.ToString(util.GetTop10())",
  23. "deviceNumber": "LocalConfig.EquipmentNo",
  24. "socIp": "LocalConfig.Node.Ip",
  25. },
  26. )
  27. if err != nil {
  28. fmt.Printf("发送数据监控信息报错%v,响应信息为:%v", err, responseString)
  29. }
  30. fmt.Printf("发送数据监控信息成功,响应信息为:%v", responseString)
  31. }