Created
May 18, 2018 06:09
-
-
Save fraszczakszymon/5d8250848dd6af13d88544942133cf20 to your computer and use it in GitHub Desktop.
Disk monitor with slack notification
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/bash | |
MAX=90 | |
WEBHOOK="https://slack-incomming-webhook-url" | |
PART="/dev/xvda1" | |
MACHINE_NAME="hostname" | |
USE=`df -h | grep $PART | awk '{ print $5 }' | cut -d'%' -f1` | |
if [ $USE -gt $MAX ]; then | |
curl -X POST -H 'Content-type: application/json' \ | |
--data '{"text":"<!channel|channel> Machine *'$MACHINE_NAME'* is running out of disk space (usage: '$USE'%)"}' \ | |
$WEBHOOK | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment