Skip to content

Instantly share code, notes, and snippets.

@fraszczakszymon
Created May 18, 2018 06:09
Show Gist options
  • Save fraszczakszymon/5d8250848dd6af13d88544942133cf20 to your computer and use it in GitHub Desktop.
Save fraszczakszymon/5d8250848dd6af13d88544942133cf20 to your computer and use it in GitHub Desktop.
Disk monitor with slack notification
#!/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