When I run service httpd status like root user I get httpd (pid 2932) is running... which is like expected.
Now, when I su nrpe and run the same cmd service httpd status I get httpd dead but subsys locked.
I’m kind of new to the Linux world but to me this smells like nrpe doesn’t have the permissions to run this cmd so it gives mentioned output.
How can I grant sudo permissions to nrpe so it can run chis cmd as root?
I have a nagios plugin that checks httpd status and it gives httpd dead but subsys locked which is not what I need.
Thanks
Advertisement
Answer
You should be able to edit your sudo file by typing visudo as the root user.
To allow your nrpe user to run service without needing a password you first need to comment out the following lines if they exist:
#Defaults targetpw #ALL ALL=(ALL) ALL
Then add the following line:
nrpe ALL=NOPASSWD: /usr/sbin/service
Now the nrpe user should be able to run “sudo service httpd status” without it asking for a password.
You should note though that this will give the nrpe user control to every service. If you’re using Apache, you might want to try something like this instead:
nrpe ALL=NOPASSWD: /usr/sbin/apache2ctl