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!
NRDS and Event Handlers
Re: NRDS and Event Handlers
This should work but it will require some work.
1. First, make sure you can run "logrotate" as nagios user.
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:
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.
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.
Don't worry about it - you can temporarily change your command to this:
just for testing purposes.
3. Create a command to be used as an event handler, for example:
4. Modify your "disk" service to use the event handler.
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.
1. First, make sure you can run "logrotate" as nagios user.
Code: Select all
su nagios
sudo /usr/sbin/logrotate -f /etc/logrotate.confCode: Select all
NAGIOSXI ALL = NOPASSWD: /usr/sbin/logrotate *
NAGIOSXIWEB ALL = NOPASSWD: /usr/sbin/logrotate *Code: Select all
command[logrotate]=sudo /usr/sbin/logrotate -f /etc/logrotate.confNote: 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 outputCode: Select all
command[logrotate]=sudo /usr/sbin/logrotate -f /etc/logrotate.conf;echo "Logs rotated"Code: Select all
[root@localhost tmp]# /usr/local/nagios/libexec/check_nrpe -H x.x.x.x -c logrotate
Logs rotated4. Modify your "disk" service to use the event handler.
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!