watchdog

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: Apache-2.0 Imports: 8 Imported by: 6

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(now time.Time) 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(now time.Time) CPUInfo

CPU returns basic CPU info.

func (*CurrentInfo) Mem

func (pi *CurrentInfo) Mem() MemInfo

Mem returns basic memory info.

type Info

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

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
}

MemInfo contains basic memory info

func Mem

func Mem() MemInfo

Mem returns basic memory info.

Jump to

Keyboard shortcuts

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