Page 2 of 2

Re: How to configure Nagios to run plugin with sudo

Posted: Fri Oct 25, 2013 12:16 pm
by abrist
Looking over the previous posts, your command looks odd. You run a perl script, then sudo, and finally a shell script - all in the same command. Does this combination work on the cli?

Re: How to configure Nagios to run plugin with sudo

Posted: Sat Oct 26, 2013 9:16 pm
by xtremax
Hi,

It's indeed working from the CLI, the first perl script is used to display the error message from nagios, without it I will not get any error message.

Refer to my attached screenshot.

Thanks,

Rudy

Re: How to configure Nagios to run plugin with sudo

Posted: Mon Oct 28, 2013 9:41 am
by abrist
This has to be a sudoers issue. The only real difference between my working sudo checks and yours I see is the following line:

Code: Select all

Defaults   !requiretty
Which is essentially disabled in my sudoers file.

Re: How to configure Nagios to run plugin with sudo

Posted: Mon Oct 28, 2013 10:10 am
by xtremax
Hi abrist,

May I know how to disable it? Do I just need to remove it ? Or add some # to comment it out?

Thanks,

Rudy

Re: How to configure Nagios to run plugin with sudo

Posted: Mon Oct 28, 2013 11:33 am
by slansing
You would need to edit the sudoers file and edit that line to the following:

Code: Select all

##Defaults    requiretty

Re: How to configure Nagios to run plugin with sudo

Posted: Mon Oct 28, 2013 10:19 pm
by xtremax
Hi,

I have changed the line as you suggested, and also add the following:

Code: Select all

nagios ALL=(ALL) NOPASSWD:/usr/local/nagios/libexec/
apache ALL=(ALL) NOPASSWD:/usr/local/nagios/libexec/
And now my service test and check works.

Thanks for all your suggestion.