shell监控mysql慢查询日志并推送到钉钉

filestatus=`cat /data/mysql_db/slow.log |wc -l`
if [ $filestatus != 0 ]
then
        cat /data/mysql_db/slow.log|grep -B 2 -E 'SELECT|DELETE|UPDATE|SAVE' > /data/mysql_db/slow.log.bak
        > /data/mysql_db/slow.log
        filecontent=''
        while read line
        do
           filecontent=$filecontent"\n"$line
        done < /data/mysql_db/slow.log.bak

        echo $filecontent
        curl 'https://oapi.dingtalk.com/robot/send?access_token=' -H 'Content-Type: application/json' -d '{"msgtype": "text","text": {"content": "IP:xxx.xxx.xx.xx\n'"$filecontent"'"}}'
        #`> /data/mysql_db/slow.log`
fi

赤狐博客 - 对于互联网行业的胡诌八扯
请先登录后发表评论
  • 最新评论
  • 总共0条评论