2 ################################################################################
4 # File: $RCSfile: diskspace,v $
5 # Revision: $Revision: 1.2 $
6 # Description: Check filesystems to see if they are becoming too full
7 # Author: Andrew@DeFaria.com
8 # Created: Fri Mar 12 10:17:44 PST 2004
9 # Modified: $Date: 2010/06/08 15:03:27 $
12 # (c) Copyright 2005, ClearSCM, Inc., all rights reserved
14 ################################################################################
20 use lib "$FindBin::Bin/../lib";
29 display "ERROR: $msg\n" if defined $msg;
31 display "diskspace\t[-v] [-d] [-u] [ -t <threshold> ]";
32 display "\t-v\tTurn on verbose mode";
33 display "\t-d\tTurn on debug mode";
34 display "\t-u\tThis usage message";
35 display "\t-t\tThreshold (0-100)";
40 sub CheckLocalFilesystems {
41 my @local_filesystems = `df -lP`;
43 @local_filesystems = grep {/^\/dev/} @local_filesystems;
45 foreach (@local_filesystems) {
46 my ($fs, $blocks, $used, $available, $used_percent, $mounted_on) = split;
48 if ($used_percent =~ /(\d+)%/) {
52 $available = sprintf ("%.3f", $available / 1024);
54 # Check if over threshold and report
55 if ($used_percent <= $threshold ) {
56 verbose "$mounted_on is $used_percent% full - $available Megs left";
58 warning "$mounted_on is $used_percent% full - $available Megs left";
61 } # CheckLocalFilesystems
65 if ($ARGV [0] eq "-v") {
67 } elsif ($ARGV [0] eq "-d") {
69 } elsif ($ARGV [0] eq "-t") {
72 Usage "Must specify threshold after -t";
74 $threshold = $ARGV [0];
76 } elsif ($ARGV [0] eq "-u") {
79 Usage "Unknown argument found: " . $ARGV [0];
85 verbose "Theshold: $threshold\%";
86 CheckLocalFilesystems;