Devops: Send Alerts when Your Server HDD Usage is above Threshold

in blog •  2 months ago 

image.png

#!/bin/bash

usage=`df -h / | tail -1 | awk '{print $5}'`
usage=${usage%?}

threshold=80

if [[ $usage -gt $threshold ]]; then
    echo "Diskspace: $usage% Exceeding $threshold%"
    ## send email "Your Server $(echo $HOSTNAME) Diskspace: $usage% Exceeding $threshold% $(date)"
    exit 1
else
    echo "Diskspace: $usage%"
    exit 0
fi

Put it in Crontab and schedule it run daily.

See this post

Steem to the Moon🚀!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE BLURT!