serverstatus

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package serverstatus 采集本机的系统负载指标(CPU/内存/磁盘/运行时长), 供 panel 的 ReportNodeStatus 周期上报使用。基于 gopsutil/v3,跨平台容错: 任何单项采集失败都返回 0 并把错误并入合并错误,绝不 panic。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSystemInfo

func GetSystemInfo() (cpuPct float64, memPct float64, diskPct float64, uptime uint64, err error)

GetSystemInfo 采集一次系统信息:

  • cpu: 最近一次采样区间的总 CPU 使用率(百分比,0~100)
  • mem: 物理内存已用百分比(0~100)
  • disk: 根卷已用百分比(0~100;Windows 为系统盘)
  • uptime: 主机运行时长(秒)

任何单项失败都会被记入合并错误一并返回,对应字段保持 0; 调用方即使收到非 nil error 也可安全使用已成功采集的字段。

Types

This section is empty.

Jump to

Keyboard shortcuts

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