Restart service problem with sudo
Sil <Spam>
smog1 at free.fr
Tue Mar 27 11:04:49 CEST 2007
Hi,
I want to test the event-handler for restarting services on my Debian
Sarge with Nagios 1.3.
I've change the sudoers permissions to accord nagios user to run
/etc/init.d/mysql restart :
Host_Alias SERVEUR = 192.168.X.X
User_Alias NAGIOS = nagios
Cmnd_Alias SERVICES = /etc/init.d/mysql restart
NAGIOS SERVEUR = NOPASSWD: SERVICES
I use a script based on the example of the doc :
restart-mysql #########################################
#!/bin/sh
case "$1" in
OK)
;;
WARNING)
;;
UNKNOWN)
;;
CRITICAL)
case "$2" in
SOFT)
case "$3" in
3)
echo -n "Restarting service (3rd soft critical state)..."
/usr/bin/sudo /etc/init.d/mysql restart
;;
esac
;;
HARD)
echo -n "Restarting service..."
/usr/bin/sudo /etc/init.d/mysql restart
;;
esac
;;
esac
exit 0
#################################################
In my checkcommands.cfg
define command{
command_name restart-mysql
command_line
/usr/lib/nagios/plugins/eventhandlers/restart-mysql $SERVICESTATE$
$STATETYPE$ $SERVICEATTEMPT$
}
But my problem is that mysql never restart
And when I try the script whit the nagios user shell, it works !
An example of my /var/log/auth.log
when I execute :
nagios at serveur$ /usr/lib/nagios/plugins/eventhadlers/restart-mysql
CRTICAL SOFT 3
Mysql restarts and I see this log :
Mar 26 15:05:34 localhost sudo: nagios : TTY=pts/1 ;
PWD=/var/log/nagios ; USER=root ; COMMAND=/etc/init.d/mysql restart
But when nagios works alone :
Mar 26 15:04:40 localhost sudo: nagios : TTY=unknown ; PWD=/ ;
USER=root ; COMMAND=/etc/init.d/mysql restart
Nothing append !
I don't understand anything, command line is run but mysql nerver starts !
Thanks for your help
Sil
-------------------------------------------------------------------------
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