LingxinMeng 10 месяцев назад
Родитель
Сommit
ea22f363ca

+ 19 - 16
aarch64/pjisuv/common/config/c_resource.go

@@ -10,26 +10,29 @@ import (
 // 保存资源占用情况
 func SendResourceUsage() {
 	for {
-		time.Sleep(time.Duration(2) * time.Second)
+		time.Sleep(time.Duration(5) * time.Second)
 		top10Cpu, top10Mem := util.GetTop10CpuAndMem()
 		top10CpuJson, _ := json.MarshalIndent(top10Cpu, "", "    ")
 		top10MemJson, _ := json.MarshalIndent(top10Mem, "", "    ")
-		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":     string(top10CpuJson),
-				"top10Cpu":         string(top10CpuJson),
-				"top10Mem":         string(top10MemJson),
-				"deviceNumber":     LocalConfig.EquipmentNo,
-				"socIp":            LocalConfig.Node.Ip,
-			},
-		)
-		if err != nil {
-			c_log.GlobalLogger.Errorf("发送数据监控信息报错%v,响应信息为:%v", err, responseString)
+
+		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)
 	}
 }

+ 2 - 2
aarch64/pjisuv/master/main.go

@@ -26,8 +26,8 @@ func init() {
 	commonConfig.InitPlatformConfig()
 	// 初始化ros节点
 	commonConfig.InitRosConfig()
-	//// 发送资源占用信息
-	//go commonConfig.SendResourceUsage()
+	// 发送资源占用信息
+	go commonConfig.SendResourceUsage()
 	// 维护data目录缓存的包数量
 	go commonService.BagCacheClean()
 	// 磁盘占用过高时根据缓存策略处理copy目录

+ 2 - 2
aarch64/pjisuv/slave/main.go

@@ -25,8 +25,8 @@ func init() {
 	commonConfig.InitPlatformConfig()
 	// 初始化ros节点
 	commonConfig.InitRosConfig()
-	//// 发送资源占用信息
-	//go commonConfig.SendResourceUsage()
+	// 发送资源占用信息
+	go commonConfig.SendResourceUsage()
 	// 维护data目录缓存的包数量
 	go commonService.BagCacheClean()
 	// 磁盘占用过高时根据缓存策略处理copy目录