Plugin needs root level access

So I am trying to use a MegaRAID command to query my DAS but it has to run as root to access the information it needs. I don’t want to give the nagios user root access, such as setting the sticky bit for this command, but I do need to pull that information remotely, any ideas how the nagios user could get that info?

yeppers. give that command sudo access with nopasswd. Heres an example:

Edit your sudoers file:
$ visudo

Add the following line:
nagios ALL=(ALL) NOPASSWD: /usr/sbin/smartctl

Of course, replace /usr/svin/smartctl with whatever the path is to the binary/script you’re using to access your MegaRAID controller info.

You can even make the line more specific if you’re concerned about security (eg: nagios ALL=(ALL) NOPASSWD: /usr/sbin/smartctl -l -c /dev/sda or some crap like that!)

Modify scripts as necessary (adding “sudo …”), then switch to your nagios user and try the commands out
$ su - nagios
$ sudo /usr/bin/smartctl

It should do it without prompting for a password

Very clever, works great. I didn’t know you could do that with the sudoers file. Many thanks, hopefully I will be able to repay the favor.
Doug