stat

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2024 License: MIT Imports: 8 Imported by: 0

README

stat

Statistics on system and process cpu and memory information, alarm notification support.


Example of use

    import "gitee.com/the_sun_light/common_pkg/stat"

    l, _ := zap.NewDevelopment()
    stat.Init(
        stat.WithLog(l),
        stat.WithPrintInterval(time.Minute),
        stat.WithEnableAlarm(stat.WithCPUThreshold(0.9), stat.WithMemoryThreshold(0.85)), // invalid if it is windows
    )

Documentation

Overview

Package stat provides for counting system and process cpu and memory information, alarm notification support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(opts ...Option)

Init initialize statistical information

Types

type AlarmOption

type AlarmOption func(*alarmOptions)

AlarmOption set the alarm options field.

func WithCPUThreshold

func WithCPUThreshold(threshold float64) AlarmOption

WithCPUThreshold set cpu threshold, range 0 to 1

func WithMemoryThreshold

func WithMemoryThreshold(threshold float64) AlarmOption

WithMemoryThreshold set memory threshold, range 0 to 1

type Option

type Option func(*options)

Option set the stat options field.

func WithAlarm

func WithAlarm(opts ...AlarmOption) Option

WithAlarm enable alarm and notify, except windows

func WithLog

func WithLog(l *zap.Logger) Option

WithLog set zapLog

func WithPrintInterval

func WithPrintInterval(d time.Duration) Option

WithPrintInterval set print interval

Directories

Path Synopsis
Package cpu is a library that counts system and process cpu usage.
Package cpu is a library that counts system and process cpu usage.
Package mem is a library that counts system and process memory usage.
Package mem is a library that counts system and process memory usage.

Jump to

Keyboard shortcuts

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