http://blog.chinaunix.net/u/20483/showart_625936.html#! /bin/bash
LOG_PATH=/home/logs
ALERT_SIZE=100000k
TMP_FILE=/tmp/log_detail
TOMAIL=’log@bbc.com’
IPADDR=`ifconfig | grep -E ‘Link encap’\|’inet addr’ | awk ‘{if (NR%2==0){print $0} else {printf”%s “,$0}}’ | grep -v lo | awk ‘BEGIN{ORS=” “}{print $1 ” ” $7}’`
SUBJ=’Stat log size exceed ‘$ALERT_SIZE’ at ‘$IPADDR;
find $LOG_PATH -type f -name “*.log*” -size +$ALERT_SIZE -exec du -hs {} \; > $TMP_FILE
CHK_LINE=`cat $TMP_FILE | wc -l`
if [ $CHK_LINE -gt 0 ]
then
(echo -e $SUBJ “\n”; cat $TMP_FILE) | mail -s”$SUBJ” $TOMAIL
fi
cat /dev/null > $TMP_FILE
阅读(1056) | 评论(0) | 转发(0) |