You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug IOCountersStat.SerialNumber always have no value on linux
I use telegraf to monitor disk which use this go module to get disk info, and the serial of disk always be null.
To Reproduce
package main
import (
"github.com/shirou/gopsutil/v3/disk""fmt"
)
funcmain() {
info, err:=disk.IOCounters("/dev/sda")
if (err!=nil) {
fmt.Print(err)
}
fmt.Println(info)
serialNumber, err:=disk.SerialNumber("/dev/sda")
if (err!=nil) {
fmt.Print(err)
}
fmt.Println(serialNumber)
serialNumber, err=disk.SerialNumber("sda")
if (err!=nil) {
fmt.Print(err)
}
fmt.Println(serialNumber)
}
result:
map[sda:{"readCount":398790,"mergedReadCount":1,"writeCount":613726,"mergedWriteCount":360,"readBytes":20676746240,"writeBytes":55764192768,"readTime":3302034,"writeTime":2927377,"iopsInProgress":0,"ioTime":6360176,"weightedIO":8757288,"name":"sda","serialNumber":"","label":""}]
INTEL_SSDSC2BW240A4_CVDA4152****<CENSORED>***
no such file or directory
Expected behavior disk.IOCounters should contain serial number of disks.
Environment (please complete the following information):
Linux: [paste contents of /etc/os-release and the result of uname -a]
Let me clarify the problem:
I want to use disk.IOCounters() to get disk metrics and disks' serial number. So I called the disk.IOCounters() function with parameter names be something like ["/dev/sda", "/dev/sdb"...].
And in the disk.IOCountersWithContext(), the d.SerialNumber is assigned by disk.SerialNumberWithContext() with name as parameter and ignoring errors.
But the name variable gets from /proc/diskstats in sd* form. So it always call disk.SerialNumberWithContext(ctx, "sd*") and return nil. Resulting the d.SerialNumber always be nil.
Describe the bug
IOCountersStat.SerialNumber
always have no value on linuxI use telegraf to monitor disk which use this go module to get disk info, and the serial of disk always be null.
To Reproduce
result:
Expected behavior
disk.IOCounters
should contain serial number of disks.Environment (please complete the following information):
Linux: [paste contents of
/etc/os-release
and the result ofuname -a
]cat /etc/os_release
uname -a
Additional context
Actually this line will fail every time when it was called from IOCounters
gopsutil/v3/disk/disk_linux.go
Line 444 in 8d7a3ab
The
name
variable should prepend/dev/
The text was updated successfully, but these errors were encountered: