in reply to RE: Full Filesystem Notification
in thread Full Filesystem Notification

Thanks very much, Shendal! Much appreciated. Actually, I probably should have gone over the code before submitting. FYI here's another version in pure ksh I wrote for a Oracle DBA friend of mine that didn't want to install Perl if you're interested. Bit more condensed.

Hope I don't get into any trouble for posting shell! =)

#!/usr/bin/ksh

pct=90
x=0

for filesys in `df -k | awk '{print $1}'`
do
 x=`expr $x + 1`
 dfline=`df -k | head -$x | tail -1`
 full=`echo $dfline | awk '{print $5}' | sed 's/%//g' | egrep -v capacity`

 if $full -gt pct
 then
 mailx -s "Filesystem: $filesys is ${full}% full!!!" mail@mailhost.com <<EOF
 $dfline
EOF
 mailx -s "Filesystem: $filesys is ${full}% full!!!" pager@pagerhost.com <<EOF
 $dfline
EOF

 fi
done

Replies are listed 'Best First'.
Whoops - here's the script
by prodevel (Scribe) on Jun 30, 2000 at 23:46 UTC
    #!/usr/bin/ksh x=0 for filesys in `df -k | awk '{print $1}'` do x=`expr $x + 1` dfline=`df -k | head -$x | tail -1` full=`echo $dfline | awk '{print $5}' | sed 's/%//g' | egrep -v capacity` if $full -gt 76 then mailx -s "Filesystem: $filesys is ${full}% full!!!" pager@pagerhost.com <<EOF $dfline EOF fi done