[mrtg] Re: mrtg slow

McGlinchy, Alistair Alistair.McGlinchy at marks-and-spencer.com
Tue Sep 27 21:15:46 MEST 2005


> I am running mrtg/rrd on the linux/Unix platform. The computer that I 
> have running it, is very slow when implementing mrtg with crontab. I 
> only have 110 lines in crontab and the computer is almost 
> nonrepsonsive. 

You'll need to give a lot more information about what you're doing here.
How many targets are you polling? How what is the spec of your box.
What are the other 109 lines in the crontab (...or are you running 110
different cfg files). Which process(es) and CFG file(s) is/are using the
most CPU or memory.

[For reference I have 11,000 targets running on a 2x1Ghz i586 box with
1GB of RAM @ 300 second polling and have around 70 seconds CPU time

> I have little experience in writing scripts for Unix/linux, 
> but I would like to write a script and place it in rc I know I have to
have the 
> RunAsDaemon in each config file equal to yes. 

The only performance enhancement you'll get from using RunAsDaemon is
reducing the time required for perl to compile mrtg and parse the .CFG
file.  However if you have 110 distinct CFG files (I have 102 right
now), you may be better off writing a single entry in crontab and call a
general "poll_mrtg_once" script which staggers the cfgs over the 300
seconds.  Here's unixified version of mine <untested>:




my $Active_Root  	= "../Active";  # Active CFG files go here.
my $Log_Root     	= "../Logs/MRTG_Polling_Logs";
opendir DIR, $Active_Root or die "$0: ERROR, Cannot read directory
$Active_Root : $!\n";
my @files = grep /\.cfg$/i , readdir(DIR);
closedir DIR 	or die "$0: ERROR, Cannot close directory $Active_Root :
@files  		or die "$0: ERROR, No CFG files files found in

my $sleep_time = int(300/ (@files+1) );

for my $cfg_file (@files) {
	my ($day,$mon,$year)=(localtime)[3,4,5];
	my $date=sprintf "%04d-%02d-%02d", $year+1900,$mon+1,$day;
	(my $log_file = $cfg_file)=~s/.cfg$/".$date.log"/e;
	system("perl mrtg --logging=$Log_Root/$log_file
$Active_Root/$cfg_file \&");
	sleep $sleep_time;

Registered Office:
Marks and Spencer plc
Waterside House
35 North Wharf Road
W2 1NW

Registered No. 214436 in England and Wales.

Telephone (020) 7935 4422
Facsimile (020) 7487 2670


Please note that electronic mail may be monitored.

This e-mail is confidential. If you received it by mistake, please let us know and then delete it from your system; you should not copy, disclose, or distribute its contents to anyone nor act in reliance on this e-mail, as this is prohibited and may be unlawful.

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