Date created: Friday, February 17, 2012 10:20:19 AM. Last modified: Wednesday, January 25, 2017 5:50:48 PM

Cisco Interace Throughput

expect-cisco.sh - This expect script will show the current throughput rate of a given interface and output drop rate. It can Telnet or SSH to a device and execute "show int fa0/21" (for example). The out put shall be "grep'ed" for the bytes received/sent and output drops. The difference in the figures gathered each second is the amount of traffic traversing the port (it a delta).

There is a variation I made of this script here, which performs the same process but on a Linux based host using the 'ifconfig' command.

 

The code is below with an example output, is using iPerf to perform a 1Mbps UDP test;

# Running an iPerf test at 1Mbps over UDP (default speed when using -b);

me@myhost:~/scripts$ ./expect-switch.sh 
Device name: switch7.dc1.data.net
Username: myuser
Password: 
show int fa0/21

spawn telnet switch7.dc1.data.net
Trying 11.22.33.44...
Connected to switch7.dc1.data.net.
Escape character is '^]'.


User Access Verification

Username: myuser
Password: 

switch7.dc1>
Input: 0 Kbps Output: 0 Kbps
Input: 15 Kbps Output: 1110 Kbps
Input: 6 Kbps Output: 1101 Kbps
Input: 1 Kbps Output: 1096 Kbps
Input: 21 Kbps Output: 1101 Kbps
Input: 11 Kbps Output: 1101 Kbps
Input: 2 Kbps Output: 1098 Kbps
Input: 0 Kbps Output: 1098 Kbps
Input: 0 Kbps Output: 1097 Kbps
Input: 0 Kbps Output: 1094 Kbps
Input: 1 Kbps Output: 1108 Kbps
Input: 2 Kbps Output: 2195 Kbps
^C
Total duration 12 seconds
Total bytes received 7914 (0 MBs)
Total bytes sent 1650679 (1 MBs)
Average speed (bytes over duration)
In: 0 Kbps 
Out: 1096 Kbps