Need help with sudo and /etc/sudoers
These are the rights of the nagios-user on nagisk.pl :
Code:
[nagios@vps ~]$ ls -l /usr/local/nagios/libexec/nagisk.pl Code:
nagios ALL= (root) NOPASSWD: /usr/local/nagios/libexec/nagisk.pl Code:
[nagios@vps ~]$ /usr/local/nagios/libexec/nagisk.pl -c peers Code:
[nagios@vps ~]$ sudo /usr/local/nagios/libexec/nagisk.pl -c peers Code:
[nagios@vps ~]$ /usr/local/nagios/libexec/check_nrpe -H localhost Code:
[nagios@vps ~]$ sudo /usr/local/nagios/libexec/check_nrpe -H localhost -c check_asterisk_peers So how do I correctly give the nagios-user root-rights to be able to execute "nagisk.pl -c peers" ?? Without manually having to give the sudo-command... |
You seem to be implying that the check_asterisk_peers check in NRPE is calling the /usr/local/nagios/libexec/nagisk.pl script.
Is this the case? Is check_asterisk_peers a script? If so you'd need to insert the sudo into the line of the script that is calling /usr/local/nagios/libexec/nagisk.pl. You do NOT need to do sudo to check_npre. It won't work (and didn't as you show) because you never granted permission to do check_nrpe in sudo. It is NOT necessary to do such a grant because you're running the check_nrpe as nagios user which is the default user. That is to say you've granted permission to one thing (/usr/local/nagios/libexec/nagisk.pl) but then try to run something else (check_nrpe) with sudo. |
Quote:
Code:
bash-3.2# vi /usr/local/nagios/etc/nrpe.cfg But this sudo-statement doesn't work. Something wrong in my /etc/sudoers-file ?? |
Have you considered having the executable run itself as "root" by using chmod as root to set the s permission flag on it? If only the nagios group has x permission, that might be a possible solution.
|
What I said before is that this line is wrong:
Code:
sudo /usr/local/nagios/libexec/check_nrpe -H localhost -c check_asterisk_peers Code:
/usr/local/nagios/libexec/check_nrpe -H localhost -c check_asterisk_peers Of course I've never done a sudo in nrpe.cfg so can't guarantee that would work. |
Quote:
Code:
[nagios@vps ~]$ /usr/local/nagios/libexec/check_nrpe -H localhost -c check_asterisk_peers |
Do other checks not requiring sudo work or do you also get the NRPE: Unable to read output?
I've seen posts for that which indicate issue is that the nrpe daemon is not running as the user that owns the directory. |
I still had the option 'requiretty' enabled in /etc/sudoers
By putting it in comment, everything works well now... Thanks for all reply |
All times are GMT -5. The time now is 10:00 PM. |