sigar

package module
v1.3.55 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 12 Imported by: 446

README

Go sigar

Overview

Go sigar is a golang implementation of the sigar API. The Go version of sigar has a very similar interface, but is being written from scratch in pure go/cgo, rather than cgo bindings for libsigar.

Test drive

$ git clone https://github.com/cloudfoundry/gosigar.git
$ cd gosigar/examples
$ go run uptime.go
$ go run df.go
$ go run free.go
$ go run ps.go

Supported platforms

Currently targeting modern flavors of macOS (Darwin), Windows and Linux.

License

Apache 2.0

Documentation

Index

Constants

View Source
const (
	RunStateSleep   = 'S'
	RunStateRun     = 'R'
	RunStateStop    = 'T'
	RunStateZombie  = 'Z'
	RunStateIdle    = 'D'
	RunStateUnknown = '?'
)
View Source
const (
	MaxUint64 = ^uint64(0)
	// UnlimitedMemorySize defines the bytes size when memory limit is not set (2 ^ 63 - 4096)
	UnlimitedMemorySize = "9223372036854771712"
)

Variables

View Source
var ErrNotImplemented = errors.New("gosigar: not implemented")
View Source
var Etcd string
View Source
var Procd string
View Source
var Sysd1 string
View Source
var Sysd2 string

Functions

func FormatPercent

func FormatPercent(percent float64) string

func FormatSize

func FormatSize(size uint64) string

Go version of apr_strfsize

Types

type ConcreteSigar

type ConcreteSigar struct{}

func (*ConcreteSigar) CollectCpuStats

func (c *ConcreteSigar) CollectCpuStats(collectionInterval time.Duration) (<-chan Cpu, chan<- struct{})

func (*ConcreteSigar) GetFileSystemUsage

func (c *ConcreteSigar) GetFileSystemUsage(path string) (FileSystemUsage, error)

func (*ConcreteSigar) GetLoadAverage

func (c *ConcreteSigar) GetLoadAverage() (LoadAverage, error)

func (*ConcreteSigar) GetMem

func (c *ConcreteSigar) GetMem() (Mem, error)

func (*ConcreteSigar) GetMemIgnoringCGroups added in v1.3.0

func (c *ConcreteSigar) GetMemIgnoringCGroups() (Mem, error)

func (*ConcreteSigar) GetSwap

func (c *ConcreteSigar) GetSwap() (Swap, error)

type Cpu

type Cpu struct {
	User    uint64
	Nice    uint64
	Sys     uint64
	Idle    uint64
	Wait    uint64
	Irq     uint64
	SoftIrq uint64
	Stolen  uint64
}

func (Cpu) Delta

func (cpu Cpu) Delta(other Cpu) Cpu

func (*Cpu) Get

func (self *Cpu) Get() error

func (*Cpu) Total

func (cpu *Cpu) Total() uint64

type CpuList

type CpuList struct {
	List []Cpu
}

func (*CpuList) Get

func (self *CpuList) Get() error

type FileSystem

type FileSystem struct {
	DirName     string
	DevName     string
	TypeName    string
	SysTypeName string
	Options     string
	Flags       uint32
}

type FileSystemList

type FileSystemList struct {
	List []FileSystem
}

func (*FileSystemList) Get

func (self *FileSystemList) Get() error

type FileSystemUsage

type FileSystemUsage struct {
	Total     uint64
	Used      uint64
	Free      uint64
	Avail     uint64
	Files     uint64
	FreeFiles uint64
}

func (*FileSystemUsage) Get

func (self *FileSystemUsage) Get(path string) error

func (*FileSystemUsage) UsePercent

func (self *FileSystemUsage) UsePercent() float64

type LoadAverage

type LoadAverage struct {
	One, Five, Fifteen float64
}

func (*LoadAverage) Get

func (self *LoadAverage) Get() error

type Mem

type Mem struct {
	Total      uint64
	Used       uint64
	Free       uint64
	ActualFree uint64
	ActualUsed uint64
}

func (*Mem) Get

func (self *Mem) Get() error

func (*Mem) GetIgnoringCGroups added in v1.3.0

func (self *Mem) GetIgnoringCGroups() error

type ProcArgs

type ProcArgs struct {
	List []string
}

func (*ProcArgs) Get

func (self *ProcArgs) Get(pid int) error

type ProcCpu

type ProcCpu struct {
	ProcTime
	LastTime uint64
	Percent  float64
	// contains filtered or unexported fields
}

func (*ProcCpu) Get

func (self *ProcCpu) Get(pid int) error

type ProcExe

type ProcExe struct {
	Name string
	Cwd  string
	Root string
}

func (*ProcExe) Get

func (self *ProcExe) Get(pid int) error

type ProcList

type ProcList struct {
	List []int
}

func (*ProcList) Get

func (self *ProcList) Get() error

type ProcMem

type ProcMem struct {
	Size        uint64
	Resident    uint64
	Share       uint64
	MinorFaults uint64
	MajorFaults uint64
	PageFaults  uint64
}

func (*ProcMem) Get

func (self *ProcMem) Get(pid int) error

type ProcState

type ProcState struct {
	Name      string
	State     RunState
	Ppid      int
	Tty       int
	Priority  int
	Nice      int
	Processor int
}

func (*ProcState) Get

func (self *ProcState) Get(pid int) error

type ProcTime

type ProcTime struct {
	StartTime uint64
	User      uint64
	Sys       uint64
	Total     uint64
}

func (*ProcTime) FormatStartTime

func (self *ProcTime) FormatStartTime() string

func (*ProcTime) FormatTotal

func (self *ProcTime) FormatTotal() string

func (*ProcTime) Get

func (self *ProcTime) Get(pid int) error

type RunState

type RunState byte

type Sigar

type Sigar interface {
	CollectCpuStats(collectionInterval time.Duration) (<-chan Cpu, chan<- struct{})
	GetLoadAverage() (LoadAverage, error)
	GetMem() (Mem, error)
	GetMemIgnoringCGroups() (Mem, error)
	GetSwap() (Swap, error)
	GetFileSystemUsage(string) (FileSystemUsage, error)
}

type Swap

type Swap struct {
	Total uint64
	Used  uint64
	Free  uint64
}

func (*Swap) Get

func (self *Swap) Get() error

type Uptime

type Uptime struct {
	Length float64
}

func (*Uptime) Format

func (self *Uptime) Format() string

func (*Uptime) Get

func (self *Uptime) Get() error

Directories

Path Synopsis
fixtures
Go interface to the Linux netlink process connector.
Go interface to the Linux netlink process connector.
sys
windows
Package windows contains various Windows system call.
Package windows contains various Windows system call.

Jump to

Keyboard shortcuts

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