package
1.12.6
Repository: https://github.com/go-dev-frame/sponge.git
Documentation: pkg.go.dev

# README

stat

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


Example of use

    import "github.com/go-dev-frame/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
    )

# Packages

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

# Functions

Init initialize statistical information.
WithAlarm enable alarm and notify, except windows.
WithCPUThreshold set cpu threshold, range 0 to 1.
WithLog set zapLog.
WithMemoryThreshold set memory threshold, range 0 to 1.
WithPrintField set print field.
WithPrintInterval set print interval.

# Type aliases

AlarmOption set the alarm options field.
Option set the stat options field.