All Projects → mackerelio → Go Osstat

mackerelio / Go Osstat

Licence: apache-2.0
OS system statistics library for Go

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Go Osstat

fetches
hell
Stars: ✭ 21 (-85.62%)
Mutual labels:  system-information
Hardinfo
System profiler and benchmark tool for Linux systems
Stars: ✭ 385 (+163.7%)
Mutual labels:  system-information
Systemd exporter
Exporter for systemd unit metrics
Stars: ✭ 82 (-43.84%)
Mutual labels:  system-information
psutil.cr
Psutils.cr is a Crystal port of https://github.com/shirou/gopsutil
Stars: ✭ 18 (-87.67%)
Mutual labels:  system-information
netbox-agent
Netbox agent to run on your infrastructure's servers
Stars: ✭ 99 (-32.19%)
Mutual labels:  system-information
Gopsutil
psutil for golang
Stars: ✭ 7,117 (+4774.66%)
Mutual labels:  system-information
sysfex
Another system information fetching tool written in C++
Stars: ✭ 107 (-26.71%)
Mutual labels:  system-information
Archey4
💻 Maintained fork of the original Archey Linux system tool
Stars: ✭ 118 (-19.18%)
Mutual labels:  system-information
Systemstat
Rust library for getting system information
Stars: ✭ 301 (+106.16%)
Mutual labels:  system-information
Stacer
Linux System Optimizer and Monitoring - https://oguzhaninan.github.io/Stacer-Web
Stars: ✭ 7,405 (+4971.92%)
Mutual labels:  system-information
PyCPU
Central Processing Unit Information Gathering Tool
Stars: ✭ 19 (-86.99%)
Mutual labels:  system-information
scooby
🐶 🕵️ Great Dane turned Python environment detective
Stars: ✭ 36 (-75.34%)
Mutual labels:  system-information
Tmux Mem Cpu Load
CPU, RAM, and load monitor for use with tmux
Stars: ✭ 746 (+410.96%)
Mutual labels:  system-information
disfetch
Yet another *nix distro fetching program, but less complex.
Stars: ✭ 45 (-69.18%)
Mutual labels:  system-information
Amon
Amon is a modern server monitoring platform.
Stars: ✭ 1,331 (+811.64%)
Mutual labels:  system-information
node exporter
Exporter for machine metrics
Stars: ✭ 7,897 (+5308.9%)
Mutual labels:  system-information
Otseca
Open source security auditing tool to search and dump system configuration. It allows you to generate reports in HTML or RAW-HTML formats.
Stars: ✭ 416 (+184.93%)
Mutual labels:  system-information
Seeker
Accurately Locate Smartphones using Social Engineering
Stars: ✭ 2,772 (+1798.63%)
Mutual labels:  system-information
Cfg2html
cfg2html is a UNIX shell script similar to supportinfo, getsysinfo or get_config, except that it creates a HTML (and plain ASCII) system documentation for HP-UX, SCO-UNIX, AIX, Sun OS and Linux systems. Plug-ins for SAP, Oracle, Informix, Serviceguard, Fiber Channel/SAN, TIP/ix, OpenText (IXOS/LEA), SN Mass Storage like MAS, EMC, EVA, XPs, Network Node Manager and DataProtector etc. are included. The first versions of cfg2html were written for HP-UX. Meanwhile the cfg2html HP-UX stream was ported to all major *NIX platforms and small embedded systems.
Stars: ✭ 116 (-20.55%)
Mutual labels:  system-information
Pfetch
🐧 A pretty system information tool written in POSIX sh.
Stars: ✭ 816 (+458.9%)
Mutual labels:  system-information

OS system statistics library for Go

This is a library to get system metrics like cpu load and memory usage. The library is created for mackerel-agent.

GoDev Build Status

Example

package main

import (
	"fmt"
	"os"

	"github.com/mackerelio/go-osstat/memory"
)

func main() {
	memory, err := memory.Get()
	if err != nil {
		fmt.Fprintf(os.Stderr, "%s\n", err)
		return
	}
	fmt.Printf("memory total: %d bytes\n", memory.Total)
	fmt.Printf("memory used: %d bytes\n", memory.Used)
	fmt.Printf("memory cached: %d bytes\n", memory.Cached)
	fmt.Printf("memory free: %d bytes\n", memory.Free)
}

Supported OS

loadavg uptime cpu memory network disk i/o
Linux yes yes yes yes yes yes
Darwin yes yes *1 yes yes no
FreeBSD yes yes no yes yes no
NetBSD yes yes no no yes no
OpenBSD yes yes no no no no
Windows no yes no yes no no

*1: unavailable without cgo

Note for counter values

This library returns the counter value for cpu, network and disk I/O statistics by design. To get the cpu usage in percent, network traffic in kB/s or disk IOPS, sleep for a while and calculate the difference.

package main

import (
	"fmt"
	"os"
	"time"

	"github.com/mackerelio/go-osstat/cpu"
)

func main() {
	before, err := cpu.Get()
	if err != nil {
		fmt.Fprintf(os.Stderr, "%s\n", err)
		return
	}
	time.Sleep(time.Duration(1) * time.Second)
	after, err := cpu.Get()
	if err != nil {
		fmt.Fprintf(os.Stderr, "%s\n", err)
		return
	}
	total := float64(after.Total - before.Total)
	fmt.Printf("cpu user: %f %%\n", float64(after.User-before.User)/total*100)
	fmt.Printf("cpu system: %f %%\n", float64(after.System-before.System)/total*100)
	fmt.Printf("cpu idle: %f %%\n", float64(after.Idle-before.Idle)/total*100)
}

LICENSE

Copyright 2017-2019 Hatena Co., Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].