Welcome to docs.opsview.com

Differences

This shows you the differences between two versions of the page.

opsview4.6:nagiosplugins [2014/09/09 12:19] (current)
Line 1: Line 1:
 +====== Nagios Plugins ======
 +It should be possible to use any Nagios plugin with Opsview.
 +
 +===== Plugins API =====
 +A plugin runs and returns 3 things:
 +  * a status code (0 = OK, 1 = WARNING, 2 = CRITICAL, 3 = UNKNOWN)
 +  * a single line of output (Opsview 3 allows multiple lines)
 +  * optionally, some performance data
 +
 +In Opsview 3, the plugin output is limited to 16K.
 +
 +**Note**: For distributed slaves, the plugin output that reaches the master is limited to the first line and the first 511 bytes. This includes the performance data
 +
 +**Note**: By default, a plugin cannot take more than 60 seconds to run. This can be changed by adding a value for ''nagios_service_check_timeout'' in opsview.conf, which will override the default behaviour.
 +
 +==== Output ====
 +Plugin output will be stored into the Runtime database as it is printed, so linefeeds will be preserved (no escaping is required). The only exception is the tab character, which is stripped out by Nagios.
 +
 +*Note*: Results from slaves will not include angle brackets (<>)
 +
 +===== Adding Plugins For Master/Slaves =====
 +
 +To add a Nagios Plugin to the Opsview server:
 +
 +  - Switch to 'nagios' user with ''su - nagios''
 +  - Choose a plugin name not already used. Must start "check_" to be picked up
 +  - Check ./<plugin name> -h returns help data
 +  - Copy plugin script or executable to /usr/local/nagios/libexec
 +  - Wait 1 minute
 +
 +This plugin should then be available in the plugin popup menu in the Servicecheck edit pages and pushed to slaves in a distributed environment.  See the [[opsview4.6:servicecheck]] page for details on creating a new service.
 +
 +==== If plugins are not appearing in the service check plugin list ====
 +Check ''/var/log/opsview/opsviewd.log''. There should be an entry which says ''master libexec directory updated; refreshing opsview config and slaves libexec directory as necessary''.
 +
 +You can manually update the database by:
 +  - Switching to nagios user with ''su - nagios''
 +  - Running ''/usr/local/nagios/bin/populate_db.pl plugins''
 +
 +==== If plugins are not automatically sent to slaves ====
 +You can manually push plugins out with:
 +
 +  - Switch to 'nagios' user with ''su - nagios''
 +  - Run ''/usr/local/nagios/bin/send2slaves -p''
 +
 +
 +==== Deleting a plugin from the list ====
 +If you have a plugin that you want to delete from the list, run this in mysql:
 +<code>
 +mysql> delete from plugins where name = '<plugin_name>';
 +</code>
 +
 +This may fail if you have any service checks that still reference this plugin name.
 +===== Adding Plugins For Use On Agents Only =====
 +
 +See the [[opsview4.6:servicecheck|service check]] page for details on creating a new service.
 +
 +===== Performance data and graphing =====
 +
 +If the plugin returns valid performance data it will automatically be displayed as a graph in Opsview.
 +
 +{{opsview4.6:graph.png|}}
 +
 +The graph icon only appears when performance data is detected for service check during reload cycle. This means the graphing icon only appears at the //second reload// for a new service (after results have been received at least once).
 +
 +**Note**: The service must run at least once an hour for the graph line to be produced. The RRDs are created with a default timeout of one hour, so if there are no results within an hour, the graph line will not be created.
 +
 +===== Environment Variables =====
 +Nagios Core 4 is used for the monitoring engine. When executing plugins, only environment variables specifically defined will be included when executing the plugin. If you use any environment variables in any custom plugins, you will need to set information within the plugin. For example, add this near the beginning of your plugin:
 +<code>
 +### BEGIN OPSVIEW INFO
 +# Macros: HOSTNAME,SERVICEDESC
 +### END OPSVIEW INFO
 +</code>
 +
 +This will tell Opsview to add the environment variables for NAGIOS_HOSTNAME and NAGIOS_SERVICEDESC to the plugin.
 +
 +The plugins are scanned by the populate_db.pl script, which is run when a change is detected in the libexec directory, and during an upgrade.
 +
 +===== Specific additional plugin information =====
 +
 +==== check_logfiles ====
 +
 +check_logfiles can be installed with the following configuration options:
 +
 +  ./configure --with-nagios-user=nagios \
 +    --with-nagios-group=nagios \
 +    --with-seekfiles-dir=/usr/local/nagios/tmp \
 +    --with-protocols-dir=/usr/local/nagios/tmp
 +
 +Normally the script stores its seekfiles in /tmp, but that directory can be emptied by the OS, so a better choice is /usr/local/nagios/tmp.  The default install location (--prefix) is correct (/usr/local/nagios).
Navigation
Print/export
Toolbox