2 # $Id: filesize.pl 230 2006-09-30 20:11:05Z touche $
3 # julien.touche@touche.fr.st
5 # Added use strict, warning, treshold for min size
7 # from http://www.nagiosexchange.org/NRPE_Plugins.66.0.html?&tx_netnagext_pi1[p_view]=81
8 #################################################
9 # Small quick and dirty perl example from Larry #
10 #################################################
11 # downloaded from http://exchange.nagios.org/directory/Plugins/System-Metrics/File-System/filesize-2Epl/details
16 if($#ARGV+1!=3 || ! -f $ARGV[0]){
17 print "Usage: \"Filename\" \"Critical filesize\" \"Warning filesize\"\n";
18 print " exemples: $0 <file> 1024 512\n";
19 print " exemples: $0 <file> 16:1024 128:512\n";
23 my ($file,$maxwarn,$maxcrit,$minwarn,$mincrit);
26 if ($maxcrit =~ m/([0-9].+):([0-9].+)/) {
31 if ($maxwarn =~ m/([0-9].+):([0-9].+)/) {
39 print "Critical: Filesize of '$file' too large $size > $maxcrit.\n";$exit=2;
40 } elsif (defined($mincrit) && $size < $mincrit) {
41 print "Critical: Filesize of '$file' too small $size < $mincrit.\n";$exit=2;
42 } elsif ($size>$maxwarn) {
43 print "Warning: Filesize of '$file' $size > $maxwarn.\n";$exit=1;
44 } elsif (defined($minwarn) && $size < $minwarn) {
45 print "Warning: Filesize of '$file' $size < $minwarn.\n";$exit=1;
47 print "OK: Filesize of '$file' $size.\n"; $exit = 0;