Home Directory Plugins Hardware Network Gear Cisco check_snmp_cisco improved version

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 improved version

Hits
109536
Files:
FileDescription
check_snmp_ciscothe plugin itself - Rel. 18/05/2009
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!
SNMP check for cisco devices (routers/switches) returning state of different interfaces. By Martin Fuerstenau
The plugin is a enhanced and modified version of check_cisco.pl from R3dL!GhT.

19.05.2009 - New version. Corrects a minor bug. In case the cache file was deleted a new one was not generated automatically. Fixed. Now - in case the cached indexfile is wrong (for example you have reconfigured the cisco switch) delete the file. The next time the script runs the cachefile will be generated.

15.07.2008 - First release of the improved version.

The changes are mainly related on performance. The script was rewritten in several parts and the code was cleaned up.

On bigger switches the plugin was too slow due to the fact that it did multiple snmpwalks. On a switch with over 350 ports that caused a timeout in Nagios.

The problem was solved by implementing a cache mechanism. This was done in the following manner.

You need a directory for the cache files. It is best to do it with a tmpfs because a tmpfs is
opposite to a ramdisk swapable.

Sample entry from /etc/fstab:



tmpfs /var/nagios_plugin_cache tmpfs defaults 0 0



Please change variable $CachePath for a different location

Unforunately I use some systemcalls for executing system commands. This is a little bit dirty
but every snmp call in this script was done be a system call instead of using perl. A complete
rewrite was too much work for the time I had to solve my problems.

The function snmpwalkgrep, snmpwalk and some lines of code were kicked out because they were
no longer necessary

The script does a find in the cache directory for the cache file. If it is too old (-mtime) or
not existent it will be generated. OIDs, interface names and descriptions are store in the cache
That means the double walk will be done only every 2 days instead of every run

Synopsis:

check_cisco_snmp -H ip -C community -I interface -S state (optional)
Reviews (1)
Nagios Core 4.3.4
Ubuntu 16.04.1 LTS

snmpwalk works

Check does not

root@tgcs017:/usr/local/nagios/libexec# ./check_snmp_cisco.pl -H 10.2.8.4 -C public -I GigabitEthernet1/0/21 -S up
sh: 1: cannot create /var/nagios_plugin_cache/10.2.8.4_cache: Directory nonexistent
MIB search path: /root/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp
Cannot find module (IF-MIB): At line 0 in (none)
IF-MIB::ifDescr: Unknown Object Identifier
sh: 1: cannot create /var/nagios_plugin_cache/10.2.8.4_cache: Directory nonexistent
MIB search path: /root/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp
Cannot find module (IF-MIB): At line 0 in (none)
IF-MIB::ifName: Unknown Object Identifier
sh: 1: cannot create /var/nagios_plugin_cache/10.2.8.4_cache.tmp: Directory nonexistent
mv: cannot stat '/var/nagios_plugin_cache/10.2.8.4_cache.tmp': No such file or directory
grep: /var/nagios_plugin_cache/10.2.8.4_cache: No such file or directory
MIB search path: /root/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp
Cannot find module (IF-MIB): At line 0 in (none)
IF-MIB::ifOperStatus.: Unknown Object Identifier
Unknown state for GigabitEthernet1/0/21 : check your -s state syntax
root@tgcs017:/usr/local/nagios/libexec#

Even leaving off the -S get same error

Any ideas?

Thank you

Tom