Hello,
first sorry for my English.
Can somebody look attached patch for mrtg-2.16.1 and say me if it is
good idea or I invent wheel.
I need solve problem with some cisco box which index interfaces a bit
chaotic (yes indexing follow rules, but changes are possible when VLAN
is added etc.). I want to identify interface by name and graph error
counters.
Regards
Petr "Prcek" Janda
diff -ruNa -x .svn -x prcek_test mrtg-2.16.1/doc/mrtg-reference.pod mrtg-2.16.1.prcek1/doc/mrtg-reference.pod
--- mrtg-2.16.1/doc/mrtg-reference.pod 2008-02-17 11:27:36.000000000 +0100
+++ mrtg-2.16.1.prcek1/doc/mrtg-reference.pod 2008-02-27 10:34:21.000000000 +0100
@@ -1802,6 +1802,14 @@
TimeStrFmt[myrouter]: %H:%M:%S
+=head2 UseCounters
+
+By this keyword you may specify different counter names to use if you specify interfaces by number, IP address, description, name, ethernet address or by type. When you specify target by OID this option has no effect of course. Format of this option is InCounter,OutCounter
+
+Example:
+
+ UseCounters[myrouter]: ifInErrors,ifOutErrors
+
=head1 THRESHOLD CHECKING
Through its threshold checking functionality mrtg is able to detect
diff -ruNa -x .svn -x prcek_test mrtg-2.16.1/lib/mrtg2/MRTG_lib.pm mrtg-2.16.1.prcek1/lib/mrtg2/MRTG_lib.pm
--- mrtg-2.16.1/lib/mrtg2/MRTG_lib.pm 2008-02-17 11:27:36.000000000 +0100
+++ mrtg-2.16.1.prcek1/lib/mrtg2/MRTG_lib.pm 2008-02-23 17:09:14.000000000 +0100
@@ -403,7 +403,10 @@
[sub{$_[0] =~ /^(no|[lr][ul])$/i}, sub{"Must be a string of NO, LU, RU, LL, RL"}],
'timestrfmt[]' =>
- [sub{1}, sub{"Internal Error"}] #what ever the user chooses.
+ [sub{1}, sub{"Internal Error"}], #what ever the user chooses.
+
+ 'usecounters[]' =>
+ [sub{$_[0] =~ /^[^,]+,[^,]+$/i}, sub{"Must have format Counter1,Counter2"}]
);
@@ -968,7 +971,7 @@
$nohc = 1 if (defined $$rcfg{nohc}{$rou}) && (lc($$rcfg{nohc}{$rou}) eq 'yes');
( $$rcfg{target}{$rou}, $$rcfg{uniqueTarget}{$rou} ) =
- targparser( $$rcfg{target}{$rou}, $target, $targIndex, $ipv4only, $rcfg->{snmpoptions}{$rou}, $nohc );
+ targparser( $$rcfg{target}{$rou}, $target, $targIndex, $ipv4only, $rcfg->{snmpoptions}{$rou}, $nohc, $$rcfg{usecounters}{$rou} );
} else {
warn ("WARNING: I can't find a \"target[$rou]\" definition\n");
$error = "yes";
@@ -1278,7 +1281,7 @@
# efficient. See Friedl, J.E.F. Mastering Regular Expressions. O'Reilly.
# p. 273
-sub targparser( $$$$$$ ) {
+sub targparser( $$$$$$$ ) {
# Target string (int:[EMAIL PROTECTED], etc.)
my $string = shift;
# Reference to target array
@@ -1291,6 +1294,8 @@
my $snmpoptions = shift;
# Highspeed Counter test
my $nohc = shift;
+ # Use different counters for simple targets
+ my $different_counters = shift;
# Next available index in the @$target array
my $idx = @$target;
@@ -1472,6 +1477,9 @@
(.*)$ # capture post-target string
>x ) { # Total of 15 captures
my $thisTarg;
+ if(defined $different_counters) {
+ $t = $different_counters.$t;
+ }
if( exists $targIndex->{ $t } ) {
# This simple target has been encountered previously
$thisTarg = $targIndex->{ $t };
@@ -1484,12 +1492,18 @@
my $d2 = 1 - $d1;
# Set the OIDs depending on whether SNMPv2 has been specified
# and on the direction
- if( $if->{SnmpInfo} =~ m/(?::[^:]*){4}:[32][Cc]?/ and $nohc == 0 ) {
- $if->{OID}[$d1] = 'ifHCInOctets';
- $if->{OID}[$d2] = 'ifHCOutOctets';
+ if(defined $different_counters) {
+ my ($inC, $outC) = split (',', $different_counters);
+ $if->{OID}[$d1] = $inC;
+ $if->{OID}[$d2] = $outC;
} else {
- $if->{OID}[$d1] = 'ifInOctets';
- $if->{OID}[$d2] = 'ifOutOctets';
+ if( $if->{SnmpInfo} =~ m/(?::[^:]*){4}:[32][Cc]?/ and $nohc == 0 ) {
+ $if->{OID}[$d1] = 'ifHCInOctets';
+ $if->{OID}[$d2] = 'ifHCOutOctets';
+ } else {
+ $if->{OID}[$d1] = 'ifInOctets';
+ $if->{OID}[$d2] = 'ifOutOctets';
+ }
}
# Give $if->{Alt}[i] an arbitrary defined value so that
# &newSnmpTarg works correctly
_______________________________________________
mrtg-developers mailing list
[email protected]
https://lists.oetiker.ch/cgi-bin/listinfo/mrtg-developers