版本封存

This commit is contained in:
zeaslity
2025-12-06 11:26:05 +08:00
parent 13949e1ba8
commit c0ae5e30c4
57 changed files with 2443 additions and 1428 deletions

View File

@@ -1,8 +1,8 @@
package services
package host_info
import (
"cmii-uav-watchdog-common/models"
"fmt"
"cmii-uav-watchdog-common/wdd_log"
"strconv"
"strings"
"syscall"
@@ -68,7 +68,7 @@ func GetDiskInfo() []models.DiskInfo {
// Get disk usage information using stat
var stat syscall.Statfs_t
if err := syscall.Statfs(mountPoint, &stat); err != nil {
fmt.Printf("Warning: error getting statfs for %s: %v\n", mountPoint, err)
wdd_log.Warn("获取 %s 的statfs信息失败: %v", mountPoint, err)
continue
}
@@ -85,7 +85,8 @@ func GetDiskInfo() []models.DiskInfo {
// Calculate percentage used
usePercent := "0%"
if total > 0 {
usePercent = fmt.Sprintf("%.1f%%", float64(used)/float64(total)*100)
percentage := float64(used) / float64(total) * 100
usePercent = strconv.FormatFloat(percentage, 'f', 1, 64) + "%"
}
// Determine the physical device and its size