Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Just installed nagios on a central machine and nrpe on 10 remote linux machines and just started monitoring them. It works great. I can get cpu load, current users, processes, mysql, etc. I can't find a way to monitor memory usage using the core plugins. What am I missing? Do I need an external plugin to do this?

share|improve this question

3 Answers 3

up vote 2 down vote accepted

i suggest you rather monitor swap usage. check out check_swap plugin - it comes by default [at least in debian].

share|improve this answer
This is exactly what I was looking for... thanks... – rmarimon Sep 30 '10 at 19:40

yes, i do thought why they didnt include a plugin which will check the memory, when they have included check_swap and check_disk... ok, something wrong... but the check_memory plugin is available from the

this one works pretty nice.. its a perl script, so not even an installation needed... this is the link from the above plugin page...simple and good documentation...

$ /usr/local/nagios/libexec/ -w 10 -c 5 -f 

WARNING - 9.9% (406520 kB) free!|TOTAL=4113824KB;;;; USED=3707304KB;;;; FREE=406520KB;;;; CACHES=816947KB;;;;

So, the configuration steps are simple:

  • Copy the perl script and write it as "check_memory" (or check_mem or a suitable name for you) in the same directory as where you have the check_disk, check_load etc
    • important to change the execute permissions to that check_memory similar to the other check_plugins(i mean, the execute permission should be given to the nagios user. in our dev environment i gave 755, please verify whether you need 754 or 755)
    • update the remote client nrpe.cfg config file with the command[check_memory]=/usr/lib64/nagios/plugins/check_memory -u -w 8% -c 90%
share|improve this answer
Thanks ErikA for the edit, much appreciated... – Invent Sekar Oct 15 '12 at 1:48

Working with Nagios Server and NRPE Client to automatically restart services on failure January 13, 2015

Executing Remote Commands using Nagios and NRPE

1. Installing NRPE on remote host:

rpm -Uvh yum –enablerepo=epel -y install nrpe nagios-plugins yum –enablerepo=epel -y list nagios-plugins* vim /etc/nagios/nrpe.cfg

service nrpe start chkconfig nrpe on

2. To execute commands on remote nagios client follow below steps:

  1. Open NRPE configuration file and make below mentioned changes:

vim /etc/nagios/nrpe.cfg a. Change from 0 to 1, as shown below: dont_blame_nrpe=1 b. Configuring the Command in NRPE Open your nrpe.cfg file in a text editor and add the following line to define the command in NRPE. Add below mentioned command below the commands section in the nrpe.cfg file: command[runcmd]=sudo service $ARG1$ restart

  1. Granting NRPE Permission to Restart Services Run the following command as root to give NRPE permission to restart services. Make Changes to sudoers file:

vim /etc/sudoers nagios ALL = NOPASSWD: /sbin/service nrpe ALL = NOPASSWD: /sbin/service

Testing runcmd command from the nagios server:

Testing the Commands from Nagios Server Moving over to the Nagios command line, the service restart script will be using Check_Nrpe to send the command to the Service’s Host. Navigate to the Nagios command line and enter the following commands:

/usr/local/nagios/libexec/check_nrpe -H -p 5666 -c runcmd -a httpd

Executing remote commands using Nagios NRPE & Event Handler Configuring the nagios client/remote machine 1. Modify the nrpe.cfg as shown below: Change dont_blame_nrpe=0 to don’t_blame_nrpe=1 2. Add the below custom command in the nrpe.cfg as shown below: command[event-ntp]=/usr/lib64/nagios/plugins/event-ntp $ARG1$ $ARG2$ $ARG3$ 3. Create a event handler, as shown below: vim /usr/lib64/nagios/plugins/event-ntp


case “$1″ in
    echo -e “Running NTP Query” “\n”
    ntpq -p | mailx -s “HOSTNAME – NTP Query”
    case “$2″ in
        case “$3″ in
            echo -e “Running NTP Query & Restarting NTP Service” “\n”
            ntpq -p | mailx -s “HOSTNAME – NTP Query – Restarted NTPD” \
              /usr/bin/sudo /sbin/service ntpd restart
        echo -e “Running NTP Query & Restarting NTP Service” “\n”
        ntpq -p | mailx -s “HOSTNAME – NTP Query – Restarted NTPD” \
        /usr/bin/sudo /sbin/service ntpd restart
exit 0
  1. Give execution permission and change owner and group: chmod +x /usr/lib64/nagios/plugins/event-ntp chown nagios:nagios /usr/lib64/nagios/plugins/event-ntp

  2. The tricky, and probably not the most secure way to do this, is to modify the sudoer’s file to allow the nagios user to execute system commands

visudo add the following: User_Alias NAGIOS = nagios,nagcmd Cmnd_Alias NAGIOSCOMMANDS = /sbin/service Defaults:NAGIOS !requiretty NAGIOS ALL=(ALL) NOPASSWD: NAGIOSCOMMANDS

  1. Once everything is complete restart nrpe service and client configuration is done.

Configuring Event Handler on the Nagios Server First thing you need to do is create an event-ntp command in the commands.cfg file:

  1. Vim /usr/local/nagios/etc/objects/commands.cfg

define command{ command_name event-ntp command_line /usr/local/nagios/libexec/check_nrpe -H $HOSTNAME$ -c event-ntp -a $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$ }

  1. This will be called by the event-handler object in your configuration file. now, modify your service description in wherever you configure your service/host definitions. In my case I have a separate configuration file called linux.cfg.

define service{ use local-service host_name neeraj-test service_description Time Sync Check event_handler event-ntp check_command check_nrpe!check_ntp }

  1. Now restart nagios (service nagios restart), and test the configuration from the server end: /usr/local/nagios/libexec/check_nrpe -H REMOTEHOSTNAME -c event-ntp -a CRITICAL HARD

If all goes well, you should receive an email from your client with an output from ntpq -p, and an ntpd service restart. If you have any problems, not receiving email, or not executing the said script, set the debug level=1 on nrpe.cfg, restart nrpe, execute the above event-ntp test, and check your logs. As you can see, it’s not too difficult to execute event-handler scripts, and saves Administrator’s time when nagios can do the leg-work on system/host critical alerts.

share|improve this answer
Thanks for the detailed explanation. However, I voted your answer down because you copied and dumped a whole blog post here without (1) paying attention to the fact the the formatting is all wrong unless you adjust it, and (2) boiling your answer down to the key points. – Andrew Schulman Jan 16 at 9:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.