How the Global-Plugin-Execution service template works
Preparation and prerequisites of the client program
The idea behind the Global-Plugin-Execution service template is to allow the running of a program/script customised by the customer and transferred to the ServiceNav Box.
To function correctly, this program must meet the following conditions:
- Encoding type : LATIN
- The program must produce a return code according to the table below
|Value||Interpreted status in ServiceNav|
- Program output must be a single line
- The output may contain performance data, in which case the output must be of the form :
text displayed in the ServiceNav detail field| 'metric-name'=value [unit]; [warning threshold]; [critical threshold]; [min value]; [max value].
- list of metric name / value names separated by spaces
- the metric name can contain any character except the equal sign (=) or the quote sign (')
- single quotation marks for the metric name are optional, but MANDATORY if name contains spaces
- the name of the metric is flexible insofar that it:, must be less than 19 characters long, unique in the output line and must not contain the quote sign (')
- [warning threshold]; [critical threshold]; [min value]; [max value] can be zero (e.g. if the threshold is not defined or if min and max do not apply). Blank separating semicolons can be omitted. Min and max are not required if the unit is %
- value, warning threshold, critical threshold, min and max must use numbers [0-9] and must all use the same units for a given metric.
- Unit is a string of one or more characters. The following characters are prohibited: numbers, semicolons, single or double quotation marks.
- A few examples:
- no units specified - Indicates a number (int or float) of entities (e.g., number of users or processes, load averages)
- s - seconds (also min, ms, ...)
- % - percentage
- B - bytes (also KB, MB, TB)
- A few examples:
If your program meets the above requirements, you can run it on a ServiceNav Box.
If you have more than one ServiceNav Box, the script should be deployed across all your ServiceNav Boxes.
Copy your file into the ServiceNav Box directory:
Assign execution and ownership permissions using the command lines:
chown nagios:nagios /usr/local/nagios/libexec/custom_plugin/
chmod 755 /usr/local/nagios/libexec/custom_plugin/
Go to the ServiceNav interface and add a service:
Global-Plugin-ExecutionThe Plugin file to execute must contain the name of your file (previously placed in the directory as indicated above)
The Plugin arguments contains all the arguments of the plugin with the following caveats:
- Arguments are passed in the form: -H 'value' or -host 'value' (example -c 'public' or -url 'https://myurl.com' )
- To surround the values of the arguments, use the double-quote sign (" ) or the single-quote sign (').
- If the value of an argument surrounded by double quotes contains a double quote it is necessary to escape it with " (backslash double quote)
- If the value of an argument surrounded by single quotes contains a single quote it is necessary to escape it with ' ' (quote double quote quote double quote)
Example : -h $HOSTADDRESS$ –URI ‘mylogin.php’ –pwd ‘eyi "kim58’ –text ‘Rue de l' "‘ "‘alma’
Example: -h $HOSTADDRESS$ -URI 'mylogin.php' -pwd " eyi "kim58 " -text " Rue de l'alma "
The following variables can be used:
- $_SERVICEHOSTALIAS$ returns the name of the host the service is linked with as displayed in ServiceNav
- $HOSTADDRESS$ returns the IP address of the host the service is linked with as displayed in ServiceNav
- $_SERVICEDISPLAYNAME$ returns the service name as specified in ServiceNav
- $_SERVICEIDSERVICE$ returns the unique ServiceNav service ID
- $_HOSTCOMPANYNAME$ returns the name of the company the host is associated with
- $_HOSTHOST_CATEGORY_NAME$ returns the name of the ServiceNav host category the host associated with the service is assigned to
It is not possible to use inherited account variables specified at company and/or host level of ServiceNav. If the program requires any credential information, this should be specified in the field Plugin arguments.
This information is stored in encrypted form in the ServiceNav database but remains visible to anyone who has access to the service configuration page.