-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathdfstat.go
69 lines (61 loc) · 1.32 KB
/
dfstat.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package nux
import (
"fmt"
"strings"
)
var FSSPEC_IGNORE = map[string]struct{}{
"none": struct{}{},
"nodev": struct{}{},
"proc": struct{}{},
"hugetlbfs": struct{}{},
"mqueue": struct{}{},
}
var FSTYPE_IGNORE = map[string]struct{}{
"cgroup": struct{}{},
"debugfs": struct{}{},
"devpts": struct{}{},
"devtmpfs": struct{}{},
"iso9660": struct{}{},
"rpc_pipefs": struct{}{},
"rootfs": struct{}{},
"overlay": struct{}{},
"tmpfs": struct{}{},
"squashfs": struct{}{},
}
var FSFILE_PREFIX_IGNORE = []string{
"/sys",
"/net",
"/misc",
"/proc",
"/lib",
}
func IgnoreFsFile(fs_file string) bool {
for _, prefix := range FSFILE_PREFIX_IGNORE {
if strings.HasPrefix(fs_file, prefix) {
return true
}
}
return false
}
type DeviceUsage struct {
FsSpec string
FsFile string
FsVfstype string
BlocksAll uint64
BlocksUsed uint64
BlocksFree uint64
BlocksUsedPercent float64
BlocksFreePercent float64
InodesAll uint64
InodesUsed uint64
InodesFree uint64
InodesUsedPercent float64
InodesFreePercent float64
}
func (this *DeviceUsage) String() string {
return fmt.Sprintf("<FsSpec:%s, FsFile:%s, FsVfstype:%s, BPFree:%f...>",
this.FsSpec,
this.FsFile,
this.FsVfstype,
this.BlocksFreePercent)
}