Step 1 – Understand Return Codes

Every Nagios plugin must return with a status code which is called return code. On the basis of return codes, Nagios core service takes decisions and appropriate action for the corresponding host or service. Hosts: Return Code / Host status 0 => UP 1 => DOWN Other Maintains last known state Services: Return code / Service status 0 => OK 1 => WARNING 2 => CRITICAL 3 => UNKNOWN Other CRITICAL : unknown return code

Step 2 – Install NRPE Client

Let’s install the NRPE client on your system using the following commands. The above commands are for Debian based systems. To install NRPE on Redhat based system, visit this tutorial.

Step 3 – Write A Shell Script

Now the time to write a shell script to monitor any service on your system. For this example below script will monitor the disk space uses. Add the below script.

Now set the execute permission on the new script.

Step 4 – Update NRPE Configuration

Now edit NRPE configuration file /etc/nagios/nrpe.cfg and add your command to monitor some disk of your system. You can call check_disk_uses command from Nagios server using check_nrpe command and get the results back.

Step 5 – Test with Check_Nrpe Command

Now, run the below command from your Nagios server, where is the IP of the NRPE client system.