[mrtg] Re: Memory Usuage

Daniel J McDonald dmcdonald at digicontech.com
Wed Mar 28 17:43:52 MEST 2001


> From:  Josh Goldfarb

> Hello everyone, I am an intern at a company based in NJ and I was

OK, you're an intern, we'll cut you a little slack.  This question is asked
about once a week. so most people would tell you to check the archives...

> wondering if anyone can help me with the OID for a cisco 36xx 
> router for
> memory usage, to add to the config file

Now, this is an area where you will get two answers, so we might as well
discuss it.  A lot of people will hand you a config file they have used for
the past 4 years or so, querying the cisco local mib.  Cisco has announced a
replacement for this mib - the Cisco Memory MIB, and that's what I will
recommend to you.  The advantages of using the Cisco Memory mib over the
Cisco Local mib are two-fold: 1.  If you want to monitor each of the memory
pools, like the processor pool and the IO pool, you can do that easily with
the Cisco Memory MIB.  2.  If you want to monitor a router with some version
of IOS that no longer supports the local mib, and I expect that to occur in
12.2, since they put a warning in every batch of release notes to replace
your mibs now, then you will still be able to get the information, whereas
if you use the local mib you will get no such name errors.
That being said, here's the config I use for Memory:
Target[Austin3640_mem]:
1.3.6.1.4.1.9.9.48.1.1.1.7.1&1.3.6.1.4.1.9.9.48.1.1.1.6.
1:public at 172.16.0.1
MaxBytes[Austin3640_mem]: 100663296
RouterUptime[Austin3640_mem]: public at 172.16.0.1
Options[Austin3640_mem]: Gauge
Title[Austin3640_mem]: Austin3640 Memory
YLegend[Austin3640_mem]: Free memory
ShortLegend[Austin3640_mem]: B
Legend1[Austin3640_mem]: Largest Block
Legend2[Austin3640_mem]: Free Memory
Legend3[Austin3640_mem]:
Legend4[Austin3640_mem]:
LegendI[Austin3640_mem]: Block
LegendO[Austin3640_mem]: Free

PageTop[Austin3640_mem]: <H1>Memory</H1>
 <TABLE>
   <TR><TD>System:</TD><TD>Austin3640 in </TD></TR>
 </TABLE>

> The other question I have if anyone can assist me is that I would like
> to add threshold to my .cfg file. How would I go about doing this and
> how would I go about emailing the sysmon about possible threshold
> threats.

for this one, I am going to tell you to go read the manual.  Start at
http://www.mrtg.org, find the reference manual, and read the very long and
well explained section on threshholds.

As for sending mail, I've got a little perl script that is clean enough for
me to hand out to other folks now.  There are a couple of hard coded
directories, but everything else uses the MRTG config file.
Here's a sample config:

# 

IconDir: /mrtg/
Forks: 3
WorkDir: /home/httpd/mrtg
Unscaled[_]: dm
14all*columns: 2
14all*dontshowindexgraph[_]:1
dopage*mailhost: localhost
dopage*return: netmon at outreachhealth.com
dopage*domain: outreachhealth.com
SetEnv[_]: mrtgcfg="/home/httpd/mrtg/thresh.cfg"
14all*GraphErrorsToBrowser: 1
LogFormat: rrdtool
PathAdd: /usr/local/rrdtool/bin
LibAdd: /usr/local/rrdtool/lib/perl
#
######################################################################
#    Ping probes
#.....................................................................
ThreshDir: /home/httpd/mrtg/upthresh
MaxBytes1[_]: 1
MaxBytes2[_]: 3
Legend1[_]: Ping Received
ShortLegend[_]:
Legend2[_]: Ping Missed
Legend3[_]:
Legend4[_]:
LegendI[_]: &nbsp;up
LegendO[_]: &nbsp;down
Ylegend[_]: Pings
Options[_]: gauge, withzeroes
ThreshMaxO[_]: 2
ThreshProgO[_]: /home/httpd/mrtg/page.pl
ThreshProgOKO[_]:  /home/httpd/mrtg/page.pl
dopage*notify[_]: sd at outreachhealth.com anumber at mobile.att.net
another at mobile.att.net yetmore at page.metrocall.com
######################################################################
#.....................................................................

Target[Austin_up]: ` /home/httpd/mrtg/testping.pl 172.16.0.1`
RouterUptime[Austin_up]: public at 172.16.0.1
Title[Austin_up]: Austin UP
PageTop[Austin_up]: <H1>UP?</H1>
 <TABLE>
   <TR><TD>System:</TD><TD>Austin </TD></TR>
 </TABLE>

#-----------------------------------------------------------


And now, here is the paging program called by threshprogo and threshprogoko.
I'm not going to hand out my ping program.  It's pretty hokey...


#!/usr/bin/perl -w
# page.pl
# (c) 2001 by Dan McDonald - dmcdonald at digicontech.com
# Use freely, distribute at will, modify at whim.  
# No warranties expressed or implied - use at your own risk.
#
# please send any useful modifications to Dan McDonald
#

# change the path appropriately on the following line:
use lib qw(/usr/local/mrtg-2/lib/mrtg2);


use strict;
use MRTG_lib "2.090003";
use Net::SMTP;

my ($q, $cfgfile);


        $cfgfile = $ENV{mrtgcfg};

my (@sorted, %config, %targets);
my %myrules = (
        'dopage*mailhost' => [sub{1}, sub{"Internal Error"}],
        'dopage*return' => [sub{$_[0] =~ /\@/}, sub{"dopage*return must be a
valid
        e-mail address"}],
        'dopage*domain' => [sub{$_[0] =~ /\./}, sub{"dopage*domain must be a
fqdn"}],
        'dopage*notify[]' => [sub{1}, sub{"Internal Error"}]
        );

# read the config file

readcfg($cfgfile, \@sorted, \%config, \%targets, "dopage", \%myrules);
my @processed_targets;
cfgcheck(\@sorted, \%config, \%targets, \@processed_targets);
        open(LOGFILE, ">>/var/log/mrtgpage");
        print LOGFILE "pager accessed at" . time(). "\n";
        print LOGFILE "@ARGV\n";
        print LOGFILE "$cfgfile\n";

my    $host = $ARGV[0];
my ($threshhold, $current) = undef;
if (defined $ARGV[2]) {
                $threshhold = $ARGV[1];
                $current = $ARGV[2];
}
else {
                $threshhold = 'broken';
                $current= $ARGV[1];
}

my    @notify =  split (' ',$targets{'dopage*notify'}{$host});
my    $mailhost = $config{'dopage*mailhost'};
my        $domain = $config{'dopage*domain'};
my        $return = $config{'dopage*return'};
my ($already, $state,$smtp) = undef;

    $host =~ s/_up//;
        if (-e "/home/httpd/mrtg/uppage/$host.D") {
                        $already = 1 }
        else {  $already = 0 }

    if ($threshhold eq 'broken') {
                $state = "Up" ;
                unlink ("/home/httpd/mrtg/uppage/$host.D");
                print LOGFILE "lockfile cleared for $host\n";
        }
    else {
        $state = "Down" ;
        open (PAGEFILE , ">/home/httpd/mrtg/uppage/$host.D");
        close(PAGEFILE);
        }
        if (($state eq "Up") || ($already == 0)) {
        $smtp = Net::SMTP->new($mailhost,
                                Hello => $domain);

            $smtp->mail($return);
        foreach my $address (@notify) {
                  print LOGFILE "Sent to $address\n";
              $smtp->to($address);
            } ;
        $smtp->data();
            $smtp->datasend("To: list\n");
                $smtp->datasend("Subj: $host $state\n");
        $smtp->datasend("\n");
                $smtp->datasend("$host $state\n");
            $smtp->datasend(localtime(time()) . "\n");
            $smtp->dataend();

        $smtp->quit;
                print LOGFILE "Mail sent about $host $state\n";
        }



-- Attached file removed by Listar and put at URL below --
-- Type: application/ms-tnef
-- Size: 4k (5060 bytes)
-- URL : http://www.ee.ethz.ch/~slist/pantomime/55-winmail.dat


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