MCPcopy Index your code
hub / github.com/inbug-team/InScan / GetDiskInfo

Function GetDiskInfo

host_info/host_info.go:80–101  ·  view source on GitHub ↗

3.磁盘信息

()

Source from the content-addressed store, hash-verified

78
79// 3.磁盘信息
80func GetDiskInfo() (result Parts, err error) {
81 parts, err := disk.Partitions(true)
82 if err != nil {
83 return result, err
84 }
85 for _, part := range parts {
86 diskInfo, err := disk.Usage(part.Mountpoint)
87 if err == nil {
88 result = append(result, Part{
89 Path: diskInfo.Path,
90 FsType: diskInfo.Fstype,
91 Total: decimal(fmt.Sprintf("%.2f", float64(diskInfo.Total/GB))),
92 Free: decimal(fmt.Sprintf("%.2f", float64(diskInfo.Free/GB))),
93 Used: decimal(fmt.Sprintf("%.2f", float64(diskInfo.Used/GB))),
94 UsedPercent: int(diskInfo.UsedPercent),
95 })
96 } else {
97 return result, err
98 }
99 }
100 return result, err
101}
102
103// 4.CPU使用率
104func GetCpuPercent() (result CpuInfo, err error) {

Callers

nothing calls this directly

Calls 1

decimalFunction · 0.85

Tested by

no test coverage detected