Nagios Quick Client Setup

Setup Overview

Nagios installation is documented in Monitoring Resources with Nagios

For the ease of updates, Nagios central server is installed in /usr/local/nagios-x.x.x folder with a symlink /usr/local/nagios pointing to it.

Plug-ins are put in /usr/local/nagios/libexec. Their names have the following format: check_<service>; for example, check_nfs.

Scripts for passive checks are located in /usr/local/nagios/bin and have their names backwards. For example, if the plug-in is called check_nfs, then the script is called nfs_check.

Passive checks are done via root’s crontab. The all-included script is located in /usr/local/nagios/bin and called check.sh. It only requires an addition of a service name into the “for service in” loop; in the above example with nfs_check, just add “nfs” there.

Active checks that are done on the distributed server tech, located in remote are, are done in a similar way, except that the results are submitted passively to the central server sparc5, located in the central office. For the central server to accept these passive results, the host(s) and service(s) should be defined on the central server. They may and probably should use “remote-host” and “remote-service” templates respectively or their derivatives.

Here are the quick steps to setup a client.

Active checks

Active checks performed by the central server

1. Download/compile/install/write your own/use existing plug-in in /usr/local/nagios/libexec called check_<service>, where <service> is the service that we want to monitor.

2. Add a host and service definitions into the /usr/local/nagios/etc/servers/<server-name.cfg> file, where server name is the name of the machine, that we want to monitor (i.e. a client).

3. If necessary, add check_command definition in /usr/local/nagios/etc/objects/commands.cfg file.

4. Optionally include this(es) host(s) and/or service(s) into host and/or service groups defined in /usr/local/nagios/etc/servers/host-groups.cfg and /usr/local/nagios/etc/servers/service-groups.cfg files.

5. Optionally define contact and contact groups for your host(s) service(s) definitions - these are the people who should be notified when the host or service is down, for example.

6. Check your configuration running the following command

# cd /usr/local/nagios
# bin/nagios -v etc/nagios

7. If everything looks ok in step 6, then reload the nagios server

# /etc/init.d/nagios reload

Active checks performed by the distributed server and submitted passively to the central server

1. Download/compile/install/write your own/use existing plug-in in /usr/local/nagios/libexec called check_<service>, where <service> is the service that we want to monitor.

2. Add a host and service definitions into the /usr/local/nagios/etc/servers/<server-name.cfg> file, where server name is the name of the machine, that we want to monitor (i.e. a client).

3. If necessary, add check_command definition in /usr/local/nagios/etc/objects/commands.cfg file.

4. Check your configuration running the following command

# cd /usr/local/nagios
# bin/nagios -v etc/nagios

5. If everything looks ok in step 4, then reload the nagios server

# /etc/init.d/nagios reload

6. On the central server sparc5 add host and service definitions into the /usr/local/nagios/etc/servers/<server-name.cfg> file, where server name is the name of the machine, that we want to monitor (i.e. a client). Use remote-host and remote-service templates or derive your own from them.

Passive service checks

Passive checks are run on a client and submitted to the central server directly with nsca add-on (its client part)

1. Download/Compile/Install/ nsca add-on or copy pre-compiled one from the existing clients. You only need two files: send_nsca and send_nsca.cfg. Put the first one in /usr/local/nagios/bin and the second one in /usr/local/nagios/etc. nsca_send.cfg should look like this:

# cat /usr/local/nagios/etc/send_nsca.cfg
password=*******
encryption_method=3

The above will ensure that information is encrypted between the client and the central server with 3DES.

2. Download/compile/install/write your own/use existing plug-in in /usr/local/nagios/libexec called check_<service>, where <service> is the service that we want to monitor.

3. Write/copy/modify a shell script that will run the check_<service> plug-in. Call it backwards, <service>_check and put it in /usr/local/nagios/bin/ folder.

4. Use existing or write your own scipt to check all your services at once. It looks like this:

# vi /usr/local/nagios/bin/check.sh

#!/usr/bin/bash

SERVICES="kadmin kdc nic svm ypbind ypserv"
CHECK_PATH=/usr/local/nagios/bin

for service in ${SERVICES}; do
 ${CHECK_PATH}/${service}_check
done;

5. Setup a root’s cron job using crontab command; for example,

# crontab -e
0,15,30,45 * * * * /usr/local/nagios/bin/check.sh

6. On the central server sparc5 add host and service definitions into the /usr/local/nagios/etc/servers/<server-name.cfg> file, where server name is the name of the machine, that we want to monitor (i.e. a client). Use remote-host and remote-service templates or derive your own from them.

7. Optionally include this(es) host(s) and/or service(s) into host and/or service groups defined in /usr/local/nagios/etc/servers/host-groups.cfg and /usr/local/nagios/etc/servers/service-groups.cfg files.

8. Optionally define contact and contact groups for your host(s) service(s) definitions - these are the people who should be notified when the host or service is down, for example.

9. Check your configuration running the following command

# cd /usr/local/nagios
# bin/nagios -v etc/nagios

10. If everything looks ok in step 9, then reload the central nagios server

# /etc/init.d/nagios reload