[mrtg] Re: cfgmaker --descint option

Curtis Doty Curtis at GreenKey.net
Sat Oct 28 22:24:29 MEST 2000


>I am by no means a Perl wizard but there appears to be a problem with this
>snippet of code in cfgmaker.
>
>	if (defined $$opt{descint}) {
>	   $refdesc = '';
>	   $refsimp = $iftype;
>	   $refsimp = ~ s/^$/$$i{RDescr}/;
>	}
>
>This results in the "ethernetCsmacd" ($iftype) being displayed in the Title
>and PageTop instead of "FastEthernet0/0" ($$i{RDescr}) as I had expected.

I'm to blame for that one, Merton. I was actually itching a different
scratch than what you had in mind. I wanted the interface type to be
displayed so they would be sorted together when I ran indexmaker.

So, here is a patch to make us both happy--I hope. ;)

What you want to try is replacing --descint with --iftitle=descr and see
what happens. Tobi may have more sage input as I only graph a few systems.

But don't expect too much, I'm also no perlwiz; I just play one on TV.

../C

--- src/mrtg-2.9.4/bin/cfgmaker Fri Oct 27 20:38:09 2000
+++ /usr/local/mrtg-2/bin/cfgmaker      Sat Oct 28 12:55:28 2000
@@ -301,17 +301,22 @@
            my $speed = int($$i{ifSpeed} / 8);
            my $speed_str = fmi($speed,$opt);
            my $iftype = IfType($$i{ifType});
-            my $refdesc = 'Traffic Analysis for ';
-            if (defined $$opt{descint}) {
-                $refdesc = '';
-                $refsimp = $iftype;
-                $refsimp =~ s/^$/$$i{RDescr}/;
-            }

             my $port_dot = $$i{RName};
             $port_dot =~ s/\//./g;
             my $portname =
$routers->{$router}{$port_dot}{CiscoCatalystPortName};

+           my $iftitle;
+           for ($$opt{iftitle} || 'any') {
+               /^any$/                 && do{ $iftitle = $$i{RName} };
+               /^(any|type)$/          && do{ $iftitle =~ s/^$/$iftype/ };
+               /^(any|type|descr)$/    && do{ $iftitle =~
s/^$/$$i{RDescr}/; last};
+               die "ERROR: Invalid value for --iftitle:
'$$opt{iftitle}'\n";
+           }
+           $iftitle =~ s/^$/Traffic Analysis for $refsimp/;
+           my $systitle = $$s{sysName};
+           $systitle =~ s/^$/$router_name/;
+
              $conf .= <<ECHO;
 ${c}
 ${c}Target[$name]: $ifref:$router
@@ -326,8 +331,8 @@
              }
              $conf .= <<ECHO;
 ${c}MaxBytes[$name]: $speed
-${c}Title[$name]: $refdesc$refsimp -- $$s{sysName}
-${c}PageTop[$name]: <H1>$refdesc$refsimp -- $$s{sysName}</H1>
+${c}Title[$name]: $iftitle -- $systitle
+${c}PageTop[$name]: <H1>$iftitle -- $systitle</H1>
 ${c} <TABLE>
 ${c}   <TR><TD>System:</TD>     <TD>$$s{sysName} in
$$s{sysLocation}</TD></TR>
 ${c}   <TR><TD>Maintainer:</TD> <TD>$$s{sysContact}</TD></TR>
@@ -573,7 +578,7 @@
        'man',
         'subdirs=s',
         'no-down',
-        'descint',
+        'iftitle=s',
         'noreversedns',
        'ifref=s',
        'output=s',
@@ -616,7 +621,11 @@

  --no-down         do not look at admin or opr status of interfaces

- --descint         describe interface instead of just 'Traffic Analysis
for'
+ --iftitle=any     interface title trying any property in this order
(default)
+                                   trying Interface Name
+ --iftitle=type                ... trying Interface Type first
+ --iftitle=descr               ... trying Interface Description first
+                                   otherwise use Interface Reference

  --subdirs=format  give each router its own subdirectory, naming each per
                    "format", in which HOSTNAME and SNMPNAME will be


--
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