Home

Snmp CSS check

Script : check_snmp_css.pl / check_snmp_css_main.pl

Last update : Jan 22 2007

Description :

Checks by snmp v1, v2c or v3 CSS services state

SNMP Login

See snmp info page

Requirements :

- Perl in /usr/bin/perl - or just run 'perl script'
- Net::SNMP
- file 'utils.pm' in plugin diretory (/usr/local/icinga/libexec)

Checks

This scripts checks status of the CSS services.

Select service(s)
You select services you wan't to check with -n using regular expressions

Put thresholds
You select the warning and critical levels for : <num>,<resp>,<conn>
num : minimum number of active & alive service
resp : average response time in ms
conn : number of connexions

You can choose not to put 1, 2 or 3 numbers.
If you set "-w 3" only the number of active services will be checked.
If you set "-w 3,200" only the number of active services and response time will be checked.

For no warnings, put -1 (ex : -w5,-1,3).
When using negative numbers, dont put space after "-w" : "-w -1,100,6" will not work, "-w-1,100,6" will work.

-d option and check_snmp_css_main.pl

This option is set to make the script read the index from a file instead of on the CSS.

The reason of this option is :
- when you have a lot (> 50) services on the CSS
- you want to check 10 service group consisting of 5 services every 2 minutes.

If you use check_snmp_css, then it will read the index (50 oids) + checks 5 oids = 55 OID every 12 seconds in average. This will heavily load the CSS.
This is why I wrote check_snmp_css_main.pl. This script will get the index of the CSS every 10 minutes for example (could be more) as the index won't change often.
Then the check_snmp_css will only have to check for the 5 oids every 12 seconds, which will reduce by about 10 the amount of snmp queries !

How to use it :

Create a service with long inter-delay check executing :

check_snmp_css_main.pl -H <host> <snmp logins> -2 -d /var/tmp
-2 if for using snmpv2c (better to get a lot of data)
-d /var/tmp is to put the temp file to a special directory (default is /tmp).

A file named : Nagios_CSS_<IP Address> will be created

Then you can use your check_snmp_css.pl script just as before but adding the '-d' option with the temp directory if not /tmp.

If the Nagios_CSS_<IP> file is not created when the check_snmp_css script runs, it will then return unknown status.
If the check_snmp_css_main.pl cannot read index, a warning will be returned but the old index file will remain.

A lockfile is created bye check_snmp_css_main.pl when it writes it's file. The check_snmp_css script will wait until the lock file is removed to read the index file.
The lock file is named : Nagios_CSS_<IP Address>.lock
The lock file format is simple: every line is in format
<OID>:<Service name>

 

Dowload lastest version of check_snmp_css.pl : 1.0

Dowload lastest version of check_snmp_css_main.pl : 1.0

Configurations examples

Changelog : On CVS repository on sourceforge : http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/.

Examples :


All examples below are considering the script is local directory. Host to be checked is 127.0.0.1 with snmp community "public".

Get help

./check_snmp_css.pl -h

Verbose output ./check_snmp_css.pl -H <IP> -C <com> -v
snmpv3 login ./check_snmp_css.pl -H 127.0.0.1 -l login -x passwd

Output of check_snmp_css.pl -h

 SNMP Cisco CSS monitor for Nagios version 1.0
(c)2004-2006 Patrick Proy

Usage: ./check_snmp_css.pl [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) 
       -n <name> [-d directory] [-w <num>,<resp>,<conn> -c <num>,<resp>,<conn>]  [-p <port>] [-f] [-t <timeout>] [-V]
-v, --verbose
   print extra debugging information 
-h, --help
   print this help message
-H, --hostname=HOST
   name or IP address of host to check
-n, --name=<name> 
   regexp to select service
-w, --warning=<num>,<resp>,<conn> 
   Optional. Warning level for
   - minimum number of active & alive service 
   - average response time
   - number of connexions
   For no warnings, put -1 (ex : -w5,-1,3).
   When using negative numbers, dont put space after "-w"
-d, --dir=<directory to put file> 
   Directory where the temp file with index, created by check_snmp_css_main.pl, can be found
   If no directory is set, /tmp will be used
-c, --critical=<num>,resp>,<conn>
   Optional. Critical levels (-1 for no critical levels)
   See warning levels.
-C, --community=COMMUNITY NAME
   community name for the host's SNMP agent (implies v1 protocol)
-2, --v2c
   Use snmp v2c
-l, --login=LOGIN ; -x, --passwd=PASSWD
   Login and auth password for snmpv3 authentication 
   If no priv password exists, implies AuthNoPriv 
-X, --privpass=PASSWD
   Priv password for snmpv3 (AuthPriv protocol)
-L, --protocols=<authproto>,<privproto>
   <authproto> : Authentication protocol (md5|sha : default md5)
   <privproto> : Priv protocole (des|aes : default des) 
-P, --port=PORT
   SNMP port (Default 161)
-f, --perfparse, --perfdata
   Performance data output
-t, --timeout=INTEGER
   timeout for SNMP in seconds (Default: 5)
-V, --version
   prints version number

Output of check_snmp_css_main.pl -h

 SNMP Cisco CSS monitor MAIN script for Nagios version 1.0
GPL Licence, (c)2004-2006 Patrick Proy

Usage: ./check_snmp_css_main.pl [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) 
       [-d directory] [-p <port>] [-t <timeout>] [-V]
-v, --verbose
   print extra debugging information 
-h, --help
   print this help message
-H, --hostname=HOST
   name or IP address of host to check
-d, --dir=<directory to put file> 
   Directory where temp file with index is written
-C, --community=COMMUNITY NAME
   community name for the host's SNMP agent (implies v1 protocol)
-2, --v2c
   Use snmp v2c
-l, --login=LOGIN ; -x, --passwd=PASSWD
   Login and auth password for snmpv3 authentication 
   If no priv password exists, implies AuthNoPriv 
-X, --privpass=PASSWD
   Priv password for snmpv3 (AuthPriv protocol)
-L, --protocols=<authproto>,<privproto>
   <authproto> : Authentication protocol (md5|sha : default md5)
   <privproto> : Priv protocole (des|aes : default des) 
-P, --port=PORT
   SNMP port (Default 161)
-t, --timeout=INTEGER
   timeout for SNMP in seconds (Default: 5)
-V, --version
   prints version number

This project is hosted on :
SourceForge.net Logo

Nagios and the Nagios logo are registered trademarks of Ethan Galstad.