watchdog

package
v0.0.0-...-e57142c Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2019 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogOnPanic

func LogOnPanic()

LogOnPanic catches panics and logs them on the fly. It also flushes the log file, ensuring the message appears. Then it propagates the panic so that the program flow remains unchanged.

Types

type CPUInfo

type CPUInfo struct {
	// UserAvg is the average of the user CPU usage since last time
	// it was polled. 0 means "not used at all" and 1 means "1 CPU was
	// totally full for that period". So it might be greater than 1 if
	// the process is monopolizing several cores.
	UserAvg float64
}

CPUInfo contains basic CPU info

func CPU

func CPU() CPUInfo

CPU returns basic CPU info.

type CurrentInfo

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

CurrentInfo is used to query CPU and Mem info, it keeps data from the previous calls to calculate averages. It is not thread safe.

func NewCurrentInfo

func NewCurrentInfo() (*CurrentInfo, error)

NewCurrentInfo creates a new CurrentInfo referring to the current running program.

func (*CurrentInfo) CPU

func (pi *CurrentInfo) CPU() CPUInfo

CPU returns basic CPU info.

func (*CurrentInfo) Mem

func (pi *CurrentInfo) Mem() MemInfo

Mem returns basic memory info.

func (*CurrentInfo) Net

func (pi *CurrentInfo) Net() NetInfo

Net returns basic network info.

type Info

type Info struct {
	// CPU contains basic CPU info
	CPU CPUInfo
	// Mem contains basic Mem info
	Mem MemInfo
	// Net contains basic Net info
	Net NetInfo
}

Info contains all the watchdog infos, to be published by expvar

type MemInfo

type MemInfo struct {
	// Alloc is the number of bytes allocated and not yet freed
	// as described in runtime.MemStats.Alloc
	Alloc uint64
	// AllocPerSec is the average number of bytes allocated, per second,
	// since last time this function was called.
	AllocPerSec float64
}

MemInfo contains basic memory info

func Mem

func Mem() MemInfo

Mem returns basic memory info.

type NetInfo

type NetInfo struct {
	// Connections is the number of connections opened by this process.
	Connections int32
}

NetInfo contains basic networking info

func Net

func Net() NetInfo

Net returns basic network info.

Jump to

Keyboard shortcuts

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