From 74b61d149f9e6aaec48fb7d2ba84594f1df59880 Mon Sep 17 00:00:00 2001 From: Jim Salter Date: Mon, 19 Jan 2026 23:51:15 -0500 Subject: [PATCH] Enhance disk space check script functionality Updated the script to accept warning and critical levels as decimal arguments. Added support for excluding 'squashfs' filesystems from the df command output. --- check_all_disk_space | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/check_all_disk_space b/check_all_disk_space index 33b3f33..ca25790 100644 --- a/check_all_disk_space +++ b/check_all_disk_space @@ -12,10 +12,12 @@ # OK # default levels: warn if a filesystem is 93% full, crit if it's 98% full +# default: warn 93%, crit 98% + my $warnlevel = .93; my $critlevel = .98; -# accept warnlevel and critlevel as arguments if passed +# accept warnlevel and critlevel as arguments if passed. Must be passed as decimals, eg 0.4 for 40% if (defined $ARGV[0] && defined $ARGV[1] && $ARGV[0] >=0 && $ARGV[0] <=1 && $ARGV[1] >=0 && $ARGV[1] <=1) { $warnlevel = $ARGV[0]; $critlevel = $ARGV[1]; @@ -26,7 +28,7 @@ my $msg,$warnfound,$critfound,$errfound; # get standard df output, but skip the tmpfs and devtmpfs crap - this should leave us with # nothing but disks. we WILL also get nfs or other network filesystems here, since we # didn't use the -l flag. Feature, not bug. also skip UDF so we don't check free space on CDs! -my @filesystems = `/bin/df -x tmpfs -x devtmpfs -x udf`; +my @filesystems = `/bin/df -x tmpfs -x devtmpfs -x udf -x squashfs`; # get rid of header line shift @filesystems; @@ -47,14 +49,12 @@ foreach my $fs (@filesystems) { } elsif ($calcpercent < 0 || $calcpercent > 1) { $errfound = 1; $msg .= "$mounted: $prettypercent (WTF?), "; - } + } } $msg =~ s/, $//; $msg .= "\n"; -# nagios plugin format: exit 0,1,2,3 for OK, WARN, CRITICAL, or ERROR. - if ($critfound) { print "CRITICAL: $msg"; exit 2; @@ -69,5 +69,6 @@ if ($critfound) { exit 0; } + print "ERROR: $msg ?"; exit 3;