[smokeping-users] Cann't restart SmokePing with sudo

Michel Tokic m.tokic at miroglio.com
Wed Nov 27 14:42:07 MET 2002



Hello,

I'm using a dynamically generated smokeping config by an CGI script. 
After doing the change in the config file I want to restart smokeping 
using "sudo /etc/init.d/smokeping restart". Therefor I added the 
following lines into my "/etc/sudoers":

apache ALL=NOPASSWD: /etc/init.d/smokeping
apache ALL=NOPASSWD: /usr/local/sbin/fping
apache ALL=NOPASSWD: /usr/local/smokeping-1.16/bin/smokeping

The problem is, that the script starts normal, and I see the successfull 
starting message in "/var/log/messages". The smokeping runs as user 
root. But after a few seconds the script get's killed. This only appears 
when smokeping is restarted by apache. When I restart it as root, all 
works fine. ?!???

Does anyone has an idea why?

Regards,
Michel





In my script I run the command `sudo /etc/init.d/smokeping restart`
And the file "/etc/init.d/smokeping" looks like this:


##############################################################
#!/bin/sh
# the path to your PID file
PIDFILE=/usr/local/smokeping-1.16/etc/data/smokeping.pid
#
# the path to your httpd binary, including options if necessary
SMOKEPING=/usr/local/smokeping-1.16/bin/smokeping

ERROR=0

for ARG in $@ $ARGS
do
   # check for pidfile
   if [ -f $PIDFILE ] ; then
       PID=`cat $PIDFILE`
       if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; then
           STATUS="smokeping (pid $PID) running"
           RUNNING=1
       else
           STATUS="smokeping (pid $PID?) not running"
           RUNNING=0
       fi
   else
       STATUS="smokeping (no pid file) not running"
       RUNNING=0
   fi

   case $ARG in
   start)
       if [ $RUNNING -eq 1 ]; then
           echo "$0 $ARG: mokeping (pid $PID) already running"
           continue
       fi
       if $SMOKEPING ; then
           echo "$0 $ARG: smokeping started"
       else
           echo "$0 $ARG: smokeping could not be started"
           ERROR=3
       fi
       ;;
   stop)
       if [ $RUNNING -eq 0 ]; then
           echo "$0 $ARG: $STATUS"
           continue
       fi
       if kill $PID ; then
           echo "$0 $ARG: smokeping stopped"
       else
           echo "$0 $ARG: smokeping could not be stopped"
           ERROR=4
       fi
       ;;
   restart)
       if [ $RUNNING -eq 0 ]; then
           echo "$0 $ARG: smokeping not running, trying to start"
           if $SMOKEPING --restart; then
               echo "$0 $ARG: smokeping started"
           else
               echo "$0 $ARG: smokeping could not be started"
               ERROR=5
           fi
       else
           if $SMOKEPING --restart; then
               echo "$0 $ARG: smokeping restarted"
           else
               echo "$0 $ARG: smokeping could not be restarted"
               ERROR=6
           fi
       fi
       ;;

   esac

done

exit $ERROR
###################################################################


-- 
====================================================
Michel Tokic <michel at tokic.com>
CCNA: #10498162


--
Unsubscribe mailto:smokeping-users-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:smokeping-users-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/smokeping-users
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the smokeping-users mailing list