healthinfo

package
v1.3.3-rc7 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const HealthManagerPersistantKey = "7b14dc58c8e9f5b39ef92ee4ce7c0d93fa7d8836aa3d6b67c106608c2bd6ddb1-HealthManagerPersistantKey"

Variables

This section is empty.

Functions

func IntToString

func IntToString(orig []int8) string

func NewHealthInfo

func NewHealthInfo(ctx context.Context) (*health.HealthInfo, error)

NewHealthInfo 获取系统健康信息

2023.5.10: TODO: disk rate is waiting for fixing;

Types

type Diskstat

type Diskstat struct {
	Major         uint   //  0: major dev no
	Minor         uint   //  1: minor dev no
	Name          string //  2: device name
	ReadComplete  uint64 //  3: reads completed
	ReadMerged    uint64 //  4: writes merged
	ReadSectors   uint64 //  5: sectors read
	ReadMs        uint   //  6: ms spent reading
	WriteComplete uint64 //  7: reads completed
	WriteMerged   uint64 //  8: writes merged
	WriteSectors  uint64 //  9: sectors read
	WriteMs       uint   // 10: ms spent writing
	IOPending     uint   // 11: number of IOs currently in progress
	IOMs          uint   // 12: jiffies_to_msecs(part_stat_read(hd, io_ticks))
	IOQueueMs     uint   // 13: jiffies_to_msecs(part_stat_read(hd, time_in_queue))
}

sample:

0       1 2    3       4    5        6      7        8      9         10      11 12      13

" 8 1 sda1 3774108 2444 30194552 637303 11746691 283841 529382982 90114806 0 1657750 90747516"

%4d     %7d %s   %lu     %lu  %lu      %u     %lu      %lu    %lu       %u      %u %u      %u\n

^ from linux/block/genhd.c ~ line 1139

func ReadDiskstats

func ReadDiskstats() (out []Diskstat, _ error)

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewHealthInfoManager

func NewHealthInfoManager(interval, maxCacheTime time.Duration) (*Manager, error)

func (*Manager) Cancel

func (m *Manager) Cancel()

func (*Manager) GetAliveDuration

func (m *Manager) GetAliveDuration() time.Duration

func (*Manager) GetHealthInfos

func (m *Manager) GetHealthInfos() []*health.HealthInfo

func (*Manager) RegisterCPUAverageCallback

func (m *Manager) RegisterCPUAverageCallback(cb func(percent float64))

func (*Manager) RegisterCPUPercentCallback

func (m *Manager) RegisterCPUPercentCallback(cb func(percent float64))

func (*Manager) RegisterInfoChangedCallback

func (m *Manager) RegisterInfoChangedCallback(cb func(info []*health.HealthInfo))

func (*Manager) RegisterMemAverageCallback

func (m *Manager) RegisterMemAverageCallback(cb func(percent float64))

func (*Manager) RegisterMemPercentCallback

func (m *Manager) RegisterMemPercentCallback(cb func(percent float64))

type UsageStat

type UsageStat struct {
	Path string `json:"path"`
	//Fstype            string  `json:"fstype"`
	Total             uint64  `json:"total"`
	Free              uint64  `json:"free"`
	Used              uint64  `json:"used"`
	UsedPercent       float64 `json:"usedPercent"`
	InodesTotal       uint64  `json:"inodesTotal"`
	InodesUsed        uint64  `json:"inodesUsed"`
	InodesFree        uint64  `json:"inodesFree"`
	InodesUsedPercent float64 `json:"inodesUsedPercent"`
}

func DiskUsageWithContext

func DiskUsageWithContext(ctx context.Context, path string) (*UsageStat, error)

Jump to

Keyboard shortcuts

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