Home   >>   Scripts   >>   Script to Check Free Diskspace Upon SSH Login
Script to Check Free Diskspace Upon SSH Login PDF Print E-mail
( 0 Votes )
How To - Scripts
Written by Christian Foronda   
Tuesday, 05 January 2010 16:38

Script to alert you upon login if your diskspace percentage space is >= 80%.

Edit your .bashrc:

    $ vi ~/.bashrc

Insert this script at the end of the file

    # Check Diskspace
ALERT=80
df -H | grep -vE '^Filesystem' | awk '{ print $5 " " $1 " " $6 }' | while read output;
do
#echo $output
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
mount=$(echo $output | awk '{ print $3 }' )
if [ $usep -ge $ALERT ]; then
echo "Running out of space \"$partition ($usep%)\" on \"$mount\""
fi
done

Save and exit.

 




blog comments powered by Disqus
Last Updated on Wednesday, 06 January 2010 08:54