response - Response Class

Contains the class which represents a response for Icinga. This encapsulates the response format that Icinga expects.

class pycinga.response.Response([status=None[, message=None]])[source]

Icinga responses are expected to be in a very specific format, and this class allows these responses to easily be built up and extracted in the proper format.

This class makes it easy to set the status, message, and performance data for a response.

Parameters:
  • status (optional): A Status object representing the status of the response.
  • message (optional): An information message to include with the output.
set_perf_data(label, value, uom=None, warn=None, crit=None, minval=None, maxval=None)[source]

Adds performance data to the response. Performance data is shown in the Icinga GUI and can be used by 3rd party programs to build graphs or other informational output. There are many options to this method. They are the same as the initialization parameters for a PerfData object.

See also

PerfData

exit()[source]

This prints out the response to stdout and exits with the proper exit code.

__str__()[source]

The string format of this object is the valid Icinga output format. The response format is expected to be the following:

status: information|performance data

An example of realistic output:

OK: 27 users logged in|users=27;0:40;0:60;0;