iostat

package
v0.0.0-...-1c5d739 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrIOStatNoDevice occurs when the device name is not in iostat output
	ErrIOStatNoDevice = errors.New("No device metric in iostat output")
)

Functions

func ParseIOStat

func ParseIOStat(r io.Reader) (map[string]DeviceUtilizationReport, error)

ParseIOStat creates a map of DeviceUtilizationReports (device name as keys) from a reader with iostat output.

Types

type DeviceUtilizationReport

type DeviceUtilizationReport struct {
	Device    string  // Device name
	TPS       float64 // Transfers Per Second
	BlkReadPS float64 // Reads in blocks per Second
	BlkWrtnPS float64 // Writes in blocks per Second
	BlkRead   float64 // Blocks Read total
	BlkWrtn   float64 // Blocks Written total
	KBReadPS  float64 // Kilobytes Read Per Second
	KBWrtnPS  float64 // Kilobytes Written Per Second
	KBRead    float64 // Kilobytes Read total
	KBWrtn    float64 // Kilobytes Written total
	MBReadPS  float64 // Megabytes Read Per Second
	MBWrtnPS  float64 // Megabytes Written Per Second
	MBRead    float64 // Megabytes Read total
	MBWrtn    float64 // Megabytes Written total
	RRQMPS    float64 // Read Requests Merged Per Second
	WRQMPS    float64 // Write Requests Merged Per Second
	RPS       float64 // Reads Per Second
	WPS       float64 // Writes Per Second
	RSecPS    float64 // Read Sectors Per Second
	WSecPS    float64 // Written Sectors Per Second
	RKBPS     float64 // Read Kilobytes Per Second
	WKBPS     float64 // Written Kilobytes Per Second
	RMBPS     float64 // Read Megabytes Per Second
	WMBPS     float64 // Written Megabytes Per Second
	AvgRqSz   float64 // Average Request Size (in sectors)
	AvgQuSz   float64 // Average Queue Size
	PctUtil   float64 // CPU bandwidth utilization by device requests
	Await     float64 // The  average time (in  milliseconds) for I/O requests issued to the device to be served
}

DeviceUtilizationReport is a full iostat report. Some fields may not be used if they are not output by an iostat call.

func (DeviceUtilizationReport) ToSimpleIOStat

func (d DeviceUtilizationReport) ToSimpleIOStat() (SimpleIOStat, error)

ToSimpleIOStat is a simple version of a DeviceUtilizationReport

type Getter

type Getter interface {
	GetIOStatsCh() (<-chan map[string]DeviceUtilizationReport, error)
	GetStatInterval() time.Duration
}

Getter is an interface to get a channel that reports iostats.

type Reporter

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

Reporter implements IOStatGetter and uses interval and quit to control reporting.

func NewReporter

func NewReporter(interval time.Duration, quit <-chan interface{}) *Reporter

NewReporter creates a new IOStatReporter with interval and quit.

func (*Reporter) GetIOStatsCh

func (reporter *Reporter) GetIOStatsCh() (<-chan map[string]DeviceUtilizationReport, error)

GetIOStatsCh calls iostat with -dNxy and an interval defined in reporter. It parses the output and creates a DeviceUtilizationReport for each device and sends it to the returned channel.

func (*Reporter) GetStatInterval

func (reporter *Reporter) GetStatInterval() time.Duration

GetStatInterval implements Getter, returns the stat reporting interval

type SimpleIOStat

type SimpleIOStat struct {
	Device string
	RPS    float64
	WPS    float64
	Await  float64
}

SimpleIOStat contains basic information from iostat

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL