Last active
September 24, 2019 09:11
-
-
Save fmal/848ba30ebf548d8a2f611e83ad3b89e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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