[mrtg] Re: question about mrtg daemon
kelsey hudson
khudson at tsss.org
Thu Oct 6 18:02:08 MEST 2005
Tao Yaoning wrote:
> Hi, all
> Does anybody know how to make mrtg running like really service. I mean you
> can use command "service mrtg start" and "service mrtg stop" to start and
sure. it's entirely possible to do something like this. i can whip up a
quick shell script for you to do that.
sounds like you're running a red hat/fedora style machine. if you're
not, this script is probably not going to work.
apparently the windows guys all think you're running windows *sigh*
> stop mrtg. Now, I just use a script to run bunch of mrtg daemon at one time.
> But if I want to restart, I have to stop them one by one manually, it's so
> annony, especially when I test them !! :(
here's the script:
#!/bin/bash
. /etc/rc.d/init.d/functions
# Check that networking is up. It's not going to work otherwise.
[ "${NETWORKING}" = "no" ] && exit 0
# Needs a valid configuration file.
CONFIGFILE=/etc/mrtg/mrtg.cfg
DAEMON_PROG=/usr/bin/mrtg
RUNAS=root
PROG="mrtg"
[ -f $CONFIGFILE ] || exit 0
RETVAL=0
case "$1" in
start)
echo -n $"Starting $PROG: "
daemon --user $RUNAS env LANG=C $DAEMON_PROG $CONFIGFILE
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$PROG
echo
;;
stop)
echo -n $"Shutting down $PROG: "
killproc $PROG
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROG
echo
;;
restart|reload)
$0 stop
$0 start
RETVAL=$?
;;
condrestart)
if [ -f /var/lock/subsys/$PROG ]; then
$0 stop
$0 start
fi
RETVAL=$?
;;
status)
status $PROG
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
exit 1
esac
exit $RETVAL
enjoy, hope this does the trick for you.
-kelsey
--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive http://lists.ee.ethz.ch/mrtg
FAQ http://faq.mrtg.org Homepage http://www.mrtg.org
WebAdmin http://lists.ee.ethz.ch/lsg2.cgi
More information about the mrtg
mailing list