libnrdpd.config

If writing your own wrapper around librndpd you should likely start here. The primary object to interact with is Config. From there you can use that configuration object to execute checks and submit the results.

class libnrdpd.config.Check(name, command, timeout, frequency)[source]

Bases: object

Class describing an individual check.

Parameters
  • name (str) – Check name. This is the name that is submitted to nagios and must be in sync with the nagios config files. This name is case sensitive.

  • command (list of str) – The command to execute. Each element is evaluated for variable substitution.

  • timeout (float) – How long in seconds to allow a check to run before terminating it and reporting CRITICAL due to timeout.

  • frequency (int) – How often in seconds the check should run.

Raises

error.ConfigError – Raised if timeout or frequency are not able to be treated as float values. .err attribute is set to VALUE_ERROR

property command

Read only. A ‘new’ list of the command to run.

Any template variables have not been filled out yet. See libnrdpd.task.Task for handling of templates.

Type

list of str

property fake

Send fake successful results. This is to allow overriding of templates where the template may be invalid for a host. For instance it allows you to generically check disk space on /var/log but if a host doesn’t have that partition, you can send a fake success in to bypass it.

Type

bool

property frequency

Read only. The check should run every X seconds.

Type

float

property host

Override the host on a per check basis. This allows you to override the hostname for a given check. This doesn’t override the hostname the check is being submitted to, but instead allows you to use the hostname in a template variable with the check.

For instance if you have a web server with a virtual host, you can define the virtual host here to use in the check command line.

Type

str or None

property name

Read only. Name of the check.

This value is the same as is in the nagios config file. It’s case sensitive and can only be set during object creation.

Type

str

property timeout

Read only. Execution time before timeout and going CRITICAL.

Once this time value has been hit, the individual check process is terminated and CRITICAL is reported back to nagios.

Type

float

class libnrdpd.config.Config(cfgfile, confd=None)[source]

Bases: object

Configuration class for nrdpd.

Parameters
  • cfgfile (Union[str, IOBase]) – Path to the nrdpd config.ini file. The value passed in may be either a str or an open file like object derived from io.IOBase.

  • confd (str or None) – Optional path to the conf.d directory. Any files matching the pattern *.ini within that directory will be processed, possibly overriding existing values. The priority on the files is that they are processed in lexical order, with later files having the possibility to override earlier ones.

property cacert

CA certificate file if specified in the config

Type

str or None

property checks

Dictionary describing checks to be run.

Using this property will create a duplicate dictionary that you can modify without affecting the internal data structres within this class. The individual Check objects can be modified within their contstaints.

Type

dict of str, Check

property fqdn

FQDN for inclusion in check varible substitution.

Type

str

property host

Host name presented to nagios.

By default this will be the short name. If you want a fully qualified domain name add it to the config file.

Type

str

property ip

IP address of the machine

Type

util.IP

property servers

Urls for servers to publish NRDP results to.

Type

list of str

property token

Server authentication token.

Type

str