對日志文件中的error進行監控,當日志文件中出現error關鍵字時,就截取日志(grep -i error 不區分大小寫進行搜索"error"關鍵字,但是會將包含error大小寫字符的單詞搜索出來),大家可以去看這編 文章
1)第一類日志
在每天的日志目錄下生產的error日志,此日志文件每天都會自動生成,里面有沒有error日志內容不一定,日志內容寫入不頻繁,日志文件比較小。
舉例說明:
采用sendemail發送告警郵件,sendemail安裝參考:http:
//www
.cnblogs.com
/kevingrace/p/5961861
.html
監控腳本路徑: [root@fk-databus01 ~]# cd /opt/log_error_script/ [root@fk-databus01 log_error_script]# ll total 20 -rw-r--r-- 1 root root 3782 Jun 29 12:13 DEJ_0001_error.log -rwxr-xr-x 1 root root 4274 Jun 29 11:38 prcc_log_error.sh -rwxr-xr-x 1 root root 1142 Feb 13 10:51 sendemail.sh 監控腳本內容 [root@fk-databus01 log_error_script]# cat prcc_log_error.sh #!/bin/sh ERROR_LOG=`/bin/ls /data/log/sedsb/$(date +%Y%m%d)/DEJ_0001_error*` ERROR_NEW_LOG=/opt/log_error_script/DEJ_0001_error.log DATE=`date +%Y年%m月%d日%H時%M分%S秒` HOST=`/bin/hostname` IP=`/sbin/ifconfig|grep "inet addr"|grep "Bcast"|cut -d":" -f2|awk -F" " '{print $1}'` ERROR_MESSAGE=$(/bin/grep -A20 "$(grep "ERROR" $ERROR_LOG|tail -1|awk '{print $1,$2,$3,$4}')" $ERROR_LOG) DIR=/data/log/sedsb/$(date +%Y%m%d) FILE=/data/log/sedsb/$(date +%Y%m%d)/DEJ_0001_error_$(date +%Y%m%d).0.log if [ ! -d $DIR ];then /bin/mkdir $DIR fi if [ ! -f $FILE ];then /bin/touch $FILE fi /bin/chown -R zquser.zquser $DIR sleep 3 if [ ! -f $ERROR_NEW_LOG ];then /bin/touch $ERROR_NEW_LOG fi NUM1=$(/bin/cat $ERROR_LOG|wc -l) NUM2=$(/bin/cat $ERROR_NEW_LOG|wc -l) if [ -f $ERROR_LOG ] && [ $NUM1 -ne 0 ] && [ $NUM2 -eq 0 ];then /bin/bash /opt/log_error_script/sendemail.sh wangshibo@kevin.com "風控系統${HOSTNAME}機器prcc服務日志的error監控" "告警主機:${HOSTNAME} \n告警IP:${IP} \n告警時間:${DATE} \n告警等級:嚴重,抓緊解決啊! \n告警人員:王士博 \n告警詳情:prcc服務日志中出現error了! \n告警日志文件:${ERROR_LOG} \n當前狀態: PROBLEM \n \nerror信息:\n$ERROR_MESSAGE" /bin/cat $ERROR_LOG > $ERROR_NEW_LOG fi /usr/bin/cmp $ERROR_LOG $ERROR_NEW_LOG >/dev/null 2>&1 if [ $? -ne 0 ];then /bin/bash /opt/log_error_script/sendemail.sh wangshibo@kevin.com "風控系統${HOSTNAME}機器prcc服務日志的error監控" "告警主機:${HOSTNAME} \n告警IP:${IP} \n告警時間:${DATE} \n告警等級:嚴重,抓緊解決啊! \n告警人員:王士博 \n告警詳情:prcc服務日志中出現error了! \n告警日志文件:${ERROR_LOG} \n當前狀態: PROBLEM \n \nerror信息:\n$ERROR_MESSAGE" /bin/cat $ERROR_LOG > $ERROR_NEW_LOG fi 結合crontab進行定時監控(每15秒執行一次) [root@fk-databus01 ~]# crontab -l #監控pcrr日志的error * * * * * /bin/bash -x /opt/log_error_script/prcc_log_error.sh >/dev/null 2>&1 * * * * * sleep 15;/bin/bash -x /opt/log_error_script/prcc_log_error.sh >/dev/null 2>&1 * * * * * sleep 30;/bin/bash -x /opt/log_error_script/prcc_log_error.sh >/dev/null 2>&1 * * * * * sleep 45;/bin/bash -x /opt/log_error_script/prcc_log_error.sh >/dev/null 2>&1 ================================================================================== 針對上面腳本中的某些變量說明 [root@fk-databus01 ~]# /bin/ls /data/log/sedsb/$(date +%Y%m%d)/DEJ_0001_error* /data/log/sedsb/20180629/DEJ_0001_error_20180629.0.log [root@fk-databus01 ~]# grep "ERROR" /data/log/sedsb/20180629/DEJ_0001_error_20180629.0.log ERROR DEJ 2018-06-29 12:13:29.191 [pool-4-thread-10] n.s.p.r.thread.OuterCheThdInterface - cx201806291213288440016車300接口異常! ERROR DEJ 2018-06-29 12:13:29.196 [nioEventLoopGroup-3-12] n.s.p.r.c.MessageControllerImpl - cx201806291213288440016: [root@fk-databus01 ~]# grep "ERROR" /data/log/sedsb/20180629/DEJ_0001_error_20180629.0.log |tail -1|awk '{print $1,$2,$3,$4}' ERROR DEJ 2018-06-29 12:13:29.196 [root@fk-databus01 ~]# /bin/grep -A20 "$(grep "ERROR" /data/log/sedsb/20180629/DEJ_0001_error_20180629.0.log |tail -1|awk '{print $1,$2,$3,$4}')" /data/log/sedsb/20180629/DEJ_0001_error_20180629.0.log ERROR DEJ 2018-06-29 12:13:29.196 [nioEventLoopGroup-3-12] n.s.p.r.c.MessageControllerImpl - cx201806291213288440016: net.sinocredit.pre.rcc.utils.exception.OuterDataException: 外部數據:cheFixPrice:mile里程 is null; at net.sinocredit.pre.rcc.datafactory.OuterDataProcess.execute(OuterDataProcess.java:51) at net.sinocredit.pre.rcc.datafactory.OuterDataProcess.execute(OuterDataProcess.java:23) at net.sinocredit.pre.rcc.service.getOtherDataService.MessageServiceImpl.getOrderData(MessageServiceImpl.java:34) at net.sinocredit.pre.rcc.controller.MessageControllerImpl.divMessage(MessageControllerImpl.java:110) at net.sinocredit.pre.rcc.handler.ServerHandler.channelRead(ServerHandler.java:28) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:359) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:351) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:373)
報警郵件效果如下:
2)第二類日志
此日志是固定文件,日志內容寫入頻繁,日志文件比較大。對於此文件的監控,通過采用tail -1000方式獲取日志文件的最新1000行的方式進行error監控!
舉例說明:
[root@fk-zqjcweb01 ~]# ll /data/log/decision/decision.log -rw-rw-r-- 1 zquser zquser 5108 Jun 28 16:02 /data/log/decision/decision.log 采用sendemail發送告警郵件,sendemail安裝參考:http://10.0.8.50/software/sendemail_install.sh 監控腳本路徑: [root@fk-zqjcweb01 ~]# cd /opt/log_error_script/ [root@fk-zqjcweb01 log_error_script]# ls decision sendemail.sh [root@fk-zqjcweb01 log_error_script]# ls decision/ decision.log_diff_error.log decision.log_error.log decision.log_monit.sh 腳本內容: [root@fk-zqjcweb01 log_error_script]# cat decision/decision.log_monit.sh #!/bin/sh ERROR_LOG=/data/log/decision/decision.log ERROR_NEW_LOG=/opt/log_error_script/decision/decision.log_error.log ERROR_DIFF_LOG=/opt/log_error_script/decision/decision.log_diff_error.log DATE=`date +%Y年%m月%d日%H時%M分%S秒` HOST=`/bin/hostname` IP=`/sbin/ifconfig|grep "inet addr"|grep "Bcast"|cut -d":" -f2|awk -F" " '{print $1}'` if [ ! -f $ERROR_NEW_LOG ];then /bin/touch $ERROR_NEW_LOG fi NUM1=$(/usr/bin/tail -1000 $ERROR_LOG|grep error|wc -l) NUM2=$(/bin/cat $ERROR_NEW_LOG|wc -l) if [ -f $ERROR_LOG ] && [ $NUM1 -ne 0 ] && [ $NUM2 -eq 0 ];then /bin/bash /opt/log_error_script/sendemail.sh wangshibo@kevin.com "風控系統${HOSTNAME}機器的decision.log日志中的error監控" "告警主機:${HOSTNAME} \n告警IP:${IP} \n告警時間:${DATE} \n告警等級:嚴重,抓緊解決啊! \n告警人員:王士博 \n告警詳情:decision.log日志中出現error了! \n告警日志文件:${ERROR_LOG} \n當前狀態: PROBLEM " /usr/bin/tail -1000 $ERROR_LOG|grep error > $ERROR_NEW_LOG fi /usr/bin/tail -1000 $ERROR_LOG|grep error > $ERROR_DIFF_LOG /usr/bin/cmp $ERROR_DIFF_LOG $ERROR_NEW_LOG >/dev/null 2>&1 if [ $? -ne 0 ];then /bin/bash /opt/log_error_script/sendemail.sh wangshibo@kevin.com "風控系統${HOSTNAME}機器的decision.log日志中的error監控" "告警主機:${HOSTNAME} \n告警IP:${IP} \n告警時間:${DATE} \n告警等級:嚴重,抓緊解決啊! \n告警人員:王士博 \n告警詳情:decision.log日志中出現error了! \n告警日志文件:${ERROR_LOG} \n當前狀態: PROBLEM " /usr/bin/tail -1000 $ERROR_LOG|grep error > $ERROR_NEW_LOG fi You have new mail in /var/spool/mail/root 結合crontab進行定時監控 [root@fk-zqjcweb01 log_error_script]# crontab -l #decision.log日志的error監控 * * * * * /bin/bash -x /opt/log_error_script/decision/decision.log_monit.sh >/dev/null 2>&1 * * * * * sleep 15;/bin/bash -x /opt/log_error_script/decision/decision.log_monit.sh >/dev/null 2>&1 * * * * * sleep 30;/bin/bash -x /opt/log_error_script/decision/decision.log_monit.sh >/dev/null 2>&1 * * * * * sleep 45;/bin/bash -x /opt/log_error_script/decision/decision.log_monit.sh >/dev/null 2>&1
上面提到的sendemail.sh郵件發送腳本
[root@fk-zqjcweb01 ~]# cat /opt/log_error_script/sendemail.sh #!/bin/bash # Filename: SendEmail.sh # Notes: 使用sendEmail # # 腳本的日志文件 LOGFILE="/tmp/Email.log" :>"$LOGFILE" exec 1>"$LOGFILE" exec 2>&1 SMTP_server='smtp.kevin.com' username='monit@kevin.com' password='monit@123' from_email_address='monit@kevin.com' to_email_address="$1" message_subject_utf8="$2" message_body_utf8="$3" # 轉換郵件標題為GB2312,解決郵件標題含有中文,收到郵件顯示亂碼的問題。 message_subject_gb2312=`iconv -t GB2312 -f UTF-8 << EOF $message_subject_utf8 EOF` [ $? -eq 0 ] && message_subject="$message_subject_gb2312" || message_subject="$message_subject_utf8" # 轉換郵件內容為GB2312,解決收到郵件內容亂碼 message_body_gb2312=`iconv -t GB2312 -f UTF-8 << EOF $message_body_utf8 EOF` [ $? -eq 0 ] && message_body="$message_body_gb2312" || message_body="$message_body_utf8" # 發送郵件 sendEmail='/usr/local/bin/sendEmail' set -x $sendEmail -s "$SMTP_server" -xu "$username" -xp "$password" -f "$from_email_address" -t "$to_email_address" -u "$message_subject" -m "$message_body" -o message-content-type=text -o message-charset=gb2312
3)第三類日志
日志規則說明:
- 在etl服務器下的EXP、MDB、MID、ODB、PDB、PUS、SDB系統里有很多任務日志,日志都存放在當天的日期目錄下。
- 現在需要對這些任務日志的error進行監控,當出現error報錯信息時立刻發出報警!
- 當這些任務日志文件里有出現error報錯信息的,那么該任務日志文件就不會被寫入了。也就是說一個任務日志文件只會出現一次error報錯。
- 出現error報錯信息的任務日志不能刪除和更改,因為這些任務日志會被其他程序調用展示。
[root@bigdata-etl01 ~]# ll /data/etluser/LOG/ drwxrwx--- 33 etluser etluser 4096 Jul 6 02:00 EXP drwxrwx--- 33 etluser etluser 4096 Jul 6 02:00 MDB drwxrwx--- 33 etluser etluser 4096 Jul 6 02:00 MID drwxrwx--- 33 etluser etluser 4096 Jul 6 02:00 ODB drwxrwx--- 33 etluser etluser 4096 Jul 6 02:00 PDB drwxrwx--- 32 etluser etluser 4096 Jul 6 00:47 PUS drwxrwx--- 33 etluser etluser 4096 Jul 6 02:00 SDB [root@bigdata-etl01 ~]# ls /data/etluser/LOG/EXP/ 20180606 20180609 20180612 20180615 20180618 20180621 20180624 20180627 20180630 20180703 20180706 20180607 20180610 20180613 20180616 20180619 20180622 20180625 20180628 20180701 20180704 20180608 20180611 20180614 20180617 20180620 20180623 20180626 20180629 20180702 20180705 [root@bigdata-etl01 ~]# ls /data/etluser/LOG/EXP/20180706/ EXP_EXP_V_CUST_CRDT_SITU_20180705[1][1].54.log exp_v_opr_size_curr_stats_0010601[1].pl.56.log EXP_EXP_V_DAILY_BIZ_AMT_SITU_20180705[1][1].45.log exp_v_opr_size_curr_stats_0010602[1].pl.56.log EXP_EXP_V_MATR_RMND_INTFC_QG6_001_20180705[1][1].83.log exp_v_prvs_provs_int_intfc_f0_0010600[1].pl.103.log EXP_EXP_V_OPR_SIZE_CURR_STATS_001_20180705[1][1].56.log exp_v_prvs_provs_int_intfc_f0_0010601[1].pl.103.log EXP_EXP_V_PRVS_PROVS_INT_INTFC_F0_001_20180705[1][1].103.log exp_v_prvs_provs_int_intfc_f0_0020600[1].pl.98.log EXP_EXP_V_PRVS_PROVS_INT_INTFC_F0_002_20180705[1][1].98.log exp_v_prvs_provs_int_intfc_f0_0020601[1].pl.98.log EXP_EXP_V_PRVS_PROVS_INT_INTFC_F0_003_20180705[1][1].90.log exp_v_prvs_provs_int_intfc_f0_0030600[1].pl.90.log EXP_EXP_V_PRVS_PROVS_INT_INTFC_F0_007_20180705[1][1].48.log exp_v_prvs_provs_int_intfc_f0_0030601[1].pl.90.log EXP_EXP_V_PRVS_PROVS_INT_INTFC_F0_008_20180705[1][1].78.log exp_v_prvs_provs_int_intfc_f0_0070600[1].pl.48.log EXP_EXP_V_PRVS_PROVS_INT_INTFC_F0_009_20180705[1][1].15.log exp_v_prvs_provs_int_intfc_f0_0070601[1].pl.48.log EXP_EXP_V_PRVS_PROVS_INT_INTFC_F0_010_20180705[1][1].48.log exp_v_prvs_provs_int_intfc_f0_0080600[1].pl.78.log EXP_EXP_V_PRVS_PROVS_INT_INTFC_F1_004_20180705[1][1].16.log exp_v_prvs_provs_int_intfc_f0_0080601[1].pl.78.log EXP_EXP_V_PRVS_PROVS_INT_INTFC_F1_006_20180705[1][1].8.log exp_v_prvs_provs_int_intfc_f0_0090600[1].pl.15.log EXP_EXP_V_QRY_FACT_AGT_INTFC_20180705[1][1].47.log exp_v_prvs_provs_int_intfc_f0_0090601[1].pl.15.log exp_v_cust_crdt_situ0600[1].pl.54.log exp_v_prvs_provs_int_intfc_f0_0100600[1].pl.48.log exp_v_cust_crdt_situ0601[1].pl.54.log exp_v_prvs_provs_int_intfc_f0_0100601[1].pl.48.log exp_v_cust_crdt_situ0602[1].pl.54.log exp_v_prvs_provs_int_intfc_f1_0040600[1].pl.16.log exp_v_daily_biz_amt_situ0600[1].pl.45.log exp_v_prvs_provs_int_intfc_f1_0040601[1].pl.16.log exp_v_daily_biz_amt_situ0601[1].pl.45.log exp_v_prvs_provs_int_intfc_f1_0060600[1].pl.8.log exp_v_daily_biz_amt_situ0602[1].pl.45.log exp_v_prvs_provs_int_intfc_f1_0060601[1].pl.8.log exp_v_matr_rmnd_intfc_qg6_0010600[1].pl.83.log exp_v_qry_fact_agt_intfc0600[1].pl.47.log exp_v_matr_rmnd_intfc_qg6_0010601[1].pl.83.log exp_v_qry_fact_agt_intfc0601[1].pl.47.log exp_v_matr_rmnd_intfc_qg6_0010602[1].pl.83.log exp_v_qry_fact_agt_intfc0602[1].pl.47.log exp_v_opr_size_curr_stats_0010600[1].pl.56.log監控腳本思路:
1)對這些任務日志進行批量搜索error關鍵字(不區分大小寫)
2)將出現error關鍵字的任務日志拷貝到一個專門的目錄下(error日志文件的列表目錄)。
3)對搜索到error關鍵字的任務日志做判斷,判斷它是否存在於那個列表目錄下:
如果不存在,說明是新出現error的日志文件,就立刻報警!
如果存在,說明出現的error是之前的信息,不報警!
監控腳本編寫情況如下:
error_log為error日志文件的列表目錄;
sendemail.sh為郵件發送腳本(上面介紹過)
[root@bigdata-etl01 log_error_script]
# ls
EXP MDB MID ODB PDB PUS SDB sendemail.sh
[root@bigdata-etl01 log_error_script]
# ls EXP/
error_log EXP_error_monit.sh
[root@bigdata-etl01 log_error_script]
# ls MDB/
error_log MDB_error_monit.sh
[root@bigdata-etl01 log_error_script]
# ls MID/
error_log MID_error_monit.sh
[root@bigdata-etl01 log_error_script]
# ls ODB/
error_log ODB_error_monit.sh
[root@bigdata-etl01 log_error_script]
# ls PDB/
error_log PDB_error_monit.sh
[root@bigdata-etl01 log_error_script]
# ls PUS/
error_log PUS_error_monit.sh
[root@bigdata-etl01 log_error_script]
# ls SDB/
error_log SDB_error_monit.sh
[root@bigdata-etl01 log_error_script]
#
這里貼出SDB系統的任務日志的error監控報警腳本(其他幾個系統的監控腳本與這個一樣,只需要將腳本中的SDB替換成對應的系統名稱即可!)
[root@bigdata-etl01 log_error_script]
# cat /opt/log_error_script/SDB/SDB_error_monit.sh
#!/bin/sh
DATE_DIR=$(
date
+%Y%m%d)
DATE=`
date
+%Y年%m月%d日%H時%M分%S秒`
HOST=`
/bin/hostname
`
IP=`
/sbin/ifconfig
|
grep
"inet addr"
|
grep
"Bcast"
|
cut
-d
":"
-f2|
awk
-F
" "
'{print $1}'
`
cd
/data/etluser/LOG/SDB
if
[ ! -d $DATE_DIR ];
then
/bin/mkdir
$DATE_DIR
/bin/chown
-R etluser.etluser $DATE_DIR
fi
cd
/data/etluser/LOG/SDB/
$DATE_DIR
for
FILE
in
$(
/bin/ls
*.log)
do
NUM=$(
/bin/grep
-i
"error"
/data/etluser/LOG/SDB/
$DATE_DIR/$FILE|
wc
-l)
ERROR_MESSAGE=$(
/bin/grep
-i
"error"
/data/etluser/LOG/SDB/
$DATE_DIR/$FILE)
if
[ $NUM -
ne
0 ];
then
/bin/ls
/opt/log_error_script/SDB/error_log/
$FILE
a=$?
if
[ $a -
ne
0 ];
then
/opt/log_error_script/sendemail
.sh wangshibo@
test
.com
"大數據平台etl服務器${HOSTNAME}的SDB任務日志里出現error了"
"告警主機:${HOSTNAME} \n告警IP:${IP} \n告警時間:${DATE} \n告警等級:嚴重 \n告警人員:王士博 \n告警詳情:SDB的任務日志里出現error了,抓緊解決啊! \n當前狀態: PROBLEM \n告警日志文件:/data/etluser/LOG/SDB/$DATE_DIR/$FILE \n\n\n------請看下面error報錯信息------- \nerror信息:\n$ERROR_MESSAGE"
cp
/data/etluser/LOG/SDB/
$DATE_DIR/$FILE
/opt/log_error_script/SDB/error_log/
else
echo
"$FILE日志中error報錯信息是之前發生的,無需報警!"
fi
else
echo
"$FILE 日志里沒有error報錯啦"
fi
done
給腳本賦予執行權限
[root@bigdata-etl01 log_error_script]
# chmod 755 /opt/log_error_script/SDB/SDB_error_monit.sh
[root@bigdata-etl01 log_error_script]
# sh /opt/log_error_script/SDB/SDB_error_monit.sh
qbl_biz_cst_bsc_inf0100[1].pl.73.log 日志里沒有error報錯啦
qbl_biz_cst_bsc_inf0101[1].pl.73.log 日志里沒有error報錯啦
qbl_biz_fnc_bsc_inf0100[1].pl.73.log 日志里沒有error報錯啦
qbl_biz_fnc_bsc_inf0101[1].pl.73.log 日志里沒有error報錯啦
qbl_biz_fnc_mod_inf0100[1].pl.73.log 日志里沒有error報錯啦
qbl_biz_fnc_mod_inf0101[1].pl.73.log 日志里沒有error報錯啦
qbl_biz_pd_bsc_inf0100[1].pl.73.log 日志里沒有error報錯啦
qbl_biz_pd_bsc_inf0101[1].pl.73.log 日志里沒有error報錯啦
qbl_biz_pre_ctr_bsc_inf0100[1].pl.73.log 日志里沒有error報錯啦
qbl_biz_pre_ctr_bsc_inf0101[1].pl.73.log 日志里沒有error報錯啦
qbl_biz_repy_base_inf0100[1].pl.73.log 日志里沒有error報錯啦
qbl_biz_repy_base_inf0101[1].pl.73.log 日志里沒有error報錯啦
qbl_biz_repy_pl_dtl0100[1].pl.78.log 日志里沒有error報錯啦
qbl_biz_repy_pl_dtl0101[1].pl.78.log 日志里沒有error報錯啦
qbl_biz_repy_pl_inf0100[1].pl.78.log 日志里沒有error報錯啦
qbl_biz_repy_pl_inf0101[1].pl.78.log 日志里沒有error報錯啦
qbl_biz_repy_rcrd_jrnl0100[1].pl.73.log 日志里沒有error報錯啦
qbl_biz_repy_rcrd_jrnl0101[1].pl.73.log 日志里沒有error報錯啦
.......
.......
結合
crontab
指定腳本定時執行任務(每30秒執行一次)
[root@bigdata-etl01 ~]
# crontab -l
#etl相關任務日志的error監控報警
* * * * *
/bin/bash
-x
/opt/log_error_script/EXP/EXP_error_monit
.sh >
/dev/null
2>&1
* * * * *
sleep
30;
/bin/bash
-x
/opt/log_error_script/EXP/EXP_error_monit
.sh >
/dev/null
2>&1
* * * * *
/bin/bash
-x
/opt/log_error_script/MDB/MDB_error_monit
.sh >
/dev/null
2>&1
* * * * *
sleep
30;
/bin/bash
-x
/opt/log_error_script/MDB/MDB_error_monit
.sh >
/dev/null
2>&1
* * * * *
/bin/bash
-x
/opt/log_error_script/MID/MID_error_monit
.sh >
/dev/null
2>&1
* * * * *
sleep
30;
/bin/bash
-x
/opt/log_error_script/MID/MID_error_monit
.sh >
/dev/null
2>&1
* * * * *
/bin/bash
-x
/opt/log_error_script/ODB/ODB_error_monit
.sh >
/dev/null
2>&1
* * * * *
sleep
30;
/bin/bash
-x
/opt/log_error_script/ODB/ODB_error_monit
.sh >
/dev/null
2>&1
* * * * *
/bin/bash
-x
/opt/log_error_script/PDB/PDB_error_monit
.sh >
/dev/null
2>&1
* * * * *
sleep
30;
/bin/bash
-x
/opt/log_error_script/PDB/PDB_error_monit
.sh >
/dev/null
2>&1
* * * * *
/bin/bash
-x
/opt/log_error_script/PUS/PUS_error_monit
.sh >
/dev/null
2>&1
* * * * *
sleep
30;
/bin/bash
-x
/opt/log_error_script/PUS/PUS_error_monit
.sh >
/dev/null
2>&1
* * * * *
/bin/bash
-x
/opt/log_error_script/SDB/SDB_error_monit
.sh >
/dev/null
2>&1
* * * * *
sleep
30;
/bin/bash
-x
/opt/log_error_script/SDB/SDB_error_monit
.sh >
/dev/null
2>&1
郵件報警效果如下: