Skip to content

Instantly share code, notes, and snippets.

@mick-shaw
Created September 10, 2015 13:57
Show Gist options
  • Select an option

  • Save mick-shaw/c1d87f18d73e30ff86e3 to your computer and use it in GitHub Desktop.

Select an option

Save mick-shaw/c1d87f18d73e30ff86e3 to your computer and use it in GitHub Desktop.
#!/bin/bash
# set recipient Address
ADMIN="recipient@mail.com"
# set alert-level to 90%
ALERT=10
df -P | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $6 }' | while read output;
do
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge $ALERT ]; then
/usr/sbin/sendmail "$ADMIN" <<EOF
From: sender@mail.com
Subject: Storage Alert ($usep% Utilization)
All Concerned,
The $partition partition on $HOSTNAME has reached $usep% at $(date).
EOF
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment