;;
w|W)
shift
echo "$(date +%Y-%m-%d) $(date +%H:%M:%S)|WARNING|$@" >>$logfile
;;
*)
echo "$(date +%Y-%m-%d) $(date +%H:%M:%S)|DEBUG|$@" >>$logfile
esac
}
#日志处理部分代码
cat $chkfile|egrep -v "^($|#)"|while read i;do
(
app_name=$(echo "$i"|awk -F, '{print $1}')
if test -z "$app_name";then
do_writelog e "应用名称为空,退出执行"
exit 0
fi
log_filename=$(echo "$i"|awk -F, '{print $2}')
if test ! -e "$log_filename";then
do_writelog e "日志文件($log_filename)不存在,退出执行"
exit 0
fi
log_md5sum=$(echo -n "$log_filename"|md5sum|awk '{print $1}')
log_gjz=$(echo "$i"|awk -F, '{print $3}')
if test -z "$log_gjz";then
do_writelog i "日志文件($log_filename),关键字为空,退出执行"
exit 0
fi
log_retry=$(echo "$i"|awk -F, '{print $4}')
expr $log_retry + 0 &>/dev/null
if [ $? -ne 0 ];then
log_retry=0
fi
log_max=$(echo "$i"|awk -F, '{print $5}')
expr $log_max + 0 &>/dev/null
if [ $? -ne 0 ];then
log_max=3
fi
start_command=$(echo "$i"|awk -F, '{print $6}')
stops_command=$(echo "$i"|awk -F, '{print $7}')
open_sendmail=$(echo "$i"|awk -F, '{print $8}')
mail_scripts=$(echo "$i"|awk -F, '{print $9}')
mail_contacts=$(echo "$i"|awk -F, '{print $10}')
if [ $open_sendmail -eq 1 ];then
if test -z "$mail_scripts";then
do_writelog i "应用($app_name),触发动作脚本为空,退出执行"
exit 0
fi
if test -z "$mail_contacts";then
do_writelog i "应用($app_name),联系人为空,退出执行"
exit 0
fi
fi
if test ! -e "$tmpsdir/$log_md5sum";then
log_new_count=$(wc -l $log_filename|awk '{print $1}')
echo "$log_new_count" >$tmpsdir/$log_md5sum