Skip to content

maduck/libnagios

Repository files navigation

Travis Coveralls Codacy grade Maintainability

Nagios plugin helper library. It is now easy to write Nagios plugins in python without bothering with details.

An example:

import sys
from libnagios import Nagios

nagios_check = Nagios('Asset')

asset = CheckVariable('asset', float, 'EUR')
asset.ok_condition = lambda x: x > 10
asset.warn_condition = lambda x: 5 < x <= 10
asset.crit_condition = lambda x: x <= 5
self.inst.add_check_variable(asset)

nagios_check.add_check_variable(asset)

nagios_check.add_check_result('asset', 12)
code, output = nagios_check.generate_output()

print(output)
sys.exit(code)

this should print 'Asset OK - 12.00 EUR | asset=12.00', and exit with code '0'.