MRTG Indexmaker Interface + Description

I like to have interfaces and description, not one or the other. So I do this. Use your favorite editor to open indexmaker: vi /usr/bin/indexmaker

Find this part:

for ($$opt{section}) {
# ...Skip ahead to descr...
/^descr(iption)?$/ &&
do{
$section = "No Description for $item";
$$rcfg{setenv}{$item} =~ /MRTG_INT_DESCR="(.+?)"/ #"
and $section = $1;
$$rcfg{pagetop}{$item} =~
m,<td>Description:</td>\s*<td>\Q$section\E\s*([^< ][^>]+?)

,i
and $section = $1;
last;
};

The first “and $section = $1;” is a catch all to assign the interface name if there’s no description. The second one overwrites it, replacing the int name if it does find a description. So all you need to do is modify the second instance of “and $section = $1;” to:

and $section = $section . " - " . $1;

And your MRTG index is infinitely improved!

Share and Enjoy:
  • Print
  • Facebook
  • Reddit
  • Digg
  • Tumblr
  • Google Bookmarks
  • del.icio.us
  • StumbleUpon
This entry was posted in linux. Bookmark the permalink.

4 Responses to MRTG Indexmaker Interface + Description

  1. Barryke says:

    Thanks!
    Screenshots or pictures would make a good addition to your articles.

  2. W Sanders says:

    Another way to fix this is to replace the line:

    m,Description:\s*\Q$section\E\s*([^< ][^<]+?),i

    with

    m,\s*Description:\s*\s*\s*([^< ][^<]+?),i

    to give a more general (perhaps) parsing rule for what the “Description:” line contains. I always find myself hand editing the MRTG cfg file, and screwing up the semantics of the Description: line enough to throw off indexmaker. Plus I suspect there may be incompatibilities with indexmaker and cfg files made by hand or made a long time ago with old versions of cfgmaker. Anyway, it’s all just a simple exercise in the joyful wonders of Perl regular expressions.

  3. W Sanders says:

    Well foo it took out all my tags. Will this work?

    [code]
    Replace the line

    m,Description:\s*\Q$section\E\s*([^< ][^<]+?),i

    with

    m,\s*Description:\s*\s*\s*([^< ][^<]+?),i

    [code]

  4. W Sanders says:

    Nope. well you get the idea

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>