Skip to content

Instantly share code, notes, and snippets.

@fmal
Last active September 24, 2019 09:11
Show Gist options
  • Save fmal/848ba30ebf548d8a2f611e83ad3b89e6 to your computer and use it in GitHub Desktop.
Save fmal/848ba30ebf548d8a2f611e83ad3b89e6 to your computer and use it in GitHub Desktop.
#!/bin/sh
# alert level in percent
ALERT=90
TEAMS_WEBHOOK_URL="https://outlook.office.com/<webhook>"
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | grep "/dev/[a-z][a-z][a-z][0-9]\|:" | while read output;
do
#echo $output
usepercent=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
filesystem=$(echo $output | awk '{ print $2 }' )
if [ $usepercent -ge $ALERT ]; then
curl -H 'Content-type: application/json' -d '{"text":"Running out of space '"$filesystem ($usepercent%)"' on server '"$(hostname)"'"}' $TEAMS_WEBHOOK_URL
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment