Example of Zabbix monitoring MySQL log files

Source: Internet
Author: User
Tags system log


In general, the log first reflects the application of the current problem, in the mass log found in our abnormal records, and then recorded, and according to the situation alarm, we can monitor the system log, Nginx, Apache, business log. Here I take the common MySQL log to do monitoring, we look at the demo.

Monitor Log key

First to understand Key,log[file,<regexp>,<encoding>,<maxlines>,<mode>,<output>]

File: filename, write absolute path

RegExp: A regular expression to match the content, or write directly what you want to retrieve, for example, I want to retrieve the record with the error keyword

Encoding: Encoding related, left blank

Maxlines: The maximum number of rows to commit, this parameter overrides the ' Maxlinespersecond ' in the configuration file zabbxi_agentd.conf, and we can leave blank

Mode: Default is all, or skip,skip can skip old data

Output: Data exported to the Zabbix server. Can be 1, 21 straight 9,1 indicates that the first regular expression matches the content, and 2 indicates that the second regular expression matches the wrong content.

Note: I strongly recommend that you use the second parameter, see some online Zabbix monitoring log tutorials, almost only the first parameter, which will cause the contents of the log file to throw all the Zabbix_server records, I think, this must not be what you want to see.

Log file Permission configuration

Add Read permission to the log file, for demonstration convenience, I directly to 777

# chmod 777/data/mydata/mydata_3306/li220-237.err


If the permissions are not in place, the Zabbix agent log has a similar error as follows:

4780:20150311:135742.401 cannot open '/data/mydata/mydata_3306/li220-237.err ': [+] Permission denied
4780:20150311:135742.401 Active Check "Log[/data/mydata/mydata_3306/li220-237.err,error,,,,]" is not supported
4779:20150311:135742.402 cannot open '/data/mydata/mydata_3306/li220-237.err ': [+] Permission denied
4779:20150311:135742.402 Active Check "Log[/data/mydata/mydata_3306/li220-237.err,error,,,,]" is not supported
Zabbix Configuration

Host>> target host >>item>>create item, as follows:


Description:

1. Type must select the Zabbix agent (active) because the data is zabbix to be monitored for unsolicited submission to the server

2. Key:log[/data/mydata/mydata_3306/li220-237.err,error,,,,], I do not say more, careful people will say, there is a call Logrt key, what is the difference, say later.

3. Log time format:yyMMddphh:mm:ss, the corresponding log 150311 11:47:09,y for the year, M for the month, D for the day, p and: a placeholder, h for hours, m for minutes, s for seconds.

Zabbix Monitor MySQL log view

Switch to the latest log, find the appropriate data, the following is my monitor screenshot


Zabbix monitor MySQL log

Next is the trigger, you can create a trigger based on your own situation, such as the log contains a string and so on, as shown above, we can trigger the execution of MySQL table repair.

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.