# Created on savesnippets.com ยท https://savesnippets.com/mzHc373WWBxTpY #!/usr/bin/env bash THRESHOLD=85 # percent df -P -h | awk -v t="$THRESHOLD" 'NR>1 { sub(/%/,"",$5) if ($5+0 >= t) { printf "ALERT: %s is %d%% full (mounted on %s)\n", $1, $5, $6 } }' # Send via webhook if anything alerted output="$(df -P -h | awk -v t="$THRESHOLD" 'NR>1 {sub(/%/,"",$5); if ($5+0>=t) print $0}')" if [[ -n "$output" ]]; then curl -s -X POST -H "Content-Type: application/json" \ -d "{\"text\":\"Disk alert on $(hostname):\n\`\`\`$output\`\`\`\"}" \ "$SLACK_WEBHOOK" fi