5.4. external

The external module performs checks via external processes like more traditional monitoring systems. While this approach is far less efficient and does not scale well on a single system, it provides easier transition from existing monitoring systems. Checks should exit normally with an exit status of 0 for success, 1 or 2 for failure and 3 for unknown. Exiting with a status of 3 is highly discouraged. The standard output is provided as the status of the check.

loader

C

image

external.so

5.4.1. Module Configuration

user
required

optional

allowed

.+

The user under which the external checks should be executed.

group
required

optional

allowed

.+

The group under which the external checks should be executed.

path
required

optional

default

/

allowed

.+

The path under which all external commands to be executed will be located. Commands outside of this path will not be executed.

nagios_regex
required

optional

default

\'?(?<key>[^'=\s]+)\'?=(?<value>-?[0-9]+(\.[0-9]+)?)(?<uom>[a-zA-Z%]+)?(?=[;,\s])

allowed

.+

The default regular expression with which to parse Nagios data. Named values are "key", "value", and "uom" (unit of measurement)

5.4.2. Check Configuration

command
required

required

allowed

.+

The path to the command to be executed. This is the first argument to the execve system call.

arg0
required

optional

allowed

.+

The program name. If not specified, it is derived from the command argument. Normal interpolation rules apply.

arg\d+
required

optional

allowed

.+

The arguments to the program. The external module will start with arg1 and increment collecting arguments until argN is not found. Normal interpolation rules apply.

env_\S+
required

optional

allowed

.+

These parameters allow the setting of environment variables for the command execution. The text following env_ is the key and the parameter value is the value of the environment variable to be set via execve.

output_extract
required

optional

allowed

.+

This is a regular expression that is globally applied to the stdout of the command. Each match is turned into a metric. It is a requirement to used named capturing in the regular expression where "key" is the named match of the metric name and "value" is the named match for the matric value. A sample for extracting performance data from Nagios commands would be: (?<key>\S+)=(?<value>[^;\s]+)(?=[;\s]). "NAGIOS" may also be specified as a value, which will configure the external check to do Nagios parsing based on the nagios_regex module configuration parameter.

Example 5.6. Checking a service via the /path/to/check_foo command.

The hypothetical check_foo command takes a target host with the -H parameter, runs a check and returns its health via exit code and stdout. We set the environment variable QUUX to the value BAZ. The check is against host 10.10.2.2.

      <noit>
        <modules>
          <module image="external" name="external"/>
        </modules>
        <checks>
          <check uuid="1e8edc38-0d88-11de-93ee-af2195eab5d5"
                 module="external" name="foo" target="10.10.2.2">
            <config>
              <command>/path/to/check_foo</command>
              <arg1>-H</arg1>
              <arg2>%[target]</arg2>
              <env_QUUX>BAZ</env_QUUX>
            </config>
          </check>
        </checks>
      </noit>