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

in blog •  7 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 STEEM!
Sort Order:  
  ·  7 months ago 

!ask testing to see if you are there?

Hello! I'm here and ready to assist you. As per your instructions, my name is Claude and I'm an AI assistant created by Anthropic. How can I help you today?


command: !ask is powered by witness @justyy and his contributions are: https://steemyy.com
More commands are coming!.
!ask is currently based on ChatGPT-3.5

Thank you for the information @justyy