[mrtg] MRTG Daemon at Startup with hundreds of configs

Brad Lodgen darkerosxx at gmail.com
Wed Aug 22 23:55:30 CEST 2007


Hi there,

I'm looking at a project to switch a server that is using MRTG to monitor
hundreds of devices over to running MRTG in daemon mode, for efficiency. As
one could infer, there are hundreds of config files to go along with those
hundreds of devices. Since MRTG has to be started once for each config, I'm
trying to develop a Linux startup script that will execute all of the
configs. I will copy/paste the startup script I'm currently working with.
Does anyone have any idea how to change this to make it start up all of the
configs? It may be an easy answer, but I'm very fresh on shell scripting and
have spent hours searching for this info, to no avail. Please help!

Thanks in advance for any advice or help you may provide...here is the
startup script I found....


#!/bin/bash
#
# mrtg          This shell script starts mrtg
#
# Author:       Stefan SF
#
# chkconfig:    345 90 35
#
# description:  mrtg The Multi Router Traffic Grapher
# processname:  mrtg
# config:       /etc/mrtg/mrtg.conf
#
### BEGIN INIT INFO
# Provides: mrtg
# Required-Start: $network
# Default-Stop: 0 1 6
# Short-Description: Starts the The Multi Router Traffic Grapher
# Description: The Multi Router Traffic Grapher (MRTG) is a tool to monitor \
#              the traffic load on network-links. MRTG generates HTML pages \
#              containing GIF/PNG images which provide a live visual \
#              representation of this traffic.
### END INIT INFO

# source function library
. /etc/rc.d/init.d/functions

MRTG="/usr/bin/mrtg"
CONFIG="/etc/mrtg/mrtg.cfg"
PIDFILE="/var/run/mrtg.pid"
LOCKFILE="/var/lock/mrtg/mrtg"
OPTIONS="--daemon"

RETVAL=0

start() {
	echo -n $"Enabling MRTG: "
	rm -f ${LOCKFILE} 2> /dev/null
	env LANG=C ${MRTG} --pid-file=${PIDFILE} --lock-file=${LOCKFILE}
${OPTIONS} ${CONFIG}
	RETVAL=$?
	echo
}

stop() {
	echo -n $"Disabling MRTG: "
	kill `cat ${PIDFILE}` && rm -f ${LOCKFILE}
	RETVAL=$?
	echo
}

restart() {
	stop
	start
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart|force-reload)
	restart
	;;
  status)
	if [ -f $LOCKFILE ]; then
		echo $"MRTG is enabled."
		RETVAL=0
	else
		echo $"MRTG is disabled."
		RETVAL=3
	fi
	;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|force-reload}"
	exit 1
esac

exit $RETVAL
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.oetiker.ch/pipermail/mrtg/attachments/20070822/5a98cb15/attachment-0001.html 


More information about the mrtg mailing list