Сам файлик check_freespace.sh
chmod +x check_freespace.sh
#!/bin/sh # set -x # Shell script to monitor or watch the disk space # It will send an email to $to, if the (free available) percentage of space is >= 90%. # ------------------------------------------------------------------------- # Set admin email so that you can get email. to="support@server" # set alarm level 90% used is default alarm=90 used_space=$(df -h | awk '{ print $5 }' | sort -n | tail -1 | cut -d'%' -f1) if [ "$used_space" -ge "$alarm" ]; then echo "Alert: $(date) заканчивается место на сервер $(hostname) ЗАНЯТО $used_space%" | mail -v -s "Alert: $(hostname)" -S smtp="mail.server" -S smtp-use-starttls -S smtp-auth=login -S smtp-auth-user=noreply@mail.server -S smtp-auth-password=strongpass -S ssl-verify=ignore -S nss-config-dir=/etc/pki/nssdb -S from=noreply@mail.server $to
crontab -e
0,5,10,15,20,25,30,35,40,45,50,55 8-20 * * * /root/scripts/check_freespace.sh