This article was written for version 6.2 of Monitor, it could work on both lower and higher version if nothing else is stated.
Articles in the Community-Space are not supported by op5 Support.
Table of Contents
This article describes how to use the query handler to send passive results to op5 Monitor. These types of passive results can be used for scrips that is not scheduled by op5 Monitor to perform checks.
To send a passive result to op5 Monitor we use the command 'mon qh query command run' or writing directly to the socket. Both methods are described in this how-to. Using the mon-command is a debugging tool. For implementations where passive results are sent to the monitor server using the socket is the preferred way.
To send a passive result for a service using the query handler the command looks like this:
- $(date +%s) generates a timestamp. Note that the space between the timestamp and the name of the command is significant. Leaving it out will result in an error
- PROCESS_SERVICE_CHECK_RESULT is the name of the command
- 'monitor' is the host for which to submit a passive check
- 'some_service' is the name of the service on the host.
- '0' is the check result
- 'output' is the plugin output
- The \0 after output when using the socket must be there.
In this example we will send a result to the service 'Disk usage Z:' on host 'File_server'. The check result is 'OK' with "Disk usage Z: 25Gb" as output and "'Z:' =20.00Gb;30.00;40.00" as performance output1 for building graphs.
The command output if everything is ok is
This result will look like this in op5 Monitor:
It is possible to send in passive results with multiline support. To do this we need to change the escape_html_tags=1 to escape_html_tags=0 in the file /opt/monitor/etc/cgi.cfg
To send a multiline result to op5 Monitor use the <br> tag in the output. Example:
- The performance output for the service check uses semicolon as a separator for separating results with warning and critical threshold , same as the query handler uses to separate it's input values. This is not an issue due to that the query handler stops looking at semicolons after the output starts.
It is also possible to do this for a host check then we replace PROCESS_SERVICE_CHECK_RESULT with PROCESS_HOST_CHECK_RESULT and we do not need to specify a service.