Skip to content

Instantly share code, notes, and snippets.

@fibergames
Last active August 9, 2017 16:51
Show Gist options
  • Save fibergames/1d1f6ded422b233838ac8e59e55d55aa to your computer and use it in GitHub Desktop.
Save fibergames/1d1f6ded422b233838ac8e59e55d55aa to your computer and use it in GitHub Desktop.
Solaris 5.10 Diskspace checker updated from nixcraft.
#Original script here: https://www.cyberciti.biz/tips/shell-script-to-watch-the-disk-space.html
#Updated for Solaris 10 by Loranth Moroz
#!/usr/bin/bash
df -h | egrep -v '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
echo $output
usep=$(echo $output |grep -v 'capacity'| awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge 80 ]; then
echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)"|
mailx -s "Alert: Almost out of disk space $usep%" you@somewhere.com
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment