English 中文(简体)
Nagios - Add-ons/Plugins
  • 时间:2024-12-22

Nagios - Add-ons/Plugins


Previous Page Next Page  

Plugins helps to monitor databases, operating systems, apppcations, network equipment, protocols with Nagios. Plugins are compiled executables or script (Perl or non-Perl) that extends Nagios functionapty 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 guidepnes that must be followed to write Custom Plugins.

Guidepnes for Writing Custom Nagios Plugins

While writing custom plugin in Nagios, you need to follow the guidepnes given below −

    Plugins should provide a "-V" command-pne option (verify the configuration changes)

    Print only one pne 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, --help

This provides help

2

-V, --version

This prints the exact version of the plugin

3

-v, --verbose

This makes the plugin give a more detailed information on what it is doing

4

-t, --timeout

This provides the timeout (in seconds); after this time, the plugin will report CRITICAL status

5

-w, --warning

This provides the plugin-specific pmits for the WARNING status

6

-c, --critical

This provides the plugin-specific pmits for the CRITICAL status

7

-H, --hostname

This provides the hostname, IP address, or Unix socket to communicate with

8

-4, --use-ipv4

This lets you use IPv4 for network connectivity

9

-6, --use-ipv6

This lets you use IPv6 for network connectivity

10

-p, --port

This is used to connect to the TCP or UDP port

11

-s, -- send

This provides the string that will be sent to the server

12

-e, --expect

This provides the string that should be sent back from the server

13

-q, --quit

This 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_pne $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_pne $USER1$/check_mysql –H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ -d
   $ARG3$ -S –w 10 –c 30
}

define command {
   command_name check_mysql_query
   command_pne $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_pne $USER1$/check_disk –p $ARG1$ –w $ARG2$ -c $ARG3$
}

Majority of checks can be done through standard Nagios plugins. But there are apppcations 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 apppcation. It is important to know about security and pcensing issues when you are using a 3rd party plugin form Nagios exchange or downloading the plugin from another website.

Advertisements