[mrtg] mrtg --- HELP

GUARENO at FORDHAM.EDU GUARENO at FORDHAM.EDU
Fri Jun 28 20:48:39 MEST 2002


Does anybody have any idea as to why this script (named cat_internet2.pl)
is not working?
I am using it exactly the way I got it, and only changed the OID
information.  It is trying to get User Name, Connect Times, IP Address ++
from an Ascend MAX 6000.  I'm running it on a Windows 2000 machine with
MTRG 2.9.18, and the latest version of ActivePerl.  These are the errors I
get when I run it.  It seems that there is a problem with the snmpwalk
function...

ERRORS
C:\Perl\bin>perl cat_internet2.pl s116111401 at 150.108.234.2
'c:perinsnmpwalk' is not recognized as an internal or external command,
operable program or batch file.
sysName=
'c:perinsnmpwalk' is not recognized as an internal or external command,
operable program or batch file.
'c:perinsnmpwalk' is not recognized as an internal or external command,
operable program or batch file.
'c:perinsnmpwalk' is not recognized as an internal or external command,
operable program or batch file.


SCRIPT
############################################################
#!/perl/bin/perl
#
# Copyright (C) Gehri Grimaud   Email: gehri at thingy.usu.edu
# Office of Computer Services
# Utah State University
# Logan, Utah 84322-4410
#
# May be freely distributed
#
# Script to do a "finger" on a Lucent Ascend MAX 6000.
#
# Written 30-July-1998
#
# USAGE: 'pmfinger communnity at router'
#
# The output of this script looks like:
# pm1 #2  fred    192.168.2.111   Connect 0:1:06:53 Idle 0:0:00:07
26400/31200
# pm1 #3  joe     192.168.2.87    Connect 0:2:13:47 Idle 0:0:00:07
31200/33600
# pm1 #4  gehri   192.168.2.69    Connect 0:2:23:03 Idle 0:0:00:01
28800/45333
#

# define the SNMP Object ID's we are looking for.  The Object names for
# the "Enterprise.Ascend...." MIB variables are way too ugly for words,
# so we use ".1.3.6.1.4.1.529..." OIDs instead

%OID = (
    "sysName"           =>      ".1.3.6.1.4.1.529.2.6.1.0",
    "SerialUser"        =>      ".1.3.6.1.4.1.529.12.3.1.4",
    "SerialStarted"     =>      ".1.3.6.1.4.1.529.12.3.1.5",
    "SerialIdle"        =>      ".1.3.6.1.4.1.529.11.16.1.5",
    "InSpeed"           =>      ".1.3.6.1.4.1.529.11.16.1.14",
    "OutSpeed"          =>      ".1.3.6.1.4.1.529.11.16.1.4",
#   "SerialIpAddress"   =>
".1.3.6.1.4.1.529.sessionStatusGroup.SessionStatusEntry.ssnStatusUserIPAddress",
);

# get args
($community,$router) = split(/\@/, $ARGV[0]);
#print "$community,$router\n";
die <<USAGE  unless $community && $router;

USAGE: pmfinger 'community'\@'router'

USAGE

# get the system name
#snmpwalk( sysName ) returns _stuff_.0 "pm1"
$sysName = ( &snmpwalk( $router, $community, $OID{"sysName"} ))[0];
print "sysName=$sysName\n";
$sysName =~ /"(.*?)"/;
$sysName = $1;

# get the usernames
# snmpwalk( SerialUser) returned values look like:
# _mib_stuff_.1 ""
# _mib_stuff_.2 "fred"
# _mib_stuff_.3 "miles"
# _mib_stuff_.4 "gehri"
# _mib_stuff_.5 ""

foreach $z ( &snmpwalk( $router, $community, $OID{"SerialUser"} )){
    if( $z =~ /\.(\d+) "(.+?)"/ ){
      $users{$1} = $2;
    }
}

# Get associated connect and idle times
# snmpwalk( SerialStarted ) returns _mib_stuff_.2 0:0:29:19
# snmpwalk( SerialIdle )    returns _mib_stuff_.6 0:0:00:04

foreach $z ( &snmpwalk( $router, $community, $OID{"SerialStarted"} )){
    if( $z =~ /\.(\d+) (.+?)\n/ ){
      $started{$1} = $2;
    }
}
#foreach $z ( &snmpwalk( $router, $community, $OID{"SerialIdle"} )){
#    if( $z =~ /\.(\d+) ([^\n]+)\n/ ){
#        $idle{$1} = $2;
#    }
#}

# Get IP address for each port
# snmpwalk( SerialIpAddress ) returns _mib_stuff_.3 192.168.13.12

foreach $z ( &snmpwalk( $router, $community, $OID{"SerialIpAddress"} )){
    if( $z =~ /\.(\d+) ([\d\.]+)/ ){
      $ip{$1} = $2;
    }
}

# Get connect speeds
# snmpwalk( InSpeed )  returns _mib_stuff_.2 33600
# snmpwalk( OutSpeed ) returns _mib_stuff_.2 50666

#foreach $z ( &snmpwalk( $router, $community, $OID{"InSpeed"} )){
#    if( $z =~ /\.(\d+) (\d+)/ ){
#        $speed{$1} = $2;
#    }
#}
#foreach $z ( &snmpwalk( $router, $community, $OID{"OutSpeed"} )){
#    if( $z =~ /\.(\d+) (\d+)/ ){
#        $speed{$1} .= "/" . $2;
#    }
#}

# print out info with some attempt at formatting
foreach $port ( sort { $a <=> $b } keys(%users) ){
    printf "$sysName #%-2d %-8s %-15s Connect %s Idle %s %s\n",
           $port, $users{$port}, $ip{$port}, $started{$port};
#           $idle{$port}, $speed{$port};
}

exit 0;

#####################################################
# @return = &snmpwalk( "router", "community", "OID" )
#
# call snmpwalk and return the results.  snmpwalk is an external SNMP walk
# program. In my case it is from the ucd-snmp SNMP suite.
# It is available at ftp://ucd-snmp.ucdavis.edu/
#

sub snmpwalk{
    (my $Router, my $Community, my $OID ) = @_ or return ();
    open(SNMP, "c:\perl\bin\snmpwalk -Oq -v 1 $Router $Community $OID |");
    my @snmp_table = <SNMP>;
    close SNMP;
    return @snmp_table;
}



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