c_resource.go 938 B

1234567891011121314151617181920212223242526272829
  1. package config
  2. import (
  3. "cicv-data-closedloop/common/config/c_log"
  4. "cicv-data-closedloop/common/util"
  5. "time"
  6. )
  7. // SendResourceUsage 保存资源占用情况
  8. func SendResourceUsage() {
  9. for {
  10. time.Sleep(time.Duration(2) * time.Second)
  11. responseString, err := util.HttpPostWithHeaders(
  12. CloudConfig.Monitor.Url,
  13. map[string]string{"Authorization": "U9yKpD6kZZDDe4LFKK6myAxBUT1XRrDM"},
  14. map[string]string{
  15. "totalCpuUsage": util.ToString(util.GetCpuPercent()),
  16. "totalMemoryUsage": util.ToString(util.GetMemoryPercent()),
  17. "top10Process": util.ToString(util.GetTop10()),
  18. "deviceNumber": LocalConfig.EquipmentNo,
  19. "socIp": LocalConfig.Node.Ip,
  20. },
  21. )
  22. if err != nil {
  23. c_log.GlobalLogger.Errorf("发送数据监控信息报错%v,响应信息为:%v", err, responseString)
  24. }
  25. c_log.GlobalLogger.Infof("发送数据监控信息成功,响应信息为:%v", responseString)
  26. }
  27. }