1 #!/usr/bin/perl -w
2 # File: unix_fs.pl
3 # Author: Tom Large - tlarge@thelug.org
4 # Location: http://www.thelug.org/docs/
5 # Description: Send email notification if any slice
6 # at less than 1 GB free space.
7
8 $counter = 0;
9
10 # Note: the df command has varying options across Unix flavors.
11 # This particular script was written for Linux. Try '-b' for Solaris.
12 system ("df > /tmp/freespace");
13
14 open(SPACEFILE ,"/tmp/freespace" );
15 @spacefile = <SPACEFILE>;
16 close( SPACEFILE );
17
18 foreach $spacefile ( @spacefile)
19 {
20 chomp $spacefile;
21 if ($spacefile =~ (/^\S+\s+\d+\s+\d+\s+(\d+)/))
22 {
23 if ($1 < 10000000)
24 {
25 $counter++;
26 @offenders = (@offenders,"$spacefile");
27 }
28 }
29 }
30
31 foreach $offenders (@offenders)
32 {
33 print "$offenders\n";
34 }
syntax highlighted by Code2HTML, v. 0.9.1