This site :
Home
Nagios plugins
Info on snmp
Nagios config
FAQ
Project page on SourceForge
-----------
Links :
Nagios Home
Nagios Plugins
Oreon project
NagiosExchange
Opsyx forum
Forum 2037
-----------
Others :
-----------
SourceForge.net Logo
Snmp storage check

Script : check_snmp_storage.pl

Last update : Jun 09 2007

Description :

This scripts checks by snmp (V1 and v3) disks, memory, swap, everthing in hrStorage table.
Storages selection can be done :
- by perl regexp on description or index (-m)
- and (optional) by storage type (-q) : Other, Ram, VirtualMemory, FixedDisk, RemovableDisk, FloppyDisk, CompactDisk, RamDisk, FlashMemory, NetworkDisk

One or multiple storages can be selected.
It is also possible to sum all selected storages (-s)

Warning and critical levels can be checked based on :
- Percent of disk used
- Percent of disk left
- MB left
- MB used

Output options (-S):

-S can have 3 options : <type>[,<where>,<cut>]
<type> : Make the output shorter :
0 : only print the global result except the disk in warning or critical
1 : Don't print all info for every disk
<where> : (optional) if = 1, put the OK/WARN/CRIT at the beginning
<cut> : take the <n> first caracters or <n> last if n<0

With the following disks : /home : 51% used and / : 90% used

Option used Warning Output
  99% /home: 51%used(1012MB/1969MB) /: 90%used(5781MB/6390MB) (<99%) : OK
  90% /home: 51%used(1012MB/1969MB) /: 90%used(5781MB/6390MB) (>90%) : WARNING
-S0 90% All selected storages (<99%) : OK
-S0 99% /: 90%used(5781MB/6390MB) (>90%) : WARNING
-S1 90% /home: 51% /: 90% (<99%) : OK
-S1 99% /home: 51% /: 90%used(5781MB/6390MB) (>90%) : WARNING
-S0,1 90% OK : (<99%) All selected storages
-S0,1 90% WARNING : (>90%) /: 90%used(5781MB/6390MB)
-S1,,2 99% /h: 51% /: 90% (<99%) : OK
-S1,,-2 99% me: 51% /: 90% (<99%) : OK
-S0,1,-2 30% WARNING : (>30%) me: 51%used(1012MB/1969MB) /: 90%used(5781MB/6390MB)

Performance output (-f option)

