systemHelper

package
v1.5.95 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecCmd

func ExecCmd(name string, arg ...string) (res string, err error)

ExecCmd 执行shell命令 exec.Command 的第一个参数应该是命令,后续参数是命令的参数。如果 restart 是一个脚本文件,你可能需要使用 bash 或 sh 来执行它。例如: cmd := exec.Command("/bin/bash", "-c", "/home/hujiayilu/ros/RoServercode/bin/Release/restart")

func KillProgress

func KillProgress(pid int, force bool) (err error)

KillProgress 杀死进程

Types

type CpuData

type CpuData struct {
	CoreNum  int     `json:"core_num"`
	TotalPer float64 `json:"total_per"` // 总体使用率
}

func GetCpuData

func GetCpuData() (cpuData CpuData, err error)

GetCpuData 获取cpu信息

type DiskData

type DiskData struct {
	Device     string    `json:"device"`      // 分区
	MountPoint string    `json:"mount_point"` // 挂载点
	FsType     string    `json:"fs_type"`     // 文件系统类型
	Usage      DiskUsage `json:"usage"`
	Opts       []string  `json:"opts"`
}

func GetDiskData

func GetDiskData(getLogicalDisk bool) (diskData []DiskData, err error)

GetDiskData 获取硬盘信息

type DiskUsage

type DiskUsage struct {
	Path              string  `json:"path"`
	FsType            string  `json:"fs_type"`
	TotalGB           float64 `json:"total_gb"`
	FreeGB            float64 `json:"free_gb"`
	UsedGB            float64 `json:"used_gb"`
	UsedPercent       float64 `json:"used_percent"`
	InodesTotal       uint64  `json:"inodes_total"`
	InodesUsed        uint64  `json:"inodes_used"`
	InodesFree        uint64  `json:"inodes_free"`
	InodesUsedPercent float64 `json:"inodes_used_percent"`
}

type MemoryData

type MemoryData struct {
	Total       float64 `json:"total"`
	Available   float64 `json:"available"`
	Used        float64 `json:"used"`
	UsedPercent float64 `json:"used_percent"`
}

func GetMemoryData

func GetMemoryData() (memoryData MemoryData, err error)

GetMemoryData 获取内存信息

type ProgressData

type ProgressData struct {
	PID          int32    `json:"pid"`
	Name         string   `json:"name"`
	CpuPercent   float64  `json:"cpu_percent"`    // cpu占用
	MemoryUsedMB float64  `json:"memory_used_mb"` // 内存使用MB(常驻集)
	MemoryPer    float64  `json:"memory_per"`     // 内存占用
	CmdLines     []string `json:"cmd_lines"`      // 命令参数
}

func GetProgressRank

func GetProgressRank(topNum int, sequenceFlag SequenceFlag, nameFilter string) (processInfos []ProgressData, err error)

GetProgressRank 获取cpu占用进程排行榜

type SequenceFlag

type SequenceFlag int
const CpuUsage SequenceFlag = 1
const MemoryUsage SequenceFlag = 2

type SystemData

type SystemData struct {
	CPU    CpuData    `json:"cpu"`
	Memory MemoryData `json:"memory"`
	Disk   []DiskData `json:"disk"`
}

func GetSystemInfo

func GetSystemInfo(getLogicalDisk bool) (systemData SystemData, err error)

Jump to

Keyboard shortcuts

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