|
|
|
@ -38,8 +38,8 @@ func SysMonitor(w http.ResponseWriter, r *http.Request) { |
|
|
|
return |
|
|
|
} |
|
|
|
// 磁盘空间占用
|
|
|
|
hdtval := fmt.Sprintf("总容量: %.2f GB\n", float64(diskInfo.Total)/1024/1024/1024) |
|
|
|
hduval := fmt.Sprintf("已使用: %.2f GB\n", float64(diskInfo.Used)/1024/1024/1024) |
|
|
|
hdtval := fmt.Sprintf("%.2f GB", float64(diskInfo.Total)/1024/1024/1024) |
|
|
|
hduval := fmt.Sprintf("%.2f GB", float64(diskInfo.Used)/1024/1024/1024) |
|
|
|
|
|
|
|
// 获取CPU占用率 (需要等待1秒来计算)
|
|
|
|
cpuPercent, err := cpu.Percent(time.Second, false) |
|
|
|
@ -102,8 +102,8 @@ func SysMonitor(w http.ResponseWriter, r *http.Request) { |
|
|
|
Hdstat: fmt.Sprintf("使用:%v /总计:%v", hduval, hdtval), |
|
|
|
Procout: fmt.Sprintf("进程数: %d", procnum), |
|
|
|
Cpustat: cpuinfo, |
|
|
|
Memstat: fmt.Sprintf("内存使用率: %.2f%%\n", memInfo.UsedPercent), |
|
|
|
Netstat: fmt.Sprintf("总接收: %.2f MB\n", float64(netIO[0].BytesRecv)/1024/1024), |
|
|
|
Memstat: fmt.Sprintf("内存使用率: %.2f%%", memInfo.UsedPercent), |
|
|
|
Netstat: fmt.Sprintf("总接收: %.2f MB", float64(netIO[0].BytesRecv)/1024/1024), |
|
|
|
}) |
|
|
|
if err != nil { |
|
|
|
http.Error(w, err.Error(), http.StatusInternalServerError) |
|
|
|
|