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.