package blockdevice

import "github.com/prometheus/procfs/blockdevice"

Index

Types

type Diskstats

type Diskstats struct {
	Info
	IOStats
	// IoStatsCount contains the number of io stats read.  For kernel versions
	// 4.18+, there should be 18 fields read.  For earlier kernel versions this
	// will be 14 because the discard values are not available.
	IoStatsCount int
}

Diskstats combines the device Info and IOStats

type FS

type FS struct {
	// contains filtered or unexported fields
}

FS represents the pseudo-filesystems proc and sys, which provides an interface to kernel data structures.

func NewFS

func NewFS(procMountPoint string, sysMountPoint string) (FS, error)

NewFS returns a new blockdevice fs using the given mountPoints for proc and sys. It will error if either of these mount points can't be read.

func (FS) ProcDiskstats

func (fs FS) ProcDiskstats() ([]Diskstats, error)

ProcDiskstats reads the diskstats file and returns an array of Diskstats (one per line/device)

func (FS) SysBlockDeviceStat

func (fs FS) SysBlockDeviceStat(device string) (IOStats, int, error)

SysBlockDeviceStat returns stats for the block device read from /sys/block/<device>/stat. The number of stats read will be 15 if the discard stats are available (kernel 4.18+) and 11 if they are not available.

func (FS) SysBlockDevices

func (fs FS) SysBlockDevices() ([]string, error)

SysBlockDevices lists the device names from /sys/block/<dev>

type IOStats

type IOStats struct {
	// ReadIOs is the number of reads completed successfully.
	ReadIOs uint64
	// ReadMerges is the number of reads merged.  Reads and writes
	// which are adjacent to each other may be merged for efficiency.
	ReadMerges uint64
	// ReadSectors is the total number of sectors read successfully.
	ReadSectors uint64
	// ReadTicks is the total number of milliseconds spent by all reads.
	ReadTicks uint64
	// WriteIOs is the total number of writes completed successfully.
	WriteIOs uint64
	// WriteMerges is the number of reads merged.
	WriteMerges uint64
	// WriteSectors is the total number of sectors written successfully.
	WriteSectors uint64
	// WriteTicks is the total number of milliseconds spent by all writes.
	WriteTicks uint64
	// IOsInProgress is number of I/Os currently in progress.
	IOsInProgress uint64
	// IOsTotalTicks is the number of milliseconds spent doing I/Os.
	// This field increases so long as IosInProgress is nonzero.
	IOsTotalTicks uint64
	// WeightedIOTicks is the weighted number of milliseconds spent doing I/Os.
	// This can also be used to estimate average queue wait time for requests.
	WeightedIOTicks uint64
	// DiscardIOs is the total number of discards completed successfully.
	DiscardIOs uint64
	// DiscardMerges is the number of discards merged.
	DiscardMerges uint64
	// DiscardSectors is the total number of sectors discarded successfully.
	DiscardSectors uint64
	// DiscardTicks is the total number of milliseconds spent by all discards.
	DiscardTicks uint64
}

IOStats models the iostats data described in the kernel documentation https://www.kernel.org/doc/Documentation/iostats.txt, https://www.kernel.org/doc/Documentation/block/stat.txt, and https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats

type Info

type Info struct {
	MajorNumber uint32
	MinorNumber uint32
	DeviceName  string
}

Info contains identifying information for a block device such as a disk drive

Source Files

stats.go

Version
v0.0.1
Published
May 29, 2019
Platform
js/wasm
Imports
7 packages
Last checked
4 hours ago

Tools for package owners.