增加获取各项监控的单独api

This commit is contained in:
Sun
2024-01-04 12:08:39 +08:00
parent d3e3cf5d58
commit baf64a9272
7 changed files with 102 additions and 5 deletions
+14
View File
@@ -97,6 +97,20 @@ func GetDiskInfo() ([]DiskInfo, error) {
return disks, nil
}
func GetDiskInfoByPath(path string) (*DiskInfo, error) {
diskInfo := DiskInfo{}
usage, err := disk.Usage(path)
if err != nil {
return nil, err
}
diskInfo.Free = usage.Free
diskInfo.Mountpoint = usage.Path
diskInfo.Total = usage.Total
diskInfo.Used = usage.Used
diskInfo.UsedPercent = usage.UsedPercent
return &diskInfo, nil
}
// 获取网络统计信息
func GetNetIOCountersInfo() ([]NetIOCountersInfo, error) {
netInfo := []NetIOCountersInfo{}