stats

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CPUStats

type CPUStats struct {
	User time.Duration
	Sys  time.Duration
	Idle time.Duration
}

CPUStats emulates Linux's /proc/stat.

func ReadCPUStats

func ReadCPUStats(ctx context.Context, opts ...Option) (*CPUStats, error)

type CPUTime

type CPUTime struct {
	User      time.Duration // the time in user mode (millisecconds)
	Sys       time.Duration
	Real      time.Duration
	ChildUser time.Duration // exited children and descendants time in user mode
	ChildSys  time.Duration
	ChildReal time.Duration
}

CPUTime represents /dev/cputime or a part of /proc/n/status.

type CPUType

type CPUType struct {
	Name  string
	Clock int // clock rate in MHz
}

CPUType represents /dev/cputype.

func ReadCPUType

func ReadCPUType(ctx context.Context, opts ...Option) (*CPUType, error)

type Config

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

type Gauge

type Gauge struct {
	Used  int64
	Avail int64
}

Gauge is used/available gauge.

func (Gauge) Free

func (g Gauge) Free() int64

type Host

type Host struct {
	Sysname    string
	Storages   []*Storage
	Interfaces []*Interface
}

Host represents host status.

func ReadHost

func ReadHost(ctx context.Context, opts ...Option) (*Host, error)

ReadHost reads host status.

type IPStats

type IPStats struct {
	ID      int    // number of interface in ipifc dir
	Device  string // associated physical device
	MTU     int    // max transfer unit
	Sendra6 uint8  // on == send router adv
	Recvra6 uint8  // on == recv router adv

	Pktin  int64 // packets read
	Pktout int64 // packets written
	Errin  int64 // read errors
	Errout int64 // write errors
}

type Interface

type Interface struct {
	Name string
	Addr string
}

func ReadInterfaces

func ReadInterfaces(ctx context.Context, opts ...Option) ([]*Interface, error)

ReadInterfaces reads network interfaces from etherN.

type InterfaceStats

type InterfaceStats struct {
	PacketsReceived  int64 // in packets
	Link             int   // link status
	PacketsSent      int64 // out packets
	NumCRCErr        int   // input CRC errors
	NumOverflows     int   // packet overflows
	NumSoftOverflows int   // software overflow
	NumFramingErr    int   // framing errors
	NumBufferingErr  int   // buffering errors
	NumOutputErr     int   // output errors
	Promiscuous      int   // number of promiscuous opens
	Mbps             int   // megabits per sec
	Addr             string
}

func ReadInterfaceStats

func ReadInterfaceStats(ctx context.Context, opts ...Option) (*InterfaceStats, error)

type Iplifc

type Iplifc struct {
	IP            net.IP
	Mask          net.IPMask
	Net           net.IP // ip & mask
	PerfLifetime  int64  // preferred lifetime
	ValidLifetime int64  // valid lifetime
}

type Ipv6rp

type Ipv6rp struct {
}

type MemStats

type MemStats struct {
	Total       int64 // total memory in byte
	PageSize    int64 // a page size in byte
	KernelPages int64
	UserPages   Gauge
	SwapPages   Gauge

	Malloced Gauge // kernel malloced data in byte
	Graphics Gauge // kernel graphics data in byte
}

MemStats represents the memory statistics.

func ReadMemStats

func ReadMemStats(ctx context.Context, opts ...Option) (*MemStats, error)

ReadMemStats reads memory statistics from /dev/swap.

type Option

type Option func(*Config)

func WithRootDir

func WithRootDir(dir string) Option

type Partition

type Partition struct {
	Name  string
	Start uint64
	End   uint64
}

Partition represents a part of /dev/sdXX/ctl.

type ProcStatus

type ProcStatus struct {
	Name         string
	User         string
	State        string
	Times        CPUTime
	MemUsed      int64  // in units of 1024 bytes
	BasePriority uint32 // 0(low) to 19(high)
	Priority     uint32 // 0(low) to 19(high)
}

ProcStatus represents a /proc/n/status.

type Storage

type Storage struct {
	Name       string
	Model      string
	Capacity   int64
	Partitions []*Partition
}

Storage represents /dev/sdXX/ctl.

func ReadStorages

func ReadStorages(ctx context.Context, opts ...Option) ([]*Storage, error)

type SysStats

type SysStats struct {
	ID           int
	NumCtxSwitch int64
	NumInterrupt int64
	NumSyscall   int64
	NumFault     int64
	NumTLBFault  int64
	NumTLBPurge  int64
	LoadAvg      int64 // in units of milli-CPUs and is decayed over time
	Idle         int   // percentage
	Interrupt    int   // percentage
}

func ReadSysStats

func ReadSysStats(ctx context.Context, opts ...Option) ([]*SysStats, error)

ReadSysStats reads system statistics from /dev/sysstat.

type TCPStats

type TCPStats struct {
	MaxConn            int
	MaxSegment         int
	ActiveOpens        int
	PassiveOpens       int
	EstablishedResets  int
	CurrentEstablished int
}

type Time

type Time struct {
	Unix     time.Duration
	UnixNano time.Duration
	Ticks    int64 // clock ticks
	Freq     int64 //cloc frequency
}

Time represents /dev/time.

func ReadTime

func ReadTime(ctx context.Context, opts ...Option) (*Time, error)

func (*Time) Uptime

func (t *Time) Uptime() time.Duration

Uptime returns uptime.

Jump to

Keyboard shortcuts

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