sysutil

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Loopback = "lo"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ByteSize

type ByteSize float64
const (
	MinByteSize          = iota
	KB          ByteSize = 1 << (10 * iota)
	MB
	GB
	TB
	MaxByteSize
)

type CPU

type CPU struct {
	Family    string  `json:"family"` // ex: Intel(R) Core(TM)
	Cores     int32   `json:"cores"`
	ModelName string  `json:"modelName"` // ex: i7-8750H
	Mhz       float64 `json:"mhz"`       // ex: 2.20GHz
	CacheSize int32   `json:"cacheSize"`
}

func CUPInfo

func CUPInfo() (CPU, error)

type Disk

type Disk struct {
	DiskDevices []DiskDevice
	Total       uint64  `json:"total"`
	Free        uint64  `json:"free"`
	Used        uint64  `json:"used"`
	UsedPercent float64 `json:"usedPercent"`
}

func DiskInfo

func DiskInfo(byteSize ByteSize) (Disk, error)

type DiskDevice

type DiskDevice struct {
	Device      string  `json:"device"`     // ex: /dev/sda
	Mountpoint  string  `json:"mountpoint"` // ex: /boot
	Fstype      string  `json:"fstype"`     // ex: xfs
	Total       uint64  `json:"total"`
	Free        uint64  `json:"free"`
	Used        uint64  `json:"used"`
	UsedPercent float64 `json:"usedPercent"`
}

type Host

type Host struct {
	Hostname        string `json:"hostname"`
	OS              string `json:"os"`              // ex: freebsd, linux
	Platform        string `json:"platform"`        // ex: ubuntu, linuxmint
	PlatformFamily  string `json:"platformFamily"`  // ex: debian, rhel
	PlatformVersion string `json:"platformVersion"` // version of the complete OS
	KernelVersion   string `json:"kernelVersion"`   // version of the OS kernel (if available)
	KernelArch      string `json:"kernelArch"`      // native cpu architecture queried at runtime, as returned by `uname -m` or empty string in case of error
	HostID          string `json:"hostId"`          // ex: uuid
}

func HostInfo

func HostInfo() (Host, error)

type InterfaceAddr

type InterfaceAddr struct {
	Family string `json:"family"` //ex: ipv4/ipv6
	Addr   string `json:"addr"`
}

NetInterfaceAddr is designed for represent interface addresses

type Memory

type Memory struct {
	Total       uint64  `json:"total"`
	Available   uint64  `json:"available"`
	Used        uint64  `json:"used"`
	UsedPercent float64 `json:"usedPercent"`
	Free        uint64  `json:"free"`
}

func MemoryInfo

func MemoryInfo(byteSize ByteSize) (Memory, error)

type Net

type Net struct {
	Index        int             `json:"index"`
	Name         string          `json:"name"`         // e.g., "en0", "lo0", "eth0.100"
	MTU          int             `json:"mtu"`          // maximum transmission unit
	HardwareAddr string          `json:"hardwareAddr"` // IEEE MAC-48, EUI-48 and EUI-64 form
	Flags        string          `json:"flags"`        // e.g., FlagUp, FlagLoopback, FlagMulticast
	Addrs        []InterfaceAddr `json:"addrs"`
}

func NetInfo

func NetInfo() ([]Net, error)

type SysInfo

type SysInfo struct {
	CPU    CPU
	Memory Memory
	Disk   Disk
	Net    []Net
	Host   Host
}

func GetSysInfo

func GetSysInfo() (*SysInfo, error)

Jump to

Keyboard shortcuts

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