# README
systats
Go module to get linux system stats.
taken from https://github.com/dhamith93/systats
Provides following information on systems:
- System
- Returns OS, Hostname, Kernel, Up time, last boot date, timezone, logged in users list
- CPU
- CPU model, freq, load average (overall, per core), etc
- Memory/SWAP
- Disks
- File system, type, mount point, usage, inodes
- Networks
- Interface, IP, Rx/Tx
- Service status
- Returns if given service is active or not
- Processes
- Returns list of processes sorted by CPU/Memory usage (with PID, exec path, user, usage)
Usage
Import the module
func main() {
syStats := systats.New()
}
And use the methods to get the required and supported system stats.
System
Returns OS, Hostname, Kernel, Up time, last boot date, timezone, logged in users list
func main() {
syStats := systats.New()
system, err := systats.GetSystem()
}
CPU
CPU info and load avg info (overall, and per core)
func main() {
syStats := systats.New()
cpu, err := systats.GetCPU()
}
Memory
func main() {
syStats := systats.New()
memory, err := systats.GetMemory(systats.Megabyte)
}
SWAP
func main() {
syStats := systats.New()
swap, err := systats.GetSwap(systats.Megabyte)
}
Disks
func main() {
syStats := systats.New()
disks, err := syStats.GetDisks()
}
Networks
Interface info and usage info
func main() {
syStats := systats.New()
networks, err := syStats.GetNetworks()
}
Service status
Returns if service is running or not
func main() {
syStats := systats.New()
running := syStats.IsServiceRunning(service)
if !running {
fmt.Println(service + " not running")
}
}
Running processes
Returns running processes sorted by CPU or memory usage
func main() {
syStats := systats.New()
procs, err := syStats.GetTopProcesses(10, "cpu")
procs, err := syStats.GetTopProcesses(10, "memory")
}
# Functions
No description provided by the author
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
CPU holds information on CPU and CPU usage.
Disk holds information on single disk.
No description provided by the author
DiskUsage holds information on single disk usage information.
No description provided by the author
InodeUsage holds information on single disk inode usage.
Memory holds information on system memory usage.
No description provided by the author
Network holds interface information.
NetworkUsage holds Tx/Rx usage information.
Process holds information on single process.
Swap holds information on system swap usage.
SyStats holds information used to collect data.
System holds operating system information.
User holds logged in user information.