Open itsties opened 2 years ago
disk usage on linux uses golang.org/x/sys/unix.Statfs.
It seems Statfs on ceph has something wrong. Could you this code?
package main
import (
"fmt"
"golang.org/x/sys/unix"
)
func main(){
stat := unix.Statfs_t{}
unix.Statfs("/mnt/ceph", &stat)
fmt.Printf("%#v\n", stat)
}
This is my output when running your code
unix.Statfs_t{Type:12805120, Bsize:4194304, Blocks:0x6400, Bfree:0x45e8, Bavail:0x45e8, Files:0x211170, Ffree:0xffffffffffffffff, Fsid:unix.Fsid{Val:[2]int32{-1469057901, -1}}, Namelen:255, Frsize:4194304, Flags:1056, Spare:[4]int64{0, 0, 0, 0}}
or more readable fmt.Printf("%+v\n", stat)
{Type:12805120 Bsize:4194304 Blocks:25600 Bfree:17896 Bavail:17896 Files:2167163 Ffree:18446744073709551615 Fsid:{Val:[-1469057901 -1]} Namelen:255 Frsize:4194304 Flags:1056 Spare:[0 0 0 0]}
I believe this is where is goes wrong with my Files:2167163
& Ffree:18446744073709551615
:
https://github.com/shirou/gopsutil/blob/ed37dc27a286a25cbe76adf405176c69191a1f37/disk/disk_unix.go#L21-L33
(Still?) experiencing this as well on latest release. For now I just subtract UsageStat.Free
from UsageStat.Total
since both of those fields are populated and correct.
I initially got this issue with using telegraf, but since this fix the fields used
and usedPercent
are working for me
Can you run this?
package main import ( "fmt" "golang.org/x/sys/unix" ) func main(){ stat := unix.Statfs_t{} unix.Statfs("/mnt/ceph", &stat) fmt.Printf("%#v\n", stat) }
Describe the bug The fields
inodesUsed
,inodesUsedPercent
,used
andusedPercent
fields are always 0. The fieldstotal
andfree
are working fine. When I rundf -H
values are working fine. Only tested on Debian machine.To Reproduce Mount
Test script
Output
Expected behavior
Environment (please complete the following information):
/etc/os-release
and the result ofuname -a
]Additional context N/A