Categorygithub.com/likexian/host-stat-go
modulepackage
0.0.0-20190516151207-c9cf36dd6ce9
Repository: https://github.com/likexian/host-stat-go.git
Documentation: pkg.go.dev

# README

host-stat

License GoDoc Build Status Go Report Card Code Cover

host-stat-go is a Go module for collecting host stat.

Overview

This module provided functions to collect cpu/mem/disk/io/load/uptime/kernel info of the host.

Work for popular LINUX distributions ONLY

Installation

go get -u github.com/likexian/host-stat-go

Importing

import (
    "github.com/likexian/host-stat-go"
)

Documentation

Visit the docs on GoDoc

Example

Get the memory stat

memStat, err := hoststat.GetMemStat()
if err == nil {
    // print total memory of host in KB
    fmt.Println(memStat.MemTotal)

    // print used memory of host in KB
    fmt.Println(memStat.MemUsed)

    // print free memory of host in KB
    fmt.Println(memStat.MemFree)

    // print used memory rate of host in percent
    fmt.Println(memStat.MemRate)
}

LICENSE

Copyright 2014-2019 Li Kexian

Licensed under the Apache License 2.0

About

DONATE

# Functions

Author returns package author.
GetCPUInfo returns cpu info.
GetCPUStat returns cpu stat.
GetDiskStat returns all disk stat.
GetHostInfo returns host info.
GetIOStat returns io stat.
GetLoadStat returns load stat.
GetMemStat returns memory stat.
GetNetStat returns net stat.
GetProcessStat returns process stat.
GetRelease returns host release info.
GetUptimeStat returns uptime stat.
License returns package license.
Version returns package version.

# Variables

StateMap is state map.

# Structs

CPUInfo storing cpu info.
CPUStat storing cpu stat.
DiskStat storing disk stat.
HostInfo storing host info.
IOStat storing io stat.
LoadStat storing load stat.
MemStat storing memory stat.
NetStat storing net stat.
ProcessStat storing process stat.
UptimeStat storing uptime stat.