The performance will remove any weird caracters ( `~!$%^&*'"<>|?,(= ) ) from the drive name.

Msg size option (-o option)

In case you get a "ERROR: running table : Message size exceeded maxMsgSize" error, you may need to adjust the maxMsgSize, i.e. the maximum size of snmp message with the -o option. Try a value with the -o AND the -v option : the script will output the actual value so you can add some octets to it with the -o option.

SNMP Login

See snmp info page

---
Vérifie par snmp v1 ou v3 l'occupation des disques, mais aussi de la swap, de la mémoire, etc.. tout ce qui est disponible en snmp par la table hrStorage.
Les disques sont sélectionnables par expression régulière compatible Perl

Requirements :

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

Dowload lastest version : 1.3.3

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_storage.pl -h

List all storage ./check_snmp_storage.pl -H 127.0.0.1 -C public -m zzzz -w 80 -c 81 -v
snmpv3 login ./check_snmp_storage.pl -H 127.0.0.1 -l login -x passwd

Unix/Linux

%used of /home is less than 80% and 90%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m /home -w 80% -c 90%

%free of /home is above 10% and 5%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m /home -w 10% -c 5% -T pl

Mb used of /home is less than 800 Mb and 900 Mb

./check_snmp_storage.pl -H 127.0.0.1 -C public -m /home -w 800 -c 900 -T bu

Mb free of /home is above 100Mb and 30Mb

./check_snmp_storage.pl -H 127.0.0.1 -C public -m /home -w 100 -c 30 -T bl

All mountpoints have %used less than 80% and 90%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m / -w 80% -c 90%

%used of / mountpoint only is less than 80% and 90%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m / -r -w 80% -c 90%

%used of mountpoint index 1 only is less than 80% and 90%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m 1 -p -w 80% -c 90%

Swap %used is less than 80% and 90%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m Swap -w 80% -c 90%

Memory %used is less than 80% and 90%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m "Real Memory" -w 80% -c 90%

 

Windows

%used of C is less than 80% and 90%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m ^C: -w 80% -c 90%

%used of C, D and E is less than 80% and 90%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m ^[CDE]: -w 80% -c 90%

%used of C+D+E is less than 80% and 90%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m ^[CDE]: -s -w 80% -c 90%

 

AS/400 specific

Sum of all memory storages is less than 90% and 95%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m RAM -s -w 80% -c 90%

Output of check_snmp_storage.pl -h

SNMP Disk Monitor for Nagios version 1.3.3
(c)2004-2007 Patrick Proy

Usage: check_snmp_storage [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) [-p <port>] -m <name in desc_oid> [-q storagetype] -w <warn_level> -c <crit_level> [-t <timeout>] [-T pl|pu|bl|bu ] [-r -s -i -G] [-e] [-S 0|1[,1,<car>]] [-o <octet_length>] [-R <% reserved>]
By default, plugin will monitor %used on drives :
warn if %used > warn and critical if %used > crit
-v, --verbose
print extra debugging information (and lists all storages)
-h, --help
print this help message
-H, --hostname=HOST
name or IP address of host to check
-C, --community=COMMUNITY NAME
community name for the host's SNMP agent (implies SNMP v1)
-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)
-x, --passwd=PASSWD
Password for snmpv3 authentication
-p, --port=PORT
SNMP port (Default 161)
-m, --name=NAME
Name in description OID (can be mounpoints '/home' or 'Swap Space'...)
This is treated as a regexp : -m /var will match /var , /var/log, /opt/var ...
Test it before, because there are known bugs (ex : trailling /)
No trailing slash for mountpoints !
-q, --storagetype=[Other|Ram|VirtualMemory|FixedDisk|RemovableDisk|FloppyDisk
CompactDisk|RamDisk|FlashMemory|NetworkDisk]
Also check the storage type in addition of the name
It is possible to use regular expressions ( "FixedDisk|FloppyDisk" )
-r, --noregexp
Do not use regexp to match NAME in description OID
-s, --sum
Add all storages that match NAME (used space and total space)
THEN make the tests.
-i, --index
Parse index table instead of description table to select storage
-e, --exclude
Select all storages except the one(s) selected by -m
No action on storage type selection
-T, --type=TYPE
pl : calculate percent left
pu : calculate percent used (Default)
bl : calculate MegaBytes left
bu : calculate MegaBytes used
-w, --warn=INTEGER
percent / MB of disk used to generate WARNING state
you can add the % sign
-c, --critical=INTEGER
percent / MB of disk used to generate CRITICAL state
you can add the % sign
-R, --reserved=INTEGER
% reserved blocks for superuser
For ext2/3 filesystems, it is 5% by default
-G, --gigabyte
output, warning & critical levels in gigabytes
-f, --perfparse
Perfparse compatible output
-S, --short=<type>[,<where>,<cut>]
<type>: Make the output shorter :
0 : only print the global result except the disk in warning or critical
ex: "< 80% : OK"
1 : Don't print all info for every disk
ex : "/ : 66 %used (< 80) : OK"
<where>: (optional) if = 1, put the OK/WARN/CRIT at the beginning
<cut>: take the <n> first caracters or <n> last if n<0
-o, --octetlength=INTEGER
max-size of the SNMP message, usefull in case of Too Long responses.
Be carefull with network filters. Range 484 - 65535, default are
usually 1472,1452,1460 or 1440.
-t, --timeout=INTEGER
timeout for SNMP in seconds (Default: 5)
-V, --version
prints version number
Note :
with T=pu or T=bu : OK < warn < crit
with T=pl ot T=bl : crit < warn < OK

If multiple storage are selected, the worse condition will be returned
i.e if one disk is critical, the return is critical

example :
Browse storage list : <script> -C <community> -H <host> -m <anything> -w 1 -c 2 -v
the -m option allows regexp in perl format :
Test drive C,F,G,H,I on Windows : -m ^[CFGHI]:
Test all mounts containing /var : -m /var
Test all mounts under /var : -m ^/var
Test only /var : -m /var -r
Test all swap spaces : -m ^Swap
Test all but swap spaces : -m ^Swap -e


This project is hosted on :
SourceForge.net Logo

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