shell脚本关键字 linux 监控新增关键字,Shell脚本实战:日志关键字监控+自动告警

11/27 22:11:04 来源网站:辅助卡盟网

;;

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

shell脚本关键字_shell脚本实例_shell脚本执行db2脚本

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

shell脚本关键字_shell脚本执行db2脚本_shell脚本实例

if test ! -e "$tmpsdir/$log_md5sum";then

log_new_count=$(wc -l $log_filename|awk '{print $1}')

echo "$log_new_count" >$tmpsdir/$log_md5sum

    暂无相关资讯
shell脚本关键字 linux 监控新增关键字,Shell脚本实战:日志关键字监控+自动告警