Created
March 20, 2019 13:28
-
-
Save mkerstner/01b9ea31aa33d037c79f2c82ab8a6b14 to your computer and use it in GitHub Desktop.
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 | |
# | |
# Simple script to determine the disk usage in percent for a given source path. | |
# Optionally uses disk usage to run additional web service call for further | |
# processing. | |
# Specify the minimum usage percentage to trigger the alert. | |
# | |
# @version 1.0.0 | |
# @author Matthias Kerstner <matthias@kerstner.at> | |
############################################################################### | |
# percentage when to trigger alert | |
TRIGGER_PERCENTAGE=80 | |
# path to check for usage | |
SRC_PATH=/some/path | |
# disk usage in percent | |
DISK_USAGE=`df -hP $SRC_PATH | awk '{print $5}' | tail -1 | sed 's/%$//g'` | |
# web service url to additionally handle disk usage | |
WEB_URL=https://www.yourdome.com/handle-disk-usage-alert?usage=$DISK_USAGE | |
#echo "Usage: "$DISK_USAGE"%" | |
if [ $DISK_USAGE > $TRIGGER_PERCENTAGE ]; then | |
curl -s -o /dev/null -v $WEB_URL | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment