Created
February 21, 2018 13:25
-
-
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
This file contains 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 | |
# 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