nagios-check-0.3.2: Package for writing monitoring plugins

Safe HaskellNone
LanguageHaskell2010

System.Nagios.Plugin

Contents

Synopsis

Plugin types and control flow

data CheckStatus #

Nagios plugin exit statuses. Ordered by priority - OK < Warning < Critical < Unknown, which correspond to plugin exit statuses of 0, 1, 2, and 3 respectively.

Constructors

OK

Check executed successfully and detected no service problems.

Warning

Nothing's actually broken but this should be followed up.

Critical

Check executed successfully and detected a service failure.

Unknown

Check unable to determine service status.

data CheckResult #

A CheckResult is the exit status of the plugin combined with the plugin's info text. A NagiosPlugin which exits with

CheckResult (Critical "entropy decreasing in closed system")

as its peak-badness CheckResult (and no PerfDatums) will a) exit with status 2 and b) output the text "CRITICAL: entropy decreasing in closed system".

runNagiosPlugin :: NagiosPlugin a -> IO () #

Execute a Nagios check. The program will terminate at the check's completion. A default status will provided if none is given.

runNagiosPlugin' :: NagiosPlugin a -> IO (a, CheckState) #

Execute a Nagios check as with runNagiosPlugin, but return its final state rather than terminating.

addPerfDatum #

Arguments

:: Text

Name of the quantity being measured.

-> PerfValue

Measured value.

-> UOM

Unit of the measured value.

-> Maybe PerfValue

Minimum threshold.

-> Maybe PerfValue

Maximum threshold.

-> Maybe PerfValue

Warning threshold.

-> Maybe PerfValue

Critical threshold.

-> NagiosPlugin () 

Insert a performance metric into the list the check will output.

addPerfData :: ToPerfData a => a -> NagiosPlugin () #

Alternative mechanism for adding perfdata generated from complex types; just implement the toPerfData typeclass.

addBarePerfDatum #

Arguments

:: Text

Name of the quantity being measured.

-> PerfValue

Measured value.

-> UOM

Unit of the measured value.

-> NagiosPlugin () 

Convenience function to insert a perfdatum without thresholds for min, max, warn or crit. Note that unless the range of the metric is actually unbounded, specifying explicit thresholds is considered good practice (it makes life easier for authors of graphing packages).

FIXME: implement thresholds properly and default to negative and positive infinity for min and max here.

addResult :: CheckStatus -> Text -> NagiosPlugin () #

Insert a result. Only the CheckStatus with the most badness will determine the check's exit status.

checkStatus :: CheckResult -> CheckStatus #

Extract the return status from a CheckResult.

checkInfo :: CheckResult -> Text #

Extract the infotext from a CheckResult.

worstResult :: [CheckResult] -> CheckResult #

Returns result with greatest badness, or a default UNKNOWN result if no results have been specified.

finishState :: CheckState -> (CheckStatus, Text) #

Given a check's final state, return the status and output it would exit with.

Nagios performance data

data UOM #

A Nagios "unit of measure". NoUOM translates to an empty string in the check output; it is idiomatic to use it liberally whenever the standard units do not fit.

Constructors

Second 
Millisecond 
Microsecond 
Percent 
Byte 
Kilobyte 
Megabyte 
Gigabyte 
Terabyte 
Counter 
NullUnit 
UnknownUOM

Deprecated: Will be removed in 0.4.0 in favour of failing on parse.

Instances

Eq UOM # 

Methods

(==) :: UOM -> UOM -> Bool #

(/=) :: UOM -> UOM -> Bool #

Show UOM # 

Methods

showsPrec :: Int -> UOM -> ShowS #

show :: UOM -> String #

showList :: [UOM] -> ShowS #

data PerfDatum #

One performance metric. A plugin will output zero or more of these, whereupon Nagios generally passes them off to an external system such as RRDTool or Vaultaire. The thresholds are purely informative (designed to be graphed), and do not affect alerting; likewise with _min and _max.

Constructors

PerfDatum 

Fields

class ToPerfData a where #

Minimal complete definition

toPerfData

Methods

toPerfData :: a -> [PerfDatum] #

barePerfDatum :: Text -> PerfValue -> UOM -> PerfDatum #

Create a PerfDatum from only the required values, using Nothing for all the others.