Skip to content

likexian/host-stat-go

Repository files navigation

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