MCPcopy Create free account
hub / github.com/prometheus/procfs / SysBlockDevices

Method SysBlockDevices

blockdevice/stats.go:309–319  ·  view source on GitHub ↗

SysBlockDevices lists the device names from /sys/block/ .

()

Source from the content-addressed store, hash-verified

307
308// SysBlockDevices lists the device names from /sys/block/<dev>.
309func (fs FS) SysBlockDevices() ([]string, error) {
310 deviceDirs, err := os.ReadDir(fs.sys.Path(sysBlockPath))
311 if err != nil {
312 return nil, err
313 }
314 devices := []string{}
315 for _, deviceDir := range deviceDirs {
316 devices = append(devices, deviceDir.Name())
317 }
318 return devices, nil
319}
320
321// SysBlockDeviceStat returns stats for the block device read from /sys/block/<device>/stat.
322// The number of stats read will be 15 if the discard stats are available (kernel 4.18+)

Callers 5

TestBlockDeviceFunction · 0.95
TestBlockDmInfoFunction · 0.95
TestSysBlockDeviceSizeFunction · 0.95

Calls 2

NameMethod · 0.80
PathMethod · 0.45

Tested by 5

TestBlockDeviceFunction · 0.76
TestBlockDmInfoFunction · 0.76
TestSysBlockDeviceSizeFunction · 0.76