

Vim /usr/local/nagios/etc/objects/commands.cfgĬommand_line /usr/local/nagios/libexec/check_nrpe -H $HOSTNAME$ -c event-ntp -a $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$.Once everything is complete restart nrpe service and client configuration is done.Ĭonfiguring Event Handler on the Nagios Serverįirst thing you need to do is create an event-ntp command in the commands.cfg file:.NAGIOS ALL=(ALL) NOPASSWD: NAGIOSCOMMANDS 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Ĭmnd_Alias NAGIOSCOMMANDS = /sbin/service Give execution permission and change owner and group:Ĭhmod +x /usr/lib64/nagios/plugins/event-ntpĬhown nagios:nagios /usr/lib64/nagios/plugins/event-ntp

Ntpq -p | mailx -s “HOSTNAME – NTP Query – Restarted NTPD” & Ntpq -p | mailx -s “HOSTNAME – NTP Query” “$2″ inĮcho -e “Running NTP Query & Restarting NTP Service” “\n” Vim /usr/lib64/nagios/plugins/event-ntp #!/bin/bash

Add the below custom command in the nrpe.cfg as shown below:Ĭommand=/usr/lib64/nagios/plugins/event-ntp $ARG1$ $ARG2$ $ARG3$ģ. usr/local/nagios/libexec/check_nrpe -H 192.168.5.180 -p 5666 -c runcmd -a httpdĮxecuting remote commands using Nagios NRPE & Event HandlerĬonfiguring the nagios client/remote machineĬhange dont_blame_nrpe=0 to don’t_blame_nrpe=1Ģ. Navigate to the Nagios command line and enter the following commands: 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. Testing runcmd command from the nagios server: Granting NRPE Permission to Restart Services Run the following command as root to give NRPE permission to restart services.Add below mentioned command below the commands section in the nrpe.cfg file:Ĭommand=sudo service $ARG1$ restart 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. Open NRPE configuration file and make below mentioned changes:ī.To execute commands on remote nagios client follow below steps: Yum –enablerepo=epel -y list nagios-plugins*Ģ.
LINUX MONITOR CPU AND MEMORY USAGE INSTALL
Yum –enablerepo=epel -y install nrpe nagios-plugins Working with Nagios Server and NRPE Client to automatically restart services on failureĮxecuting Remote Commands using Nagios and NRPE
LINUX MONITOR CPU AND MEMORY USAGE UPDATE

Copy the perl script and write it as "check_memory" (or check_mem orĪ suitable name for you) in the same directory as where you have the.$ /usr/local/nagios/libexec/check_mem.pl -w 10 -c 5 -f This is the link from the above plugin page.simple and good documentation. its a perl script, so not even an installation needed. but the check_memory plugin is available from the Yes, i do thought why they didnt include a plugin which will check the memory, when they have included check_swap and check_disk.
