simplesysinfo

package module
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2023 License: GPL-2.0 Imports: 17 Imported by: 0

README

This is github.com/Nigel2392/simplesysinfo!

Installation

Easily install github.com/Nigel2392/simplesysinfo with the following command:

go get github.com/Nigel2392/simplesysinfo

Documentation

Index

Constants

View Source
const (
	INC_HOSTNAME includedItem = iota
	INC_PLATFORM
	INC_CPU
	INC_MEM
	INC_DISK
	INC_MACADDR
	INC_PROCS
	INC_NETADAPTERS
)

Variables

View Source
var IncludeAll = getIncludeAll()
View Source
var VERBOSE = false

Functions

func ByteToGB added in v1.0.5

func ByteToGB(b uint64) string

func Contains added in v1.1.3

func Contains[T comparable](slice []T, item T) bool

func GetCPUUsage

func GetCPUUsage(ms int) float32

Get cpu usage in percentage

func GetMACAddr

func GetMACAddr() (string, error)

Types

type CPU added in v1.1.9

type CPU struct {
	CPU        int32    `json:"cpu"`
	VendorID   string   `json:"vendorId"`
	Family     string   `json:"family"`
	Model      string   `json:"model"`
	Stepping   int32    `json:"stepping"`
	PhysicalID string   `json:"physicalId"`
	CoreID     string   `json:"coreId"`
	Cores      int32    `json:"cores"`
	ModelName  string   `json:"modelName"`
	Mhz        float64  `json:"mhz"`
	CacheSize  int32    `json:"cacheSize"`
	Flags      []string `json:"flags"`
	Microcode  string   `json:"microcode"`
}

type CPUInfo

type CPUInfo struct {
	CPUs         []*CPU  `json:"cpus"`
	CurrentUsage float32 `json:"currentusage"`
}

CPUInfo saves the CPU information

func (*CPUInfo) String added in v1.0.5

func (c *CPUInfo) String() string

type DiskInfo

type DiskInfo struct {
	SysID string `json:"sysid"`
	Path  string `json:"path"`
	Total uint64 `json:"total"`
	Used  uint64 `json:"used"`
	Free  uint64 `json:"free"`
}

DiskInfo saves the Disk information

func (*DiskInfo) GetUsedPercentage added in v1.0.5

func (d *DiskInfo) GetUsedPercentage() float64

func (*DiskInfo) String added in v1.0.5

func (d *DiskInfo) String() string

type NetAdapterInfo added in v1.1.2

type NetAdapterInfo struct {
	IsUp    bool     `json:"isup"`
	IsIpv4  bool     `json:"isipv4"`
	Name    string   `json:"name"`
	IP      string   `json:"ip"`
	MacAddr string   `json:"macaddr"`
	Ports   []*Ports `json:"ports"`
}

func GetNetAdapters added in v1.1.2

func GetNetAdapters() []*NetAdapterInfo

type NetAdapters added in v1.1.3

type NetAdapters []*NetAdapterInfo

func (NetAdapters) Len added in v1.1.3

func (n NetAdapters) Len() int

func (NetAdapters) String added in v1.1.3

func (n NetAdapters) String() string

type Ports added in v1.2.2

type Ports struct {
	Protocol   string `json:"protocol"`
	Port       int    `json:"port"`
	ExternalIP string `json:"external_ip"`
	State      string `json:"state"` // LISTENING, ESTABLISHED, TIME_WAIT, CLOSE_WAIT, etc
	PID        int    `json:"pid"`
}

type ProcessInfo

type ProcessInfo struct {
	Pid        int32  `json:"pid"`
	Name       string `json:"name"`
	Executable string `json:"executable"`
	Username   string `json:"username"`
	Memory     *process.MemoryInfoStat
}

func GetProcs

func GetProcs() ([]*ProcessInfo, error)

func (*ProcessInfo) String added in v1.0.5

func (p *ProcessInfo) String() string

type RAMInfo

type RAMInfo struct {
	Total uint64 `json:"total"`
	Used  uint64 `json:"used"`
	Free  uint64 `json:"free"`
	Swap  uint64 `json:"swap"`
}

RAMInfo saves the RAM information

func (*RAMInfo) GetUsedPercentage added in v1.0.5

func (r *RAMInfo) GetUsedPercentage() float64

func (*RAMInfo) String added in v1.0.5

func (r *RAMInfo) String() string

type SysInfo

type SysInfo struct {
	Hostname    string         `json:"hostname"`
	Platform    string         `json:"platform"`
	CPU         *CPUInfo       `json:"cpu"`
	RAM         *RAMInfo       `json:"ram"`
	Disk        *DiskInfo      `json:"disk"`
	Procs       []*ProcessInfo `json:"procs"`
	MainMacAddr string         `json:"macaddr"`
	NetAdapters NetAdapters    `json:"netadapters"`
}

SysInfo saves the basic system information

func GetSysInfo

func GetSysInfo(include ...includedItem) *SysInfo

func (*SysInfo) JSON added in v1.1.8

func (s *SysInfo) JSON() []byte

func (*SysInfo) String added in v1.1.3

func (s *SysInfo) String() string

func (*SysInfo) UnJSON added in v1.1.8

func (s *SysInfo) UnJSON(jdata []byte) *SysInfo

Jump to

Keyboard shortcuts

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