Skip to main content

NagiosCheckHelper

This library helps with the boilerplate nagios check formating, status information, and basic evaluations when writing a Python nagios/icinga check

Installation

It's on pypi, so it's as easy as installing via pip

pip3 install NagiosCheckHelper

NagErrors Object

An object to hold the Errors that have occured.

Generally you can call it with obj.addCritical(error text) or obj.addWarning(error text) to accumulate your errors

Then call obj.printStatus() to print the formatted Errors

Then call obj.doExit() to exit your program with the proper result code.

Usage

Object Creation

No parameters, so just do a:

from NagiosCheckHelper import NagErrors
nerr = NagErrors()

Logging Errors

There are 4 functions for logging errors:

  • addRecord(eType,etext)

  • addCritical(etext)

  • addWarning(etext)

  • addUnknown(etext)

  • eType would be the type of error. One of: critical, warning, or unknown\

  • etext is the Error message (without any Error or Warning prefix, that's automatically added)

example:

from NagiosCheckHelper import NagErrors
nerr = NagErrors()
nerr.addRecord("critical", "The printer is on fire.")
nerr.addWarning("The printer is out of paper.")
nerr.addUnknown("The printer grew legs and walked out the door.")

Outputting status

There are 2 main functions for outputting status:

  • printStatus() - print out the formatted status lines
  • doExit() - Exit the program with the proper status code.

NagErrors "full" example:

A quick example that sets a couple messages and exits

from NagiosCheckHelper import NagErrors
nerr = NagErrors()
nerr.addCritical("This is a Critical Event")
nerr.addWarning("This is a Warning Event")
nerr.printStatus()
nerr.doExit()

NagEval Object

An object with common subroutines to evaluate data and cause error events based on the comparisons.

Be sure to initite it with an NagErrors Object.

Usage

Object Creation

Takes a NagErrors object to track errors, so just do a:

from NagiosCheckHelper import NagErrors, NagEval
nerr = NagErrors()
neval = NagEval(nerr)

Evaluate value against Enumerated Values

Evaluate a value based on lists of enumerated values

evalEnum(value, defaultStatus="UNKNOWN", okValues=[], warningValues=[], criticalValues=[], unknownValues=[], prefixText="", postfixText= "")

Evaluate List of values against Enumerated Values

Evaluate a list of values based on lists of enumerated values

values = ['value1', 'value2', 'value3']
evalListEnum(values, emptyStatus="UNKNOWN", unknownValueStatus="UNKNOWN", okValues=[], warningValues=[], criticalValues=[], unknownValues=[], prefixText="", postfixText= "")

Evaluate Numbers

There are 2 evaluators that will handle number ranges (asending and decending):

evalNumberAsc(value, warningAbove=None, criticalAbove=None, prefixText="", postfixText="", numberUnits="")
evalNumberDesc(value, warningBelow=None, criticalBelow=None, prefixText="", postfixText= "", numberUnits="")

Evaluate List of Numbers

There are 2 evaluators that will handle lists of numbers based on number ranges (asending and decending):

values = [5, 90, 55, 200001]
evalListNumberAsc(values, emptyStatus="UNKNOWN", warningAbove=None, criticalAbove=None, prefixText="", postfixText="", numberUnits="")
evalListNumberDesc(values, emptyStatus="UNKNOWN", warningBelow=None, criticalBelow=None, prefixText="", postfixText= "", numberUnits="")

NagEval "full" example:

A quick example that tests a value, outputs the results and exits with the proper code

from NagiosCheckHelper import NagErrors, NagEval
nerr = NagErrors()
neval = NagEval(nerr)
neval.evalNumberAsc(95, warningAbove=80, criticalAbove=90, numberUnits="%")
nerr.printStatus()
nerr.doExit()

Full Examples

These are full examples/checks that use this library and click to handle most of the boilerplate and script is mostly just defining the options and running the actual check.

Metadata

Release files for NagiosCheckHelper 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for NagiosCheckHelper 0.1.5
File Size Uploaded Provenance
NagiosCheckHelper-0.1.5.tar.gz 19.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for NagiosCheckHelper 0.1.5
File Interpreter ABI Platform
NagiosCheckHelper-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 38.8 kB

Release files / NagiosCheckHelper-0.1.5.tar.gz

Download URL NagiosCheckHelper-0.1.5.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
221f38dceec371f32a007373d1e23ce0d14d47d90c0ee1c2299290361d8206ca
BLAKE2b-256 checksum
How to use checksums
f706285761aa51bdd12eca3d684076a7137007d95bc91e79636c2ef585e6d919
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.10

Release files / NagiosCheckHelper-0.1.5-py3-none-any.whl

Download URL NagiosCheckHelper-0.1.5-py3-none-any.whl
Size 19.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c863f381323607969061dc6c11db2d9a6ca58f27b14358980103dc2b0701b1ce
BLAKE2b-256 checksum
How to use checksums
b0bf20386f7784b2d5f77690339fa817517a9a32d1dc66deee6b1dea5aa811a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.10

Security for NagiosCheckHelper 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page