[mrtg] parsing strings in OIDs

Daniel J McDonald dmcdonald at digicontech.com
Wed Feb 14 02:11:21 MET 2001


I've run across a number of OID's recently that use a literal string for the
instance, such as:
apCntByteCount."OWNER"."CONTENT-RULE"

Although this can be rendered as a very long instance, it is hard to
maintain config files like that.  I've got a little code that will change
this format to pure numeric on the fly:
#!/usr/bin/perl -w
#
sub unquoteoid ($) {
	my $attempt = shift;
	while ($attempt =~ /.+(\".+?\")/) {
		my $replace = $1;
		my $oldrep = $1;
		$replace =~ s/"//g;
		my $newrep=''; my $count=undef;
		while ($replace ne '') {
			$newrep = '.'.ord(chop($replace)).$newrep;
			$count++;
		}
		$newrep = $count . $newrep;
		$attempt =~ s/$oldrep/$newrep/;
	}
	return $attempt;
}

print unquoteoid('apCntByteCount."OWNER"."CONTENT-RULE"') ."\n";

However, I can't seem to figure out how to get it embedded into MRTG_lib.pm
in the right place to use it.  I tried fiddling a bit with sub targparser,
but it didn't seem to like what I did.  Anyone who is very familiar with
those routines want to pass me some advice?


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

Digicon - A Cisco Systems 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