stat

package
v1.10.3 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: MIT Imports: 8 Imported by: 2

README

stat

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


Example of use

    import "github.com/zhufuyi/sponge/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
        stat.WithPrintField(logger.String("service_name", cfg.App.Name), logger.String("host", cfg.App.Host)), // add custom fields to log
    )

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 WithPrintField added in v1.9.1

func WithPrintField(fields ...zap.Field) Option

WithPrintField set print field

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