Skip to content

Instantly share code, notes, and snippets.

@luckyshot
Created February 21, 2018 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luckyshot/a9bfa4f450c4bdd3238dee8817f36e0b to your computer and use it in GitHub Desktop.
Save luckyshot/a9bfa4f450c4bdd3238dee8817f36e0b to your computer and use it in GitHub Desktop.
Check Disk Space through SHELL script (cronjob) and send an HTTP request when it reaches the limit
#!/bin/bash
# Check Disk Space and send an HTTP request when it reaches the limit
# Once used space is higher than this limit, the webhook will be triggered (in percentage)
LIMIT='80'
# Stores the percentage of used space
USED=`df . | awk '{print $5}' | sed -ne 2p | cut -d"%" -f1`
# Webhook URL
RVMHTTP='https://example.com/webhook.php'
if [ $USED -gt $LIMIT ]
then
curl -X GET -G ${RVMHTTP} \
-d "usage=${USED}"
fi
# Outputs the used space %
echo $USED
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment