[mrtg] Re: Polled target list

Daniel J McDonald dmcdonald at digicontech.com
Tue Jul 17 16:44:03 MEST 2001


From: David Sawyer [mailto:david.sawyer at uk.mckhboc.com]
Sent: Tuesday, July 17, 2001 9:14 AM
>Is there a Perl script available to make a list of all the targets
>being polled in MRTG.

>Or better still, has anybody made changes to the MRTG script to export >all
target names to a text file during each poll.

<cfgfile>.ok has this information.

Or you can parse the config file using this snippet of perl code:
use lib qw(/usr/local/mrtg-2/lib/mrtg2);
use MRTG_lib;
$cfgfile = 'mrtg.cfg';
my (@sorted, %config, %targets);
readcfg($cfgfile, \@sorted, \%config, \%targets);
my @processed_targets;
cfgcheck(\@sorted, \%config, \%targets, \@processed_targets);

you will then have all of the target name as a list in @sorted, with all of
their attributes in %targets.  if you wanted a list of the target
statements, you could use something like:

foreach my $tar (@sorted) {
	print $targets{'target'}{$tar} ."\n";
}

global information is in the %config hash, as in:
print $config{'workdir'};


Daniel J McDonald, CCIE 2495, CNX
Principal Network Specialist
Digicon Technologies
http://www.digicontech.com

Digicon, a Cisco Partner, Silver Certified.


--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive     http://www.ee.ethz.ch/~slist/mrtg
FAQ         http://faq.mrtg.org    Homepage     http://www.mrtg.org
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the mrtg mailing list