gsysinfo

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MulanPSL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OsWindows windows os
	OsWindows = "windows"
	// OsMac mac os
	OsMac = "darwin"
	// OsLinux linux os
	OsLinux = "linux"
)
View Source
const (
	B  = 1
	KB = 1024 * B
	MB = 1024 * KB
	GB = 1024 * MB
)

Variables

This section is empty.

Functions

func FormatSize

func FormatSize(fileSize int64) (size string)

FormatSize 字节的单位转换 保留两位小数

func NetworkIO

func NetworkIO(pernic bool) (io []net.IOCountersStat, err error)

Types

type Cpu

type Cpu struct {
	Cpus    []float64 `json:"cpus"`
	Cores   int       `json:"cores"`
	Percent int       `json:"percent"`
}

func InitCPU

func InitCPU(percpu bool) (c Cpu, err error)

type Disk

type Disk struct {
	Used        int `json:"used"`
	Total       int `json:"total"`
	UsedPercent int `json:"usedPercent"`
}

func InitDisk

func InitDisk() (d Disk, err error)

type InfoStat

type InfoStat struct {
	Hostname             string `json:"hostname"`
	Uptime               uint64 `json:"uptime"`
	BootTime             uint64 `json:"bootTime"`
	Procs                uint64 `json:"procs"`           // number of processes
	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
	VirtualizationSystem string `json:"virtualizationSystem"`
	VirtualizationRole   string `json:"virtualizationRole"` // guest or host
	HostID               string `json:"hostid"`             // ex: uuid
}

func InitHost

func InitHost() (info InfoStat, err error)

type Os

type Os struct {
	GOOS         string `json:"goos"`
	NumCPU       int    `json:"numCpu"`
	Compiler     string `json:"compiler"`
	GoVersion    string `json:"goVersion"`
	NumGoroutine int    `json:"numGoroutine"`
}

func InitOS

func InitOS() (o Os)

@function: InitCPU @description: OS信息 @return: o Os, err error

type Rrm

type Rrm struct {
	Used        int `json:"used"`
	Total       int `json:"total"`
	UsedPercent int `json:"usedPercent"`
}

func InitRAM

func InitRAM() (r Rrm, err error)

type Server

type Server struct {
	Os   Os   `json:"os"`
	Cpu  Cpu  `json:"cpu"`
	Rrm  Rrm  `json:"ram"`
	Disk Disk `json:"disk"`
}

Jump to

Keyboard shortcuts

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