0: #!/usr/bin/perl
1: #
2: # Sorry for the simplicity of this script, but as a first submission...
3: #
4: # Emails/Pages me when a filesystem > 90% full
5:
6: $df=`df -lk 2>/dev/null`;
7: $fs=`df -lk 2>/dev/null | grep -v used | cut -d'%' -f2 | grep -v denied`;
8: $full=`df -lk 2>/dev/null | grep -v used | cut -d'%' -f1`;
9:
10: $full =~ s/.*(..\d)$/\1/mg;
11:
12: $fs=~s/\s+/ /g;
13: $full=~s/\s+/ /g;
14:
15: @fs=split(" ",$fs);
16: @full=split(" ",$full);
17: $host=`hostname`;
18: chomp($host);
19: $fs=@fs;
20: chomp($date);
21: while ($fs)
22: {$fs=shift(@fs);
23: $full=shift(@full);
24: chomp($fs);
25: chomp($full);
26: if ($full > 90)
27: {print "Host: $host Filesystem: $fs is ${full}% full!\n";
28: @chk=grep(/$fs:$full/,@log);
29: undef(@log);
30: $chk=@chk;
31: close(LOG);
32: if ($chk == 0)
33: {`mailx -s "$host:$fs is ${full}%" youremail\@host.com <<EOF
34: $df
35: EOF
36: `;
37: `mailx -s "$host:$fs is ${full}%" mypager\@pagerhost.com <<EOF
38:
39: EOF
40: `;
41: }
42: }
43: }
44:
In reply to Full Filesystem Notification by prodevel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |