Documentation ¶
Index ¶
- Constants
- Variables
- func AddAlarm(a *Alarm) error
- type Alarm
- func (j *Alarm) Above(v float64) *Alarm
- func (j *Alarm) AboveEqual(v float64) *Alarm
- func (j *Alarm) Below(v float64) *Alarm
- func (j *Alarm) BelowEqual(v float64) *Alarm
- func (j *Alarm) Equal(v float64) *Alarm
- func (j *Alarm) Free() *Alarm
- func (j *Alarm) Percent() *Alarm
- func (j *Alarm) Run(f func()) *Alarm
- func (j *Alarm) RunningTime() *Alarm
- func (j *Alarm) SetMetricsManager(m sigarMetrics)
- func (j *Alarm) Status(s state) *Alarm
- func (j *Alarm) Used() *Alarm
Constants ¶
const ( Sleeping state = iota + 1 Running Stopped Zombie Idle Unknown )
Linux process states to be used with status alarms
const ( OneMinPeriod period = iota + 1 FiveMinPeriod FifteenMinPeriod )
Load average can be calculated for the last one minute, five minutes and fifteen minutes respectively. Load average is an indication of whether the system resources (mainly the CPU) are adequately available for the processes (system load) that are running, runnable or in uninterruptible sleep states during the previous n minutes.
Variables ¶
var ( ErrAlarmTypeNotDefined = errors.New("Bad chain. Alarm type not defined") ErrComparisonNotDefined = errors.New("Bad chain. Alarm comparison not defined") ErrExpectedNumWhenPercentage = errors.New("Bad chain. A number is needed for applying a percentage") ErrIncorrectTypeForFree = errors.New("Alarm type not set or trying to use Free with something different than memory or swap memory") ErrIncorrectTypeForUsed = errors.New("Alarm type not set or trying to use Free with something different than memory, swap memory or memory used by a proc") ErrIncorrectTypeForTime = errors.New("Alarm type not set or trying to use RunningTime with something different than uptime or uptime by a proc") ErrIncorrectTypeForStatus = errors.New("Alarm type not set or trying to use Status with something different than SysteProcAlarm") ErrMultipleComparisonDefined = errors.New("Alarm comparison already defined") ErrIncorrectTypeForAbove = errors.New("Alarm type not set or trying to use Above with a status metric") ErrIncorrectTypeForBelow = errors.New("Alarm type not set or trying to use Below with a status metric") ErrIncorrectTypeForPercentage = errors.New("Couldn't apply percentage to uptime/status Alarms") ErrIncorrectValuesWithPercentage = errors.New("Couldn't apply percentage") ErrInexistentPid = errors.New("Pid does not exist") ErrIncorrectTypeForComparison = errors.New("Alarm type not set or trying to use an incorrect comparison with this type of Alarm") ErrIncorrectTypeForMetric = errors.New("Alarm type not set or trying to use an incorrect metric with this type of Alarm") )
Error codes returned by failures when trying to create the alert chain
var Alarms = make([]*Alarm, 0)
alarms pool
var Duration = 5
check interval set to 5 seconds as default
Functions ¶
Types ¶
type Alarm ¶
type Alarm struct { Err error // contains filtered or unexported fields }
Alarm defines a running alarm
func SystemLoad ¶
func SystemLoad(p period) *Alarm
SystemLoad creates an alarm based on load metric P is the period needed for calculating the load, and it could be OneMinPeriod, FiveMinPeriod or FifteenMinPeriod
func SystemMemory ¶
func SystemMemory() *Alarm
SystemMemory creates an alarm based on memory metrics
func SystemProc ¶
SystemProc creates an alarm based on a process specified by PID
func (*Alarm) AboveEqual ¶
AboveEqual compares if the specified alarm is greater or equal than the number set
func (*Alarm) BelowEqual ¶
BelowEqual compares if the specified alarm is lower or equal than the number set
func (*Alarm) Free ¶
Free allows to specify that the created alarm will use the free memory as main metric
func (*Alarm) Run ¶
Run allows a func to be specified. This callback will be executed when the alarm is fired
func (*Alarm) RunningTime ¶
RunningTime gets the time a process has been running
func (*Alarm) SetMetricsManager ¶
func (j *Alarm) SetMetricsManager(m sigarMetrics)
SetMetricsManager allows to set a specific sigar manager