Index of /files/code/snmptraf
snmptraf is a little script I threw together to get simple, easy,
real-time (or close to) statistics via SNMP, from any device that
supports the standard MIB (RFC1213), also known as MIB-II.
Requirements: Standard Perl install, Net::SNMP modules.
Running snmptraf is easy. Just start it without any arguments, and you
will be presented with syntax:
% ./snmptraf.pl
Syntax: <-t time in us> <-v 1|2c> -c [community] -h [host] -i [interface]
Here's an example:
% ./snmptraf.pl -c public -h some.host.com -i FastEthernet0/0
Peak Inbound Rate | Rate Peak Outbound
------------------------------------------------------------------------------
2.7 ********************* 2.7 | 0.1 ******************** 0.1
5.4 ********************* 5.4 | 0.1 *************** 0.1
5.4 ********************* 5.4 | 0.1 *************** 0.1
5.4 ********************* 5.3 | 0.1 *************** 0.1
5.4 ********************* 5.3 | 0.1 *************** 0.1
5.4 ********************* 5.3 | 0.1 *************** 0.1
5.4 ********************* 5.3 | 0.1 *************** 0.1
5.4 ********************* 5.4 | 0.1 *************** 0.1
5.4 ********************* 5.4 | 0.1 *************** 0.1
5.4 ********************* 5.4 | 0.1 *************** 0.1
5.4 ********************* 5.3 | 0.1 *************** 0.1
5.4 ********************* 5.4 | 0.1 *************** 0.1
5.4 ********************* 5.4 | 0.1 *************** 0.1
5.4 ********************* 5.4 | 0.1 *************** 0.1
5.4 ********************* 5.4 | 0.1 *************** 0.1
5.4 ********************* 5.4 | 0.1 *************** 0.1
The community string, host, and interface name are required, and the
other arguments are optional.
The SNMP version (-v) defaults to v1, but can be specified, as v2c
support is built-in, too.
The -t argument is the polling interval, and defaults to 150ms, which is
150000 in microseconds (us). The argument expects a number in
microseconds, so -t 1 will most likely flood the remote host with SNMP
queries, and end up being horribly inaccurate. Any polling interval
larger than five minutes is susceptible to rounding errors and aliasing,
if the selected interface carries >100Mb/sec of traffic.