sysinfo

package module
v0.0.0-...-e162450 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

README

sysinfo

golang sysinfo

Code Example

package main

import (
	"encoding/json"
	"fmt"

	"github.com/koomox/sysinfo"
)

func main() {
	si, err := sysinfo.Get()
	if err != nil {
		fmt.Println(err.Error())
		return
	}

	data, err := json.MarshalIndent(si, "", "  ")
	if err != nil {
		fmt.Println(err.Error())
		return
	}

	fmt.Println(string(data))
}

Documentation

Index

Constants

View Source
const (
	KB  = 1024
	MB  = KB * 1024
	GB  = MB * 1024
	TB  = GB * 1024
	KiB = 1000
	MiB = KiB * 1000
	GiB = MiB * 1000
	TiB = GiB * 1000
)

Variables

This section is empty.

Functions

func HumanFriendlySize

func HumanFriendlySize(bytes uint64) string

func HumanFriendlyTraffic

func HumanFriendlyTraffic(bytes uint64) string

Types

type BIOS

type BIOS struct {
	Vendor  string `json:"vendor"`
	Version string `json:"version"`
	Date    string `json:"date"`
}

type Board

type Board struct {
	Name    string `json:"name"`
	Vendor  string `json:"vendor"`
	Version string `json:"version"`
	Serial  string `json:"serial"`
}

type CPU

type CPU struct {
	Vendor  string `json:"vendor"`
	Model   string `json:"model"`
	Cpus    uint32 `json:"cpus"`
	Cores   uint32 `json:"cores"`
	Threads uint32 `json:"threads"`
	Serial  string `json:"serial"`
}

type Memory

type Memory struct {
	Vendor string `json:"vendor"`
	Size   string `json:"size"`
}

type NetworkDevice

type NetworkDevice struct {
	Name string `json:"name"`
	MAC  string `json:"mac"`
}

type OS

type OS struct {
	Host      string `json:"host"`
	Name      string `json:"name"`
	Vendor    string `json:"vendor"`
	Version   string `json:"version"`
	Arch      string `json:"arch"`
	Serial    string `json:"serial"`
	Installed string `json:"installed"`
}

type StorageDevice

type StorageDevice struct {
	Name   string `json:"name"`
	Vendor string `json:"vendor"`
	Model  string `json:"model"`
	Serial string `json:"serial"`
	Size   string `json:"size"`
}

type SysInfo

type SysInfo struct {
	OS      OS              `json:"os"`
	Board   Board           `json:"board"`
	CPU     CPU             `json:"cpu"`
	BIOS    BIOS            `json:"bios"`
	Memory  Memory          `json:"memory"`
	Storage []StorageDevice `json:"storage"`
	Network []NetworkDevice `json:"network"`
}

func Get

func Get() (element *SysInfo, err error)

func (*SysInfo) ToJSON

func (c *SysInfo) ToJSON() string

Directories

Path Synopsis
providers

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL