java日志报错邮件报警shell脚本

#!/bin/bash
#by fuqiang
#2018-09-05

Date=$(date +"%Y.%m.%d")

source /etc/profile
cd /home/sh/
scp [email protected]:/mnt/log/cemserver/cemserver.es /home/sh/

curl http://10.1.6.9:9200/yt_java_webserver_log-$Date/_search > /home/sh/getlog.log

count=`grep -o ERROR getlog.log | wc -l`

echo $count
echo $COUNT

if [ $count -gt $COUNT ];then 
    sendEmail -f [email protected] -t [email protected] -s smtp.exmail.qq.com -u 'java-error' -xu [email protected] -xp Harryxxx -m 'java-error' -a /home/sh/getlog.log -a /home/sh/cemserver.es
     echo "it's ERROR!"
fi

sed -i '$d' /etc/profile

echo "export COUNT=$count" >> /etc/profile

source /etc/profile

rm -rf /home/sh/cemserver.es

猜你喜欢

转载自blog.csdn.net/kevinsingapore/article/details/82458764