nrpe

Shared utility functions to use in nrpe scripts

accre.nrpe.nrpe_precheck(fname, timeout=600, reboot_grace=7200)[source]

Check that the given nrpe precheck file exists and has been updated within the specified timeout, or exit critical (2). If ok, return file contents.

If the file does not exist and the machine has recently rebooted, an ok will be given instead of a critical status.

A precheck file is a small output file generated by some command that needs to be run as root which has output to be inspected by an NRPE check. This is done as a cronjob on a node so that the NRPE user does not need sudo access to run diagnostics. Running checks this way also makes it easy to test the check itself against expected failures.

Parameters:
  • fname (str) – Absolute path to the precheck file

  • timeout (int) – Maximum number of seconds that may have passed since the precheck file was last updated

  • reboot_grace (int) – Maximum number of seconds after reboot to allow a grace period where the file may not exist

Returns:

Precheck file contents

Return type:

str

accre.nrpe.parse_mmlsdisk(raw)[source]

Return mmlsdisk info for each device

Parameters:

raw (str) – Raw input text presumably from an mmlsdisk command run with the -Y option

Returns:

List of device data dictionaries

Return type:

list(dict(str, str))

accre.nrpe.parse_multipath_info(raw)[source]

Return information for each multipath device from output presumably returned by “multipath -ll” with their name (i.e. “dm-X”), their serial number, and number of links in the “active ready running” state.

Parameters:

raw (str) – Raw input text presumably from a multipath -ll command

Returns:

List of device data dictionaries

Return type:

list(dict(str, str))