Skip to content

Commit

Permalink
fix: fix no disk info on apfs file system
Browse files Browse the repository at this point in the history
fix double counting size with subvolume

See: cokemine/nodestatus-client-go#18 (comment)
  • Loading branch information
cokemine committed Apr 21, 2022
1 parent 33c2264 commit 86101b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion pkg/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,17 @@ func Disk(INTERVAL *float64) (uint64, uint64) {
)
if timer <= 0 {
diskList, _ := disk.Partitions(false)
devices := make(map[string]bool)
for _, d := range diskList {
if checkValidFs(d.Fstype) {
if devices[d.Device] {
continue
}
cachedFs[d.Mountpoint] = struct{}{}
devices[d.Device] = true
}
}
timer = 150.0
timer = 300.0
}
timer -= *INTERVAL
for k := range cachedFs {
Expand Down
2 changes: 1 addition & 1 deletion pkg/status/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

var invalidInterface = []string{"lo", "tun", "kube", "docker", "vmbr", "br-", "vnet", "veth"}
var validFs = []string{"ext4", "ext3", "ext2", "reiserfs", "jfs", "btrfs", "fuseblk", "zfs", "simfs", "ntfs", "fat32", "exfat", "xfs"}
var validFs = []string{"ext4", "ext3", "ext2", "reiserfs", "jfs", "btrfs", "fuseblk", "zfs", "simfs", "ntfs", "fat32", "exfat", "xfs", "apfs"}

func BytesToString(b []byte) string {
return *(*string)(unsafe.Pointer(&b))
Expand Down

0 comments on commit 86101b9

Please sign in to comment.