diskusage

package
v0.0.0-...-df36a95 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package diskusage calculates IO usage of the block devices. Usage is calculated by taking the difference between two snapshots of IO statistics of the block devices, /proc/diskstats. The time elapsed between the two snapshots is stored in the TimeDelta field. Instead of returning a Go struct, it returns Flatbuffer serialized bytes. A function to deserialize the Flatbuffer serialized bytes into a struct.DiskUsage struct is provided.

Note: the package name is diskusage and not the final element of the import path (flat).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deserialize

func Deserialize(p []byte) *structs.DiskUsage

Deserialize takes some Flatbuffer serialized bytes and deserializes them as a structs.DiskUsage.

func Get

func Get() (p []byte, err error)

Get returns the current IO usage of the block devices as Flatbuffer serialized bytes using the package's global Profiler. The Profiler is instantiated lazily. If the profiler doesn't already exist, the first utilization information will not be useful due to minimal time elapsing between the initial and second snapshots used for utilization calculations; the results of the first call should be discarded.

func NewTicker

func NewTicker(d time.Duration) (joe.Tocker, error)

NewTicker returns a new Ticker containing a Data channel that delivers the data at intervals and an error channel that delivers any errors encountered. Stop the ticker to signal the ticker to stop running. Stopping the ticker does not close the Data channel; call Close to close both the ticker and the data channel.

func Serialize

func Serialize(u *structs.DiskUsage) (p []byte, err error)

Serialize IO usage of the block devices as Flatbuffer serialized bytes using the package's global Profiler.

Types

type Profiler

type Profiler struct {
	*usage.Profiler
	*fb.Builder
}

Profiler is used to process IO usage of the block devices using Flatbuffers.

func NewProfiler

func NewProfiler() (prof *Profiler, err error)

Returns an initialized Profiler; ready to use. Upon creation, a /proc/diskstats snapshot is taken so that any Get() will return valid information

func (*Profiler) Get

func (prof *Profiler) Get() ([]byte, error)

Get returns the current IO usage of the block devices as Flatbuffer serialized bytes. Calculating usage requires two snapshots. This func gets the current snapshot of /proc/diskstats and calculates the difference between that and the prior snapshot. The current snapshot is stored for use as the prior snapshot on the next Get call. If ongoing usage information is desired, the Ticker should be used; it's better suited for ongoing usage information.

func (*Profiler) Serialize

func (prof *Profiler) Serialize(u *structs.DiskUsage) []byte

Serialize IO usage of the block devices using Flatbuffers.

type Ticker

type Ticker struct {
	*joe.Ticker
	Data chan []byte
	*Profiler
}

Ticker delivers the system's IO usage of the block devices at intervals.

func (*Ticker) Close

func (t *Ticker) Close()

Close closes the ticker resources.

func (*Ticker) Run

func (t *Ticker) Run()

Run runs the ticker.

Jump to

Keyboard shortcuts

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