Nagios – run checks as root with NRPE

I’ve few Nagios checks that require root privileges but running nrpe as root user is not acceptable. I prefer to use sudo for only these few commands.

Run visudo and coment out this line:

#Defaults    requiretty

This change is crucial to get scripts working.

Then add at the end of file:

%nrpe ALL=(ALL) NOPASSWD: /usr/lib64/nagios/plugins/

I’ve used nrpe group, but you have to add exactly group that your nrpe process uses.

Now you should be able to run checks as root – edit /etc/nagios/nrpe.cfg and add check like this:

command[check_as_root]=/usr/bin/sudo /usr/lib64/nagios/plugins/check_with_root_privileges

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.