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
](https://gagor.pro/generic-cover.webp)