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