[nsp] Finding the bandwith hog

lee.e.rian at census.gov lee.e.rian at census.gov
Thu May 13 17:07:35 EDT 2004


Hi,

If you allow telnet, seems like RSH should be ok also...  enable RSH on the
switch and create a script that does the "rsh <device> show int" and pipes
the output to awk.  eg

>rtrUtil.sh myWS-C3524-XL
Thu May 13 16:56:11 EDT 2004
myWS-C3524-XL
  ---------- input ----------   ---------- output ----------
  --- bps ---    -pps-  bytes    --- bps ---    -pps-  bytes
        3,000        6     62              0        0      0  VLAN1
            0        0      0          4,000        4    125
FastEthernet0/2
            0        0      0          4,000        4    125
FastEthernet0/3
            0        0      0          4,000        4    125
FastEthernet0/4
            0        0      0          4,000        4    125
FastEthernet0/5
            0        0      0          4,000        4    125
FastEthernet0/6
            0        0      0          7,000        6    145
FastEthernet0/8
       15,000       10    187          1,000        1    125
GigabitEthernet0/1
       18,000       16    140         28,000       27    129  --Total



>cat rtrUtil.sh
#!/bin/sh
# show router interface utilization
# Lee Rian  8/2003
#
if [ $# -ne 0 ]; then
  devices="$*"
else
  echo "Usage: $0 device_name"
   # or somesuch... i have a default list of devices here
  exit
fi
#
date
for DEV in $devices
do
  echo $DEV
  #  rsh hangs if device is down, so try a ping first
  /usr/sbin/ping $DEV 2 > /dev/null
  stat=$?
  if [ $stat -ne 0 ]; then
     echo "$DEV  *** no response ***"
  else
rsh $DEV sh int |\
nawk '
BEGIN {
   printf("  ---------- input ----------   ---------- output ----------\n")
   printf("  --- bps ---    -pps-  bytes    --- bps ---    -pps-  bytes\n")
} # end BEGIN processing

/line protocol/ {
   operStat = substr($3,1,2)
   ifName = $1
   next
} # end /line protocol/

/put rate/ {
   if ( operStat != "up" ) next
   if ( ifName == "Loopback0" ) next
   ###
   ###   5 minute [in|out]put rate 0 bits/sec, 0 packets/sec
   ###   1   2       3         4   5  6        7  8
   ###
   printVal($5, $7)
   bps[$3] += $5; pps[$3] += $7
   if ( $3 == "output" ) printf("%s\n",ifName)
   next
} # end /put rate/

 function printVal(bps, pps,      avg) {
   avg=0
   if ( pps > 0 ) avg = int( (bps/8) / pps )
   printf("  %11s  %7s  %5s  ",dcomma(bps), dcomma(pps), dcomma(avg) )
 } # end func printVal

 function dcomma(s,   n, len, ans) {
    # Add commas to an integer
    len = length(s)
    n = ( ( len-1 ) % 3) + 1
    ans = substr(s,1,n);  n += 1
    while ( n < len ) {
       ans = ans "," substr(s,n,3);  n += 3
    }
    return ans
 } # end func dcomma

END {
  printVal(bps["input"] , pps["input"] )
  printVal(bps["output"], pps["output"])
  printf("--Total\n")
}

'
  fi
done
echo ""
echo ""


Regards,
Lee



|---------+--------------------------------->
|         |           Burton Windle         |
|         |           <bwindle at fint.org>    |
|         |           Sent by:              |
|         |           cisco-nsp-bounces at puck|
|         |           .nether.net           |
|         |                                 |
|         |                                 |
|         |           05/13/2004 02:58 PM   |
|         |                                 |
|---------+--------------------------------->
  >---------------------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                                             |
  |       To:       cisco-nsp at puck.nether.net                                                                                                   |
  |       cc:                                                                                                                                   |
  |       Subject:  [nsp] Finding the bandwith hog                                                                                              |
  >---------------------------------------------------------------------------------------------------------------------------------------------|




I have three 3524XL switches connected to a 3640 router, which then
connects to the Internet.

I am looking for a way to find the switch port/IP address of computers
that are using the most bandwidth.

Right now I telnet to each switch and do a 'show int' and look for which
switchport has a high 5-minute input rate, but there has to be a
quick/easy way to do this; graphing each switch port in MRTG is not a
valid solution.

Thanks for any pointers you can give.

--
Burton Windle                           bwindle at fint.org

_______________________________________________
cisco-nsp mailing list  cisco-nsp at puck.nether.net
https://puck.nether.net/mailman/listinfo/cisco-nsp
archive at http://puck.nether.net/pipermail/cisco-nsp/







More information about the cisco-nsp mailing list