Script d’alerte d’occupation disque

mardi 15 juin 2010, par Minimalteck

#!/bin/sh
MAIL_ADDRESS="adminsys@domain.tld"
HOST=`hostname`
LIMIT=85
COUNT=0
df -Ph | awk '{ print $5 " used for " $6 " (" $3 "/" $4 ")" }' | while read LINE;
        do       
                #drop the first line of the df output command               
                COUNT=`expr ${COUNT} + 1`;
                if [ ${COUNT} -eq 1 ]
                then
                         continue;
                fi
                USED=`echo ${LINE} | awk '{print $1}' | sed -e 's/%//'`;
                HOST=`hostname`;
                if [ "${USED}" -ge "${LIMIT}" ]
                then
                        echo "${LINE}" | mail -s "Disk Usage Alert on ${HOST}" ${MAIL_ADDRESS};
                fi
        done;
exit 0;
SPIP | squelette | | Plan du site | Suivre la vie du site RSS 2.0