Home Directory Plugins Hardware Network Gear Cisco Check SNMP Cisco Traffic

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

Check SNMP Cisco Traffic

Rating
2 votes
Favoured:
0
Hits
164189
Files:
FileDescription
check_snmp_cisco_trafficthe plugin itself
check-traffic.phppnp template
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
Check Traffic Usage of an Interface on a Cisco Device
Check Traffic Usage of an Interface on a Cisco Device

This is a bit tricky, because cisco's snmp counter are independent from the cli output.
The snmp counters can't be reset at runtime, they online reset themself at reboot.
So in addition to the snmp values we get, we need to calculate....

We save the last check results/sums in a text file so make sure you set "tmpfile" below.
Please create it, fill in 4 zeros and make sure it is writable by the user that nagios runs as

$ touch /home/nagios/check_snmp_cisco_traffic.txt
$ echo 0 0 0 0> /home/nagios/check_snmp_cisco_traffic.txt
$ chown nagios:nagios /home/nagios/check_snmp_cisco_traffic.txt

This plugin currently only uses HC/64bit counter, because 32bit begin from zero too often.
You also have to find out the interface number yourself, i don't, yet, want the script to
search for it every runtime. Just snmpwalk your device like this:

$ snmpwalk -v2c -c community-string HOST 1.3.6.1.2.1.31.1.1.1.1
IF-MIB::ifName.1 = STRING: Fa0
This -^- is the interface-number

Version 0.1, Copyright (c) 2008 by Michael Boehm

TODO:
-definitively add multiple check support with prefix+name_of_txt_file (should be easy)
--> easier than i thought, see Update-2008-09-22 below
-testing
-maybe accepting Interface descriptions as argument
-maybe include check for 32bit counter

---------------------------------

There was surely not enough testing(-time), so please report any bugs!
I'm not quiet happy with the pnp template, if anybody got suggestions please post or send them to me. Thx

Update-2008-09-22: modified pnp template - added "--lower=$MIN[1]" for better in-out ratio
Update-2008-09-22: remark added to temp-file section:
# if you use suffix: $1 this will be the IP adress of the given device
# so different txt files for different devices are possible

tmpfile=/home/nagios/check_snmp_cisco_traffic_$1.txt
Reviews (2)
by, September 15, 2014
Very good!

I have made a little change in order to use interface name instead of index number. My changes:

index=`snmpwalk -v2c -c $snmpstring $host IF-MIB::ifName | awk -v PORTNAME="$interface\$" '$0 ~ PORTNAME {split($1,array,"."); print array[2]}'`

# current value
trafbyteIn=`snmpget -v2c -c $snmpstring $host 1.3.6.1.2.1.31.1.1.1.6.$index |awk {'print $4'}`
trafbyteOut=`snmpget -v2c -c $snmpstring $host 1.3.6.1.2.1.31.1.1.1.10.$index |awk {'print $4'}`
Provides a cumulative total of thru put on any port.
With a little change in math it would work.