statgo

Access OS metrics from Golang,

  • Owner: akhenakh/statgo
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

wercker status

StatGo

StatGo give you access to OS metrics like network interface bandwith, cpus usage ...
It supports FreeBSD, Linux, OSX & more, it's in fact a libstatgrab binding for Golang.
Tested on FreeBSD, OSX, Linux amd64, Linux arm.

Compilation

You need at least libstatgrab 0.91, Debian & Ubuntu only have 0.90 ...

On Debian/Ubunt & OSX, you can simply install libstatgrab with the usual commands:

./configure --prefix=/usr/local
make
sudo make install

You may have to set CGO_LDFLAGS and CGO_CFLAGS environment according to your path:

export CGO_CFLAGS=-I/usr/local/include
export CGO_LDFLAGS=-L/usr/local/lib

Note: On OSX you need to install gcc to access cgo.

go get github.com/akhenakh/statgo

Usage

s := NewStat()
s.HostInfos()
OSName: Darwin
OSRelease:  14.4.0
OSVersion:  Darwin Kernel Version 14.4.0: Thu May 28 11:35:04 PDT 2015; root:xnu-2782.30.5~1/RELEASE_X86_64
Platform:   x86_64
HostName:   kamoulox
NCPUs:      4
MaxCPUs:    4
BitWidth:   64

s.CPUStats()
User:       7.500000
Kernel:     2.500000
Idle:       90.000000
IOWait      0.000000
Swap:       0.000000
Nice:       0.000000
LoadMin1:   2.206055
LoadMin5:   2.031250
LoadMin15:  1.970703

s.FSInfos()[0]
DeviceName:         /dev/disk1
FSType:             hfs
MountPoint:         /
Size:               249769230336
Used:               224367140864
Free:               25402089472
Available:          25139945472
TotalInodes:        60978814
UsedInodes:         54841132
FreeInodes:         6137682
AvailableInodes:    6137682

s.InterfaceInfos()[0]
Name:   en2
Speed:  0
Factor: 1000000
Duplex: Full Duplex
State:  UP

s.MemStats()
Total:      16649420800
Free:       4323848192
Used:       12325572608
Cache:      0
SwapTotal:  3221225472
SwapUsed:   2528378880
SwapFree:   692846592

s.NetIOStats()
IntName:    en0
TX:         2310272606
RX:         3336240203
IPackets:   114473581
OPackets:   129430304
IErrors:    0
OErrors:    0
Collisions: 0

s.ProcessStats()
Total:      343
Running:    335
Sleeping:   0
Stopped:    0
Zombie:     8

s.PagesStats()
PageIn:     90173695
PageOut:    90173695

Status

  • Host infos
  • cpu stats
  • load average
  • network interfaces infos
  • mem stats
  • swap stat
  • io stats
  • net io stats
  • process count
  • page stats

Contributors

Main metrics

Overview
Name With Ownerakhenakh/statgo
Primary LanguageGo
Program languageGo (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2015-07-31 03:29:31
Pushed At2024-01-29 21:58:57
Last Commit At2017-10-20 22:19:04
Release Count0
用户参与
Stargazers Count457
Watchers Count23
Fork Count30
Commits Count42
Has Issues Enabled
Issues Count14
Issue Open Count1
Pull Requests Count1
Pull Requests Open Count1
Pull Requests Close Count2
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private