Documentation
¶
Index ¶
Constants ¶
const ( ModeLoadAvg = "M LOADAVG" ModeMemStats = "M MEMSTATS" ModeNetStats = "M NETSTATS" ModeCPUStats = "M CPUSTATS" )
Protocol mode markers (line-based, sent by remote script)
Variables ¶
var LinuxScript []byte
LinuxScript contains the embedded loadbars-remote.sh script for Linux hosts
Functions ¶
Types ¶
type CPULine ¶
type CPULine struct {
Name string
User, Nice, System, Idle, Iowait, IRQ, SoftIRQ, Steal, Guest, GuestNice int64
}
CPULine is one line of /proc/stat: cpu name + counters (user, nice, system, idle, ...).
func ParseCPULine ¶
ParseCPULine parses a /proc/stat line: "cpu 100 0 50 200 0 0 0 0 0 0" (name + 10 numbers). Older kernels may have fewer fields; missing ones are treated as 0.
type LoadAvg ¶
type LoadAvg struct {
Load1, Load5, Load15 string
}
LoadAvg is 1/5/15 min load average.
func ParseLoadAvg ¶
ParseLoadAvg parses "1.0;0.5;0.2" into Load1, Load5, Load15.
type MemLine ¶
MemLine is one key from /proc/meminfo (e.g. MemTotal, MemFree).
func ParseMemLine ¶
ParseMemLine parses a /proc/meminfo line: "MemTotal: 123456 kB".
type NetLine ¶
type NetLine struct {
Iface string
B int64 // rx bytes
Tb int64 // tx bytes
P int64
Tp int64
E int64
Te int64
D int64
Td int64
}
NetLine is one interface line: iface and key=value pairs (b, tb, p, tp, e, te, d, td).
func ParseNetLine ¶
ParseNetLine parses a protocol net line: "eth0:b=0;tb=0;p=0;tp=0 e=0;te=0;d=0;td=0". There may be a space between first block (b,tb,p,tp) and second (e,te,d,td).
type StatsStore ¶
type StatsStore interface {
SetLoadAvg(host, load1, load5, load15 string)
SetCPU(host, name string, line CPULine)
SetMem(host, key string, value int64)
SetNet(host, iface string, net NetLine, stamp float64)
}
StatsStore is the interface for receiving parsed stats (implemented by app).