...
1 package disk
2
3 import (
4 "context"
5 "encoding/json"
6
7 "github.com/shirou/gopsutil/internal/common"
8 )
9
10 var invoke common.Invoker = common.Invoke{}
11
12 type UsageStat struct {
13 Path string `json:"path"`
14 Fstype string `json:"fstype"`
15 Total uint64 `json:"total"`
16 Free uint64 `json:"free"`
17 Used uint64 `json:"used"`
18 UsedPercent float64 `json:"usedPercent"`
19 InodesTotal uint64 `json:"inodesTotal"`
20 InodesUsed uint64 `json:"inodesUsed"`
21 InodesFree uint64 `json:"inodesFree"`
22 InodesUsedPercent float64 `json:"inodesUsedPercent"`
23 }
24
25 type PartitionStat struct {
26 Device string `json:"device"`
27 Mountpoint string `json:"mountpoint"`
28 Fstype string `json:"fstype"`
29 Opts string `json:"opts"`
30 }
31
32 type IOCountersStat struct {
33 ReadCount uint64 `json:"readCount"`
34 MergedReadCount uint64 `json:"mergedReadCount"`
35 WriteCount uint64 `json:"writeCount"`
36 MergedWriteCount uint64 `json:"mergedWriteCount"`
37 ReadBytes uint64 `json:"readBytes"`
38 WriteBytes uint64 `json:"writeBytes"`
39 ReadTime uint64 `json:"readTime"`
40 WriteTime uint64 `json:"writeTime"`
41 IopsInProgress uint64 `json:"iopsInProgress"`
42 IoTime uint64 `json:"ioTime"`
43 WeightedIO uint64 `json:"weightedIO"`
44 Name string `json:"name"`
45 SerialNumber string `json:"serialNumber"`
46 Label string `json:"label"`
47 }
48
49 func (d UsageStat) String() string {
50 s, _ := json.Marshal(d)
51 return string(s)
52 }
53
54 func (d PartitionStat) String() string {
55 s, _ := json.Marshal(d)
56 return string(s)
57 }
58
59 func (d IOCountersStat) String() string {
60 s, _ := json.Marshal(d)
61 return string(s)
62 }
63
64
65
66
67 func Usage(path string) (*UsageStat, error) {
68 return UsageWithContext(context.Background(), path)
69 }
70
71
72
73
74
75
76 func Partitions(all bool) ([]PartitionStat, error) {
77 return PartitionsWithContext(context.Background(), all)
78 }
79
80 func IOCounters(names ...string) (map[string]IOCountersStat, error) {
81 return IOCountersWithContext(context.Background(), names...)
82 }
83
View as plain text