monitor

package
v12.2.0-beta5 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Monitor

type Monitor struct {
	Holder *StatsHolder
	// contains filtered or unexported fields
}

Monitor tracks and renders the server's process and operating system statistics.

Look its `Stats` and `View` methods. Initialize with the `New` package-level function.

func New

func New(opts Options) *Monitor

New returns a new Monitor. Metrics stored through expvar standard package: - pid_cpu - pid_ram - pid_conns - os_cpu - os_ram - os_total_ram - os_load_avg - os_conns

Check https://github.com/iris-contrib/middleware/tree/master/expmetric which can be integrated with datadog or other platforms.

func (*Monitor) Stats

func (m *Monitor) Stats(ctx *context.Context)

Stats sends the stats as json.

func (*Monitor) Stop

func (m *Monitor) Stop()

Stop terminates the retrieve stats loop for the process and the operating system statistics. No other monitor instance should be initialized after the first Stop call.

func (*Monitor) View

func (m *Monitor) View(ctx *context.Context)

View renders a default view for the stats.

type Options

type Options struct {
	// Optional process id, defaults to the current one.
	PID int32 `json:"pid" yaml:"PID"`

	RefreshInterval     time.Duration `json:"refresh_interval" yaml:"RefreshInterval"`
	ViewRefreshInterval time.Duration `json:"view_refresh_interval" yaml:"ViewRefreshInterval"`
	// If more than zero enables line animation. Defaults to zero.
	ViewAnimationInterval time.Duration `json:"view_animation_interval" yaml:"ViewAnimationInterval"`
	// The title of the monitor HTML document.
	ViewTitle string `json:"view_title" yaml:"ViewTitle"`
}

Options holds the optional fields for the Monitor structure.

type Stats

type Stats struct {
	PIDCPU   float64 `json:"pid_cpu" yaml:"PIDCPU"`
	PIDRAM   uint64  `json:"pid_ram" yaml:"PIDRAM"`
	PIDConns int64   `json:"pid_conns" yaml:"PIDConns"`

	OSCPU      float64 `json:"os_cpu" yaml:"OSCPU"`
	OSRAM      uint64  `json:"os_ram" yaml:"OSRAM"`
	OSTotalRAM uint64  `json:"os_total_ram" yaml:"OSTotalRAM"`
	OSLoadAvg  float64 `json:"os_load_avg" yaml:"OSLoadAvg"`
	OSConns    int64   `json:"os_conns" yaml:"OSConns"`
}

Stats holds the process and operating system statistics values.

Note that each statistic has its own expvar metric that you can use to render e.g. through statsd. Available values: * pid_cpu * pid_ram * pid_conns * os_cpu * os_ram * os_total_ram * os_load_avg * os_conns

type StatsHolder

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

StatsHolder holds and refreshes the statistics.

func (*StatsHolder) Err

func (sh *StatsHolder) Err() <-chan error

Err returns a read-only channel which may be filled with errors came from the refresh stats operation.

func (*StatsHolder) GetStats

func (sh *StatsHolder) GetStats() Stats

GetStats returns a copy of the latest stats available.

func (*StatsHolder) Stop

func (sh *StatsHolder) Stop()

Stop terminates the routine retrieves the stats. Note that no other monitor can be initialized after Stop.

type Uint64

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

Uint64 completes the expvar metric interface, holds an uint64 value.

func (*Uint64) Set

func (v *Uint64) Set(value uint64)

Set sets v to value.

func (*Uint64) String

func (v *Uint64) String() string

String returns the text representation of the underline uint64 value.

func (*Uint64) Value

func (v *Uint64) Value() uint64

Value returns the underline uint64 value.

Jump to

Keyboard shortcuts

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