NRDS and Event Handlers

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
blariv
Posts: 190
Joined: Wed Sep 26, 2012 11:55 am

NRDS and Event Handlers

Post by blariv »

I cannot seem to get this to work and I'm sure it is even supported. Remote Linux passive disk checks w/ NRDS and trying to run a logrotate event handler.

Do i need to have active checks to trigger the handler?

command[Check Disk]=/usr/local/nagios/libexec/check_disk -w 10% -c 5% -p /
$USER1$/check_nrpe -H $HOSTADDRESS$ -c "/usr/sbin/logrotate -f /etc/logrotate.conf"

CentOS release 6.3 (Final)
Nagios XI Version : 2012R2.7

Thanks!
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: NRDS and Event Handlers

Post by lmiltchev »

This should work but it will require some work.

1. First, make sure you can run "logrotate" as nagios user.

Code: Select all

su nagios
sudo /usr/sbin/logrotate -f /etc/logrotate.conf
Most probably, you will need to modify the "/etc/sudoers" to make this work. I was running XI on my remote machine, so I added the following two lines:

Code: Select all

NAGIOSXI ALL = NOPASSWD: /usr/sbin/logrotate *
NAGIOSXIWEB ALL = NOPASSWD: /usr/sbin/logrotate *
2. Setup a command in the "/usr/local/nagios/etc/nrpe/common.cfg" or "/usr/local/nagios/etc/nrpe.cfg", depending on how you installed NRPE.

Code: Select all

command[logrotate]=sudo /usr/sbin/logrotate -f /etc/logrotate.conf
Restart xinetd (or NRPE if it's running as a standalone daemon) so that changes can take effect.

Note: If you test this command from the CLI on the Nagios XI server, you will get an error, because there is no output that is returned.

Code: Select all

[root@localhost tmp]# /usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c logrotate
NRPE: Unable to read output
Don't worry about it - you can temporarily change your command to this:

Code: Select all

command[logrotate]=sudo /usr/sbin/logrotate -f /etc/logrotate.conf;echo "Logs rotated"
just for testing purposes.

Code: Select all

[root@localhost tmp]# /usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c logrotate
Logs rotated
3. Create a command to be used as an event handler, for example:
example01.PNG
4. Modify your "disk" service to use the event handler.
example02.PNG
5. Double check the host config for the "disk" service to make sure the "Address" filed contains a valid IP address. As this is a passive check, you may have a name in the address filed, which will cause the "$HOSTADDRESS$" macro not to resolve.

Hope this helps. Let us know if you run into some issues.
You do not have the required permissions to view the files attached to this post.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked