How to configure Nagios to run plugin with sudo

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: How to configure Nagios to run plugin with sudo

Post 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?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
xtremax
Posts: 28
Joined: Wed Jul 17, 2013 11:30 pm

Re: How to configure Nagios to run plugin with sudo

Post 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
You do not have the required permissions to view the files attached to this post.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: How to configure Nagios to run plugin with sudo

Post 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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
xtremax
Posts: 28
Joined: Wed Jul 17, 2013 11:30 pm

Re: How to configure Nagios to run plugin with sudo

Post 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
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: How to configure Nagios to run plugin with sudo

Post by slansing »

You would need to edit the sudoers file and edit that line to the following:

Code: Select all

##Defaults    requiretty
xtremax
Posts: 28
Joined: Wed Jul 17, 2013 11:30 pm

Re: How to configure Nagios to run plugin with sudo

Post 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.
Locked