Extract MySQL error level logs and automatically report police content on mail

Source: Internet
Author: User

Prerequisite installation Postfix



#!/bin/shell


Log=/home/dbdata/db2.err

#原来error记录数

Numa= ' Cat/tmp/mysqlerrornb.log '


#当前error数

Numb= ' cat $log |grep "ERROR" |wc-l '


#增加的error条目

numc=$ (($numB-$numA))


#从日志中过滤出error日志

Errtotal=/tmp/mysqlerrtotal.log


#对新增的error日志提取, and report the police

Errincrease=/tmp/errincrease.log


if [[$numC > 0]]

Then

' Cat $log |grep ' ERROR ' > $errTotal '

Tail-n $numC $errTotal > $errIncrease

Mail-s "mysql10.0.0.111 error alert!" to [email protected] < $errIncrease #上报告警功能

Echo $numB >/tmp/mysqlerrornb.log

Exit 1

Else

echo "It's OK" >/dev/null 2>&1

Exit 1

Fi


Extract MySQL error level logs and automatically report police content on mail

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.