#!/bin/bash
# Threshold (in percentage) threshold=80
# disk usage
disk_usage=$(df -h | awk '{ print $5 }' | grep -v Use | sort -n | tail -1 | cut -d'%' - f1)
# Send an email notification if the disk usage exceeds the threshold if [ $disk_usage -ge $threshold ]; then
echo "Disk usage is critical ($disk_usage%)." | mail -s "Disk Usage Alert" gurudatta.nadig@gmail.com
fi
Note: Taken from net
No comments:
Post a Comment