statKit

package
v3.0.81 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustSetup

func MustSetup(logPath string)

func PrintStats

func PrintStats(logger *logrus.Logger)

func Setup

func Setup(logPath string) error

Types

type MachineStats

type MachineStats struct {
	CpuUsagePercent      float64 `json:"cpuUsagePercent"`
	CpuUsagePercentError error   `json:"cpuUsagePercentError,omitempty"`

	DiskPath              string  `json:"diskPath,omitempty"`
	DiskUsagePercent      float64 `json:"diskUsagePercent,omitempty"`
	DiskUsagePercentError error   `json:"diskUsagePercentError,omitempty"`

	// ProcessCount 进程数
	ProcessCount      int   `json:"processCount,omitempty"`
	ProcessCountError error `json:"processCountError,omitempty"`

	// ProcessThreadCount 进程数(包括线程数)
	ProcessThreadCount      int   `json:"processThreadCount,omitempty"`
	ProcessThreadCountError error `json:"processThreadCountError,omitempty"`

	MemoryStatsError error   `json:"memoryStatsError,omitempty"`
	Total            string  `json:"total,omitempty"`
	Available        string  `json:"available,omitempty"`
	Used             string  `json:"used,omitempty"`
	UsedPercent      float64 `json:"usedPercent,omitempty"`
	Free             string  `json:"free,omitempty"`

	MaxProcessThreadCountByUser      int    `json:"maxProcessThreadCountByUser,omitempty"`
	MaxProcessThreadCountByUserError string `json:"maxProcessThreadCountByUserError,omitempty"`
	PidMax                           int    `json:"pidMax,omitempty"`
	PidMaxError                      string `json:"pidMaxError,omitempty"`
	ThreadsMax                       int    `json:"threadsMax,omitempty"`
	ThreadsMaxError                  string `json:"threadsMaxError,omitempty"`
	MaxMapCount                      int    `json:"maxMapCount,omitempty"`
	MaxMapCountError                 string `json:"maxMapCountError,omitempty"`
}

type ProgramStats

type ProgramStats struct {
	PID            int `json:"pid"`
	GoroutineCount int `json:"goroutineCount"`

	Alloc      string `json:"alloc"`
	TotalAlloc string `json:"totalAlloc"`
	Sys        string `json:"sys"`
	NumGC      uint32 `json:"numGC"`
	EnableGC   bool   `json:"enableGC"`

	CpuUsagePercent      float64 `json:"cpuUsagePercent"`
	CpuUsagePercentError error   `json:"cpuUsagePercentError,omitempty"`
}

type Stats

type Stats struct {
	Program *ProgramStats `json:"program"`

	Machine *MachineStats `json:"machine"`
}

func GetStats

func GetStats() *Stats

GetStats

PS: 由于获取CPU使用率耗时较长,本函数内部使用 sync.WaitGroup.

Jump to

Keyboard shortcuts

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