[mrtg] Re: AS5800

Anthony Hardy soma at net1inc.net
Wed Jul 21 22:41:10 MEST 1999


Sure!

Here is my modified version of get5200 that I am using to get reports out of my
5396 and 5800, as well as my 5200's . . . . . .

There are several parts . . .and I'm not the best shell scripter in the world .
.but this DOES get all the current modem usage accurately!

Use the script as normal . . . .to get the info if you don't have any isdn
usage . . .

Where it says "my $portmax=$port+48;" I like to set the number (where I have
48) to the number of lines you have on the box to measure the analog
connections.  To measure the ISDN connections, you need to walk the tree on
your box and find out how many serial connections (in my 5396's case, 91) it
has listed in its SNMP tree.  I have a separate copy of the script that I run
for each box, as each one has a different number of lines.  I can usually use
one script to do ISDN on all the boxes . . all of my 5396's with PRI's have 91
ISDN IOD's.  I have attached both of these files . . . . get-5396 and
get-5396-isdn.  They are the exact copies of the get-5200 script, BUT they have
the portmax+ number changed.  You can get decent data running just one script
on the 5300 and 5200's . . .but on the 5800 . .you HAVE to separate them out
because of the listing of the OID's to serial ports mappings (too much detail
to go into here).

I have also attached the script I use to pull together the data from both isdn
and analog versions . . it is VERY basic and VERY tailored to my system .. so
don't blast me for not setting up variables and making it easy for everyone to
use. . .hehe

This would be meant for a guide only.

Anthony




kikino su sardu wrote:

> Hi Anthony,
> I have correct my "get5200" but I dont have any result.
> What is your modify for "get5200" ?
> Can you post me your "get5200" file ?
>
> Thank's for your time.
>
> kikino su sardu
>
> >I am doing this right now:) . . . .If you haven't gotten the answer, lease
> let
> >me know.  It is actually a hacked up version of get5200 (gets users n an
> >AS5200).  Because of the way the 5800 handles ISDN vs modem alls I had to
> hack
> >the script some to get accurrate numbers. . .it actually runs three
> separate
> >scripts and compiles the information, which it then reports to mrtg.
> >
> >I've been using it for quite some time and it works GREAT!
> >
> >Like I said, if you need it, let me know.
> >
> >Anthony
> >
> >kikino su sardu wrote:
> >
> >> Ps: Sorry for my previous post....
> >>
> >> Hi,
> >> I have a little problem; I need to count how many user are onnected int
> my
> >> Cisco as5800.
> >> If possible I like to know  how many user are connected in ISDN n how
> many
> >> user are in PSTN.
> >>
> >> Can You help me?
> >> There is an OID for this operation?
> >> Can You have a sample MRTG configuration for this?
> >>
> >> Thanks in advance
> >>
> >> kikino
> >>
> >> --
> >> * To unsubscribe from the mrtg mailing list, send a message ith the>>>
> subject: unsubscribe to mrtg-request at list.ee.ethz.ch
> >> * The mailing list archive is at http://www.ee.ethz.ch/~slist/mrtg
> >>>>--
> >> To unsubscribe from the mrtg mailing list, send a message with the>>
> subject: unsubscribe to mrtg-request at list.ee.ethz.ch
> >>*The mailing list archive is at http://www.ee.ethz.ch/~slist/mrtg
> >>
>
> --
> * To unsubscribe from the mrtg mailing list, send a message with the
>   subject: unsubscribe to mrtg-request at list.ee.ethz.ch
> * The mailing list archive is at http://www.ee.ethz.ch/~slist/mrtg
-------------- next part --------------
#!/usr/bin/perl
require 5.004;

use SNMP_Session "0.52";
use BER "0.50";



my($community,$router) = split /\@/, $ARGV[0];
my($port) = $ARGV[1];
my $isdn="";
if ( defined($ARGV[2]) ) {
        $isdn = $ARGV[2];
} else {
        $isdn = 0;
}
die <<USAGE  unless $community && $router && $port;
USAGE: get-5396 'community'\@'as5200' Async-Interface-Start
[Serial-Int-Start]
EXAMPLE:  get-as5200 public\@127.0.0.1 55 6
USAGE
my $portmax=$port+96;
my $up=0, $down=0, $status=0, $iup=0, $istatus=0, $Uptime=0, $sysName="";

if ($isdn > 0) {
        $isdn = ($port - $isdn);
}

while ($port < $portmax) {

        if ($isdn > 0) {
           ($status,$istatus) =
            &snmpget($router,
                     $community,
                     '1.3.6.1.2.1.2.2.1.8.'. $port,
                     '1.3.6.1.2.1.2.2.1.8.'. ($port - $isdn),
                     ); # ifOperStatus                             

            if ( $istatus == 1 )
                { $iup ++; }

        } else {
           ($status) =
            &snmpget($router,
                     $community,
                     '1.3.6.1.2.1.2.2.1.8.'. $port,
                     ); # ifOperStatus

        }

            if ( $status == 1 )
                { $up ++; }

            if ( ($status != 1) && ($status != 2) )                   
                { $down ++; }

        $port ++;
}
           ($Uptime,$sysName) =
            &snmpget($router,
                     $community,
                     '1.3.6.1.2.1.1.3.0', # sysUptime
                     '1.3.6.1.2.1.1.5.0' ); #  sysName

if ( defined($ARGV[2]) ) {
# are we reporting isdn?
        $down = $iup;
}
print "$up\n$down\n$Uptime\n$sysName\n";

%snmpget::OIDS =                                              
  ('sysDescr' => '1.3.6.1.2.1.1.1.0',
   'sysContact' => '1.3.6.1.2.1.1.4.0',
   'sysName' => '1.3.6.1.2.1.1.5.0',
   'sysLocation' => '1.3.6.1.2.1.1.6.0',
   'sysUptime' => '1.3.6.1.2.1.1.3.0',
   'ifNumber' =>  '1.3.6.1.2.1.2.1.0',
   ###################################
   # add the ifNumber ....
   'ifDescr' => '1.3.6.1.2.1.2.2.1.2',
   'ifType' => '1.3.6.1.2.1.2.2.1.3',
   'ifIndex' => '1.3.6.1.2.1.2.2.1.1',
   'ifInErrors' => '1.3.6.1.2.1.2.2.1.14',
   'ifOutErrors' => '1.3.6.1.2.1.2.2.1.20',
   'ifInOctets' => '1.3.6.1.2.1.2.2.1.10',
   'ifOutOctets' => '1.3.6.1.2.1.2.2.1.16',
   'ifInDiscards' => '1.3.6.1.2.1.2.2.1.13',
   'ifOutDiscards' => '1.3.6.1.2.1.2.2.1.19',                                  
   'ifInUcastPkts' => '1.3.6.1.2.1.2.2.1.11',
   'ifOutUcastPkts' => '1.3.6.1.2.1.2.2.1.17',
   'ifInNUcastPkts' => '1.3.6.1.2.1.2.2.1.12',
   'ifOutNUcastPkts' => '1.3.6.1.2.1.2.2.1.18',
   'ifInUnknownProtos' => '1.3.6.1.2.1.2.2.1.15',
   'ifOutQLen' => '1.3.6.1.2.1.2.2.1.21',
   'ifSpeed' => '1.3.6.1.2.1.2.2.1.5',
   # up 1, down 2, testing 3
   'ifOperStatus' => '1.3.6.1.2.1.2.2.1.8',
   'ifAdminStatus' => '1.3.6.1.2.1.2.2.1.7',
   # up = 1 else 0;
   'ifOperHack' => '1.3.6.1.2.1.2.2.1.8',
   'ifAdminHack' => '1.3.6.1.2.1.2.2.1.7',
    #frame relay stuff ... see the docs for explanations
    'frInOctets' => '1.3.6.1.2.1.10.32.2.1.9',
    'frOutOctets' => '1.3.6.1.2.1.10.32.2.1.7',
  );                                                                          

sub snmpget {
  my($host,$community, at vars) = @_;
  my(@enoid, $var,$response, $bindings, $binding, $value, $inoid,$outoid,
     $upoid,$oid, at retvals);
  foreach $var (@vars) {
    if ($var =~ /^([a-z]+)/i) {
      my $oid = $snmpget::OIDS{$1};
      if ($oid) {
        $var =~ s/$1/$oid/;
      } else {
        die "Unknown SNMP var $var\n"
      }
    }
    push @enoid,  encode_oid((split /\./, $var));
  }
  srand();                                                                     
  my $session;
  $session = SNMP_Session->open($host,$community,161);
  if (! defined($session)) {
    warn "SNMPGET Problem for $community\@$host\n";
    return (-1,-1);
  }

  if ($session->get_request_response(@enoid)) {
    $response = $session->pdu_buffer;
    ($bindings) = $session->decode_get_response ($response);
    $session->close ();
    while ($bindings) {
      ($binding,$bindings) = decode_sequence ($bindings);
      ($oid,$value) = decode_by_template ($binding, "%O%@");
      my $tempo = pretty_print($value);
      $tempo=~s/\t/ /g;
      $tempo=~s/\n/ /g;                                                      
      $tempo=~s/^\s+//;
      $tempo=~s/\s+$//;
      push @retvals,  $tempo;
    }
    return (@retvals);
  } else {
    return (-1,-1);
  }
}
                            
-------------- next part --------------
#!/usr/bin/perl
require 5.004;

use SNMP_Session "0.52";
use BER "0.50";



my($community,$router) = split /\@/, $ARGV[0];
my($port) = $ARGV[1];
my $isdn="";
if ( defined($ARGV[2]) ) {
        $isdn = $ARGV[2];
} else {
        $isdn = 0;
}
die <<USAGE  unless $community && $router && $port;
USAGE: get-5396 'community'\@'as5200' Async-Interface-Start
[Serial-Int-Start]
EXAMPLE:  get-as5200 public\@127.0.0.1 55 6
USAGE
my $portmax=$port+91;
my $up=0, $down=0, $status=0, $iup=0, $istatus=0, $Uptime=0, $sysName="";

if ($isdn > 0) {
        $isdn = ($port - $isdn);
}

while ($port < $portmax) {

        if ($isdn > 0) {
           ($status,$istatus) =
            &snmpget($router,
                     $community,
                     '1.3.6.1.2.1.2.2.1.8.'. $port,
                     '1.3.6.1.2.1.2.2.1.8.'. ($port - $isdn),
                     ); # ifOperStatus                             

            if ( $istatus == 1 )
                { $iup ++; }

        } else {
           ($status) =
            &snmpget($router,
                     $community,
                     '1.3.6.1.2.1.2.2.1.8.'. $port,
                     ); # ifOperStatus

        }

            if ( $status == 1 )
                { $up ++; }

            if ( ($status != 1) && ($status != 2) )                   
                { $down ++; }

        $port ++;
}
           ($Uptime,$sysName) =
            &snmpget($router,
                     $community,
                     '1.3.6.1.2.1.1.3.0', # sysUptime
                     '1.3.6.1.2.1.1.5.0' ); #  sysName

if ( defined($ARGV[2]) ) {
# are we reporting isdn?
        $down = $iup;
}
print "$up\n$down\n$Uptime\n$sysName\n";

%snmpget::OIDS =                                              
  ('sysDescr' => '1.3.6.1.2.1.1.1.0',
   'sysContact' => '1.3.6.1.2.1.1.4.0',
   'sysName' => '1.3.6.1.2.1.1.5.0',
   'sysLocation' => '1.3.6.1.2.1.1.6.0',
   'sysUptime' => '1.3.6.1.2.1.1.3.0',
   'ifNumber' =>  '1.3.6.1.2.1.2.1.0',
   ###################################
   # add the ifNumber ....
   'ifDescr' => '1.3.6.1.2.1.2.2.1.2',
   'ifType' => '1.3.6.1.2.1.2.2.1.3',
   'ifIndex' => '1.3.6.1.2.1.2.2.1.1',
   'ifInErrors' => '1.3.6.1.2.1.2.2.1.14',
   'ifOutErrors' => '1.3.6.1.2.1.2.2.1.20',
   'ifInOctets' => '1.3.6.1.2.1.2.2.1.10',
   'ifOutOctets' => '1.3.6.1.2.1.2.2.1.16',
   'ifInDiscards' => '1.3.6.1.2.1.2.2.1.13',
   'ifOutDiscards' => '1.3.6.1.2.1.2.2.1.19',                                  
   'ifInUcastPkts' => '1.3.6.1.2.1.2.2.1.11',
   'ifOutUcastPkts' => '1.3.6.1.2.1.2.2.1.17',
   'ifInNUcastPkts' => '1.3.6.1.2.1.2.2.1.12',
   'ifOutNUcastPkts' => '1.3.6.1.2.1.2.2.1.18',
   'ifInUnknownProtos' => '1.3.6.1.2.1.2.2.1.15',
   'ifOutQLen' => '1.3.6.1.2.1.2.2.1.21',
   'ifSpeed' => '1.3.6.1.2.1.2.2.1.5',
   # up 1, down 2, testing 3
   'ifOperStatus' => '1.3.6.1.2.1.2.2.1.8',
   'ifAdminStatus' => '1.3.6.1.2.1.2.2.1.7',
   # up = 1 else 0;
   'ifOperHack' => '1.3.6.1.2.1.2.2.1.8',
   'ifAdminHack' => '1.3.6.1.2.1.2.2.1.7',
    #frame relay stuff ... see the docs for explanations
    'frInOctets' => '1.3.6.1.2.1.10.32.2.1.9',
    'frOutOctets' => '1.3.6.1.2.1.10.32.2.1.7',
  );                                                                          

sub snmpget {
  my($host,$community, at vars) = @_;
  my(@enoid, $var,$response, $bindings, $binding, $value, $inoid,$outoid,
     $upoid,$oid, at retvals);
  foreach $var (@vars) {
    if ($var =~ /^([a-z]+)/i) {
      my $oid = $snmpget::OIDS{$1};
      if ($oid) {
        $var =~ s/$1/$oid/;
      } else {
        die "Unknown SNMP var $var\n"
      }
    }
    push @enoid,  encode_oid((split /\./, $var));
  }
  srand();                                                                     
  my $session;
  $session = SNMP_Session->open($host,$community,161);
  if (! defined($session)) {
    warn "SNMPGET Problem for $community\@$host\n";
    return (-1,-1);
  }

  if ($session->get_request_response(@enoid)) {
    $response = $session->pdu_buffer;
    ($bindings) = $session->decode_get_response ($response);
    $session->close ();
    while ($bindings) {
      ($binding,$bindings) = decode_sequence ($bindings);
      ($oid,$value) = decode_by_template ($binding, "%O%@");
      my $tempo = pretty_print($value);
      $tempo=~s/\t/ /g;
      $tempo=~s/\n/ /g;                                                      
      $tempo=~s/^\s+//;
      $tempo=~s/\s+$//;
      push @retvals,  $tempo;
    }
    return (@retvals);
  } else {
    return (-1,-1);
  }
}
                            
-------------- next part --------------
#!/bin/sh

# This should get all info and work it to give to mrtg for 5300.

# First clean out old files.
rm -rf /$path_to_mrtg/brewtont-5396-isdn.tmp
rm -rf /$path_to_mrtg/brewtont-5396.tmp

# Get ISDN stats
/$path_to_mrtg/get-5396-isdn xxx at xxx.xxx.xxx.xxx 8 >/$path_to_mrtg/brewtont-5396-isdn.tmp

# Get analog stats
/$path_to_mrtg/get-5396 xxxx at xxx.xxx.xxx.xxx 105 >/$path_to_mrtg/brewtont-5396.tmp

# Get system up time.
uptime=`tail -2 /$path_to_mrtg/brewtont-5396.tmp|head -1`

# Read in variables.
isdnt=`head -1 /$path_to_mrtg/brewtont-5396-isdn.tmp`
analogt=`head -1 /$path_to_mrtg/brewtont-5396.tmp`

#echo $isdn
#echo $analog

# Add them together to get total lines in use.
totalt=`expr $isdnt + $analogt`

#echo
#echo $total
# Figure Lines Free.
freet=`expr 69 - $totalt`

# Give final output
#echo $total
#echo $free
#echo $uptime
#echo Brewton-5396.net1inc.net

# This should get all info and work it to give to mrtg for 5300.

# First clean out old files.
rm -rf /$path_to_mrtg/brewton02t-5396-isdn.tmp
rm -rf /$path_to_mrtg/brewton02t-5396.tmp

# Get ISDN stats
/$path_to_mrtg/get-5396-isdn xxxx at xxx.xxx.xxx.xxx 8 >/$path_to_mrtg/brewton02t-5396-isdn.tmp

# Get analog stats
/$path_to_mrtg/get-5396 xxxx at xxx.xxx.xxx.xxx 105 >/$path_to_mrtg/brewton02t-5396.tmp

# Get system up time.
uptime02t=`tail -2 /$path_to_mrtg/brewton02t-5396.tmp|head -1`

# Read in variables.
isdn02t=`head -1 /$path_to_mrtg/brewton02t-5396-isdn.tmp`
analog02t=`head -1 /$path_to_mrtg/brewton02t-5396.tmp`

#echo $isdn
#echo $analog

# Add them together to get total lines in use.
total02t=`expr $isdn02t + $analog02t`

#echo
#echo $total
# Figure Lines Free.
free02t=`expr 46 - $total02t`

#Get all together and get real totals.
total=`expr $totalt + $total02t`
free=`expr $freet + $free02t`

# Give final output
echo $total
echo $free
echo $uptime
echo Brewton-5396-02.net1inc.net


More information about the mrtg mailing list