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....
check_cisco_traffic_usage <host> <snmp-string> <if-number> <warn> <crit>
|host||Hostname or IP Address|
|snmp-string||the snmp community string|
|warn||warning value in MB|
|crit||critical value in MB|
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 with.
$ 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 126.96.36.199.188.8.131.52.1.1.1 IF-MIB::ifName.1 = STRING: Fa0 This -^- is the interface-number
Version 0.1, Copyright (c) 2008 by Michael Boehm <dudleyperkins_AT_gmail.com>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
you should have received a copy of the GNU General Public License along with this program (or with Nagios); if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- definitively add multiple check support with prefix+name_of_txt_file (should be easy)
- maybe accepting Interface descriptions as argument
- maybe include check for 32bit counter