Restart service problem with sudo

Andy Shellam andy.shellam-lists at mailnetwork.co.uk
Wed Mar 28 00:17:50 CEST 2007


In your Nagios event handler definition, add the following after it:

 > /tmp/debug.log 2>&1

(e.g. /etc/init.d/mysql restart > /tmp/debug.log 2>&1)

Then examine the file after nagios has run the event handler.
What that should do is output any info and errors returned from the 
command to debug.log in /tmp.

I'm guessing it's going to be something like an environment variable 
that isn't set when Nagios is running, but is when cron (or yourself) 
runs it.
Possibly $PATH?

Anyway try the above, and let us know what you get.
Failing that post your /etc/init.d/mysql script and /tmp/debug.log (as 
attachments) and we can investigate what variables that script needs set.

Andy.

Sil wrote:
> Le mardi 27 mars 2007 21:00, Andy Shellam a écrit :
>   
>> check your /etc/sudoers
>> file does not have a "defaults requiretty" option set - if it does,
>> comment it out and try your event handler again.
>>     
>
> Thanks, I check my sudoers file and there's no "defaults requiretty" line but 
> I've try it and the result is :
> Mar 27 19:21:01 localhost sudo:   nagios : sorry, you must have a tty to run 
> sudo ; TTY=unknown ; PWD=/var/log/nagios ; USER=root ; 
> COMMAND=/etc/init.d/mysql restart
>
> and if I change the line in "defaults ! requiretty" or if I remove it the 
> resultis the same :
> Mar 27 19:23:01 localhost sudo:   nagios : TTY=unknown ; PWD=/var/log/nagios ; 
> USER=root ; COMMAND=/etc/init.d/mysql restart
> But mysql don't restart.
> I don't understand. :-(
>
> I test a cron job too with the plugin on the agios user and it works !
> # 23 19 27 3 2 /usr/lib/nagios/plugins/eventhandlers/restart-mysql CRITICAL 
> SOFT 3
> The log (the same) :
> Mar 27 19:38:21 localhost sudo:   nagios : TTY=unknown ; PWD=/var/log/nagios ; 
> USER=root ; COMMAND=/etc/init.d/mysql restart
> And mysql restarts !
>
> It's very strange a cron job works but a nagios command fail and no logs have 
> any errors.
>
> If someone have any ideas...
> Thanks
> Sil
>
> !DSPAM:37,4609850a103008306114461!
>
>
>   


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list