cisco monitor script

jerobins@unity.ncsu.edu
Thu, 29 Jun 1995 10:23:07 -0400 (EDT)

Here is a quick script that I hacked together to keep some stats for
us...most important note is the index number of the interface and not
the interface number....
Enjoy,
James

-- 
 James E. Robinson, III    |    http://www.cc.ncsu.edu/james 
    jer@ncsu.edu           |  Research, Development and Data Comm.
 Systems Programmer        |   North Carolina State University
  "The first step to wisdom is silence; the second is listening."

#!/dept/bin/scotty -f # # Script to monitor - # 5 minutes packet/sec input and output # Packet collisions # input errors #

if { $argc < 2 } { puts "usage: int_monitor <cisco.hostname> <interface index>"; exit 1; }

set hostname [lindex $argv 0]; set intIndex [lindex $argv 1];

set address [lindex [dns a $hostname] 0];

## get snmp session handle set s [snmp session];

## configure for particular router $s configure -address $address;

## open the file set fp [open "/dept/tkined/log/$hostname.$intIndex.stats" "a+"];

puts $fp "Started [getdate]"; puts $fp "Time \t\t in p/s@5 \t InErrors \t out p/s@5 \t Collisions"; flush $fp;

set InErr "1.3.6.1.2.1.2.2.1.14"; set InRate "1.3.6.1.4.1.9.2.2.1.1.7"; set OutRate "1.3.6.1.4.1.9.2.2.1.1.9"; set Coll "1.3.6.1.4.1.9.2.2.1.1.25";

set mibInErr [join [list $InErr $intIndex] "."]; set mibInRate [join [list $InRate $intIndex] "."]; set mibOutRate [join [list $OutRate $intIndex] "."]; set mibColl [join [list $Coll $intIndex] "."];

set strInErr [join [list $mibInErr DisplayString] " "]; set strInRate [join [list $mibInRate DisplayString] " "]; set strOutRate [join [list $mibOutRate DisplayString] " "]; set strColl [join [list $mibColl DisplayString] " "];

while { 1 } { set time [lindex [split [getdate] " "] 3]; ## this return Counter set pktInErr [$s get [list $strInErr]]; ## this return INTEGER set pktInRate [$s get [list $strInRate]]; ## this return INTEGER set pktOutRate [$s get [list $strOutRate]]; ## this return INTEGER set ifColl [$s get [list $strColl]];

set col1 [lindex [split [lindex $pktInRate 0] "INTEGER"] 7]; set col2 [lindex [split [lindex $pktInErr 0] "Counter"] 7]; set col3 [lindex [split [lindex $pktOutRate 0] "INTEGER"] 7]; set col4 [lindex [split [lindex $ifColl 0] "INTEGER"] 7];

puts $fp "$time \t $col1 \t\t $col2 \t\t $col3 \t\t $col4"; flush $fp;

## wait 60 seconds and get stats again after 60000; }