[mrtg] MRTG Daemon at Startup with hundreds of configs

Mersberger, Robert robert.mersberger at goldenven.com
Thu Aug 23 16:06:06 CEST 2007


I run a cron job that runs the following script.
[root at mrtg ~]# cat mrtg_run
#! /bin/bash
 
for fn in /etc/mrtg/*.cfg; do
        env LANG=C /usr/bin/mrtg "$fn" &
done
 
[root at mrtg ~]# 
 
Job runs ever 5 minutes and maintenance only needs to be done to the
config files in the /etc/mrtg directory. if you don't want a config to
be processes change the file type to something other than .cfg.
 
Hope this is what you were looking for.
 

________________________________

From: mrtg-bounces at lists.oetiker.ch
[mailto:mrtg-bounces at lists.oetiker.ch] On Behalf Of Koelstra, J. (Jan)
Sent: Thursday, August 23, 2007 3:21 AM
To: Brad Lodgen; mrtg at lists.oetiker.ch
Subject: Re: [mrtg] MRTG Daemon at Startup with hundreds of configs


What about a few 'master config'  files only containing some basic setup
and 'include: ..' statements to all your existing config files? 
In this way you only need to start your master config files.
 
HTH,
 
Jan.

	-----Original Message-----
	From: mrtg-bounces at lists.oetiker.ch
[mailto:mrtg-bounces at lists.oetiker.ch] On Behalf Of Brad Lodgen
	Sent: Wednesday, August 22, 2007 11:56 PM
	To: mrtg at lists.oetiker.ch
	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


_________________________________________________________

Dit bericht kan informatie bevatten die niet voor u is bestemd. Indien u
niet de geadresseerde bent of dit bericht abusievelijk aan u is
toegezonden, wordt u verzocht dat aan de afzender te melden en het
bericht te verwijderen. De staat aanvaardt geen aansprakelijkheid voor
schade, van welke aard ook, die verband houdt met risico's verbonden aan
het elektronisch verzenden van berichten.
_________________________________________________________

This message may contain information that is not intended for you. If
you are not the addressee or if this message was sent to you by mistake,
you are requested to inform the sender and delete the message. The state
accepts no liability for damage of any kind resulting from the risks
inherent in the electronic transmission of messages.
_________________________________________________________
	


CONFIDENTIAL NOTICE:
This e-mail message and any attachment(s) (collectively, this 'Email') are intended
only for the confidential use of the recipient(s) named above. If the reader of this
message is not the intended recipient named above or an agent responsible for
delivering it to the intended recipient named above, you have received this Email in error.
Please notify the sender immediately and permanently delete this Email and any copies thereof.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.oetiker.ch/pipermail/mrtg/attachments/20070823/32f93551/attachment-0001.html 


More information about the mrtg mailing list