gopsutilx

package
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HostInfo

type HostInfo struct {
	Hostname             string `json:"hostname"`
	Uptime               uint64 `json:"uptime"`
	BootTime             uint64 `json:"bootTime"`
	Procs                uint64 `json:"procs"`
	OS                   string `json:"os"`
	Platform             string `json:"platform"`
	PlatformFamily       string `json:"platformFamily"`
	PlatformVersion      string `json:"platformVersion"`
	KernelVersion        string `json:"kernelVersion"`
	KernelArch           string `json:"kernelArch"`
	VirtualizationSystem string `json:"virtualizationSystem"`
	VirtualizationRole   string `json:"virtualizationRole"`
	HostID               string `json:"hostId"`
}

type SystemLoad

type SystemLoad struct {
}

func NewSystemLoad

func NewSystemLoad() *SystemLoad

func (*SystemLoad) CpuAllUsage

func (s *SystemLoad) CpuAllUsage(interval ...time.Duration) (float64, error)

CpuAllUsage 获取整体 CPU 使用率(阻塞约 1 秒)

  • interval: 获取 CPU 使用率的间隔时间,默认为 0,表示阻塞约 1 秒

func (*SystemLoad) CpuInfo

func (s *SystemLoad) CpuInfo() ([]cpu.InfoStat, error)

CpuInfo 获取 CPU 信息

func (*SystemLoad) CpuUsage

func (s *SystemLoad) CpuUsage() ([]float64, error)

CpuUsage 获取CPU使用情况

func (*SystemLoad) DiskTotals

func (s *SystemLoad) DiskTotals() ([]string, error)

DiskTotals 获取总磁盘信息

func (*SystemLoad) DiskUsage

func (s *SystemLoad) DiskUsage(name []string) ([]Usage, error)

DiskUsage 获取磁盘使用情况

  • name: 磁盘名称

func (*SystemLoad) HostInfo

func (s *SystemLoad) HostInfo(ctx context.Context) (HostInfo, error)

HostInfo 获取系统信息【hostname、hostId、os等】

func (*SystemLoad) MemUsage

func (s *SystemLoad) MemUsage() (Usage, error)

MemUsage 获取内存使用情况

func (*SystemLoad) SystemLoad

func (s *SystemLoad) SystemLoad() (uint, error)

SystemLoad 获取系统负载【根据cpu、内存使用情况,给出综合评分结果】

  • 0未获取、1系统良好负载、2系统警戒负载、3系统危险负载

type Usage

type Usage struct {
	Name        string  // 磁盘名称
	Total       uint64  // 总空间
	Used        uint64  // 已使用空间
	Usable      uint64  // 可用空间
	UsedPercent float64 // 使用百分比,使用率
}

Usage 空间结构体使用情况

  • name: 磁盘/内存等名称/其他描述
  • total: 总空间,默认单位为字节
  • used: 已使用空间,默认单位为字节
  • usable: 可用空间,默认单位为字节
  • usedPercent: 使用百分比,使用率,%0-100, 类型float64

Jump to

Keyboard shortcuts

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