This may help get you started. Put all your configs in one directory and the
place this code in your startup script. Edit it to meet your needs.
I have NOT tested this code. Use at your risk.
************ Start of Code ********************
CONFIG_DIR = "/etc/mrtg/configs"
start()
{
echo -n $"Enabling MRTG: "
rm -f ${LOCKFILE} 2> /dev/null
cd CONFIG_DIR
for i in `ls`
do
env LANG=C ${MRTG} --pid-file=${PIDFILE} --lock-file=${LOCKFILE}
${OPTIONS} ${i}
done
}
************ End of Code ********************
Larry
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Brad
Lodgen
Sent: Wednesday, August 22, 2007 16:56
To: [email protected]
Subject: [mrtg] MRTG Daemon at Startup with hundreds of configs
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
_______________________________________________
mrtg mailing list
[email protected]
https://lists.oetiker.ch/cgi-bin/listinfo/mrtg