#!/bin/bash #script d'envoi de mail en cas d'espace disque insuffisant email="votre@email.com" system=`hostname` for line in `df -aPh | grep "^/" | grep \% | sort | awk '{print$6"-"$5"-"$4}'`; do percent=`echo "$line" | awk -F - '{print$2}' | cut -d % -f 1` partition=`echo "$line" | awk -F - '{print$1}' | cut -d % -f 1` limit=90 if [$partition == '/cdrom']; then limit=101 fi if [$percent -ge $limit]; then echo "Alerte Espace Disque sur $system !! `df -h `" | mail -s "Alerte Espace Disque sur $system - La partition $partition atteint $percent %" $email fi done