Plugins help to monitor databases, operating systems, applications, network equipment, protocols with Nagios. Plugins are compiled executables or script (Perl or non-Perl) that extends Nagios functionality to monitor servers and hosts. Nagios will execute a Plugin to check the status of a service or host. Nagios can be compiled with support for an embedded Perl interpreter to execute Perl plugins. Without it, Nagios executes Perl and non-Perl plugins by forking and executing the plugins as an external command.
Types of Nagios Plugins
Nagios has the following plugins available in it β
Official Nagios Plugins β There are 50 official Nagios Plugins. Official Nagios plugins are developed and maintained by the official Nagios Plugins Team.
Community Plugins β There are over 3,000 third party Nagios plugins that have been developed by hundreds of Nagios community members.
Custom Plugins β You can also write your own Custom Plugins. There are certain guidelines that must be followed to write Custom Plugins.
Guidelines for Writing Custom Nagios Plugins
While writing custom plugin in Nagios, you need to follow the guidelines given below β
- Plugins should provide a “-V” command-line option (verify the configuration changes)
- Print only one line of text
- Print the diagnostic and only part of the help message
- Network plugins use DEFAULT_SOCKET_TIMEOUT to timeout
- “-v”, or “–verboseβ is related to verbosity level
- “-t” or “–timeout” (plugin timeout);
- “-w” or “–warning” (warning threshold);
- “-c” or “–critical” (critical threshold);
- “-H” or “–hostname” (name of the host to check)
Multiple Nagios plugin run and perform checks at the same time, for all of them to run smoothly together, Nagios plugin follow a status code. The table given below tells the exit code status and its description β
Exit Code | Status | Description |
---|---|---|
0 | OK | Working fine |
1 | WARNING | Working fine, but needs attention |
2 | CRITICAL | Not working Correctly |
3 | UNKNOWN | When the plugin is unable to determine the status of the host/service |
Nagios plugins use options for their configuration. The following are few important parameters accepted by Nagios plugin β
Sr.No | Option & Description |
---|---|
1 | -h, –helpThis provides help |
2 | -V, –versionThis prints the exact version of the plugin |
3 | -v, –verboseThis makes the plugin give a more detailed information on what it is doing |
4 | -t, –timeoutThis provides the timeout (in seconds); after this time, the plugin will report CRITICAL status |
5 | -w, –warningThis provides the plugin-specific limits for the WARNING status |
6 | -c, –criticalThis provides the plugin-specific limits for the CRITICAL status |
7 | -H, –hostnameThis provides the hostname, IP address, or Unix socket to communicate with |
8 | -4, –use-ipv4This lets you use IPv4 for network connectivity |
9 | -6, –use-ipv6This lets you use IPv6 for network connectivity |
10 | -p, –portThis is used to connect to the TCP or UDP port |
11 | -s, — sendThis provides the string that will be sent to the server |
12 | -e, –expectThis provides the string that should be sent back from the server |
13 | -q, –quitThis provides the string to send to the server to close the connection |
Nagios plugin package has lot of checks available for hosts and services to monitor the infrastructure. Let us try out Nagios plugins to perform few checks.
SMTP is a protocol that is used for sending emails. Nagios standard plugins have commands for perform checks for SMTP. The command definition for SMTP β
define command { command_name check_smtp command_line $USER2$/check_smtp -H $HOSTADDRESS$ }
Let us use Nagios plugin to monitor MySQL. Nagios offers 2 plugins to monitor MySQL. The first plugin checks if mysql connection is working or not, and the second plugin is used to calculate the time taken to run a SQL query.
The commands definitions for both are as follows β
define command { command_name check_mysql command_line $USER1$/check_mysql βH $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -d $ARG3$ -S βw 10 βc 30 } define command { command_name check_mysql_query command_line $USER1$/check_mysql_query βH $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -d $ARG3$ -q $ARG4$ βw $ARG5$ -c $ARG6$ }
Note β Username, password, and database name are required as arguments in both the commands.
Nagios offers plugin to check the disk space mounted on all the partitions. The command definition is as follows
define command { command_name check_partition command_line $USER1$/check_disk βp $ARG1$ βw $ARG2$ -c $ARG3$ }
Majority of checks can be done through standard Nagios plugins. But there are applications which require special checks to monitor them, in which case you can use 3rd party Nagios plugins which will provide more sophisticated checks on the application. It is important to know about security and licensing issues when you are using a 3rd party plugin form Nagios exchange or downloading the plugin from another website.
Next Topic:-Click Here
Pingback: Nagios - Ports and Protocols - Adglob Infosystem Pvt Ltd