In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Write at the front:
In practice, checking the database error log regularly is an essential work item. But the check does not necessarily produce a new error message, or we prefer never to have an error message, because it means that our database is robust. In this case, it is impossible to predict when the error message will occur, and if we check the error log is often normal, it is easy to form thinking inertia, over time without misinformation, we are easy to ignore this work item. But the error log is essential for us, at this time, we hope that when there is an error message, directly email the police to notify me, I can make time to do something more meaningful. If you have the same need, then this article may help you.
Script file:
Cat monitor_errorlog.sh
#! / bin/bash
# error log monitoring alarm script
# Monitoring date
Time= `date +% F`
# time=2018-06-02
Cd / home/dbalzb
# generate error log monitoring files according to the date. First, check whether the error log has been generated on the same day.
Ls errorlog-$time.txt & > / dev/null
# the status return value is non-0, which means that it has not been generated in the current day
If [$?-ne 0]; then
Cat / home/data/mysql/error.log | grep "$time" | egrep-I 'error | warning' > errorlog-$time.txt
# determine whether there is an error log that day
Num= `cat errorlog-$time.txt | wc-l`
If [$num-ne 0]; then
Mutt lizibin_1@126.com-s "errorlog3306"
< errorlog-$time.txt fi md5sum errorlog-$time.txt >Md5-errorlog-$time.txt
Else
Cat / home/data/mysql/error.log | grep "$time" | egrep-I 'error | warning' > errorlog-$time-new.txt
# script files executed for the second and later times will generate new errorlog files and new md5sum values
Md5sum errorlog-$time-new.txt > > md5-errorlog-$time.txt
Str1= `cat md5-errorlog-$time.txt | sed-n '1p' | awk' {print $1}'`
Str2= `cat md5-errorlog-$time.txt | sed-n '2p' | awk' {print $1}'`
# num1= `cat errorlog-$time-new.txt | wc-l`
# cat errorlog-$time.txt > > errorlog-$time-history.txt
# compare the md5sum values of the two files to determine whether a new error log is generated
If [$str1! = $str2]; then
Mutt lizibin_1@126.com-s "new-errorlog3306"
< errorlog-$time-new.txt #cat errorlog-$time-new.txt >> errorlog-$time-history.txt
Fi
/ bin/rm-f errorlog-$time-new.txt
Sed-I '2d' md5-errorlog-$time.txt
Fi
Add scheduled tasks: (execute once every hour, can be adjusted by yourself)
5 * / 1 * sh / home/dbalzb/monitor_errorlog.sh
All roads lead to Rome. How do you monitor database error logs dynamically? Welcome to leave a message below.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.