Last active
November 26, 2023 03:41
-
-
Save deviationist/19fcd102c537491a0278712918806f3d to your computer and use it in GitHub Desktop.
Disk usage monitor for a single disk that posts to Slack if the usage percent surpasses a configurable threshold.
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 | |
| PERCENT_THRESHOLD=95 | |
| DISK_NAME=/dev/sda1 | |
| DISK_PERCENTAGE=$(df -hl $DISK_NAME | sed 1d | awk 'BEGIN{print "Use%"} {percent+=$5;} END{print percent}' | column -t | sed 1d); | |
| if (( $PERCENT_THRESHOLD <= $DISK_PERCENTAGE )); then | |
| curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"Disk is almost full - $DISK_PERCENTAGE% used on $DISK_NAME. Threshold set to $PERCENT_THRESHOLD%.\"}" https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXXX | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.