Linux Shell Script
當硬碟使用空間大於90%時就發出E-mail通知信
#!/bin/bash
df -h | grep -vE '^Filesystem' | awk '{ print $5 " " $6 }' | while read output
do
usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $usep -ge 90 ]; then
echo "Running out of space "$partition $usep%" on $(hostname) as on $(date)" | mail -s "Alert: Almost out of disk space $usep%" root
fi
done
再搭配Crontab就可以做出自動偵測.
沒有留言:
張貼留言