实现设备管理功能

This commit is contained in:
Alex Yang
2025-12-03 00:46:46 +08:00
parent a7d794405c
commit c8cdd09455
4 changed files with 185 additions and 22 deletions

View File

@@ -108,10 +108,15 @@ func HandleMetricsPost(c *gin.Context) {
agentName = device.Name
}
// 更新设备状态为active
if err := deviceStorage.UpdateDeviceStatus(deviceID, "active"); err != nil {
// 只记录警告,不影响指标处理
log.Printf("Warning: Failed to update device status: %v", err)
// 确保设备状态为active
if device.Status != "active" {
// 更新设备状态为active
if err := deviceStorage.UpdateDeviceStatus(deviceID, "active"); err != nil {
// 只记录警告,不影响指标处理
log.Printf("Warning: Failed to update device status: %v", err)
} else {
log.Printf("Device %s activated successfully", deviceID)
}
}
// 创建基础标签包含Agent名称