Monitoring MySQL status with Zabbix

Source: Internet
Author: User

Monitoring MySQL status with Zabbix

Introduction:

How to Use Zabbix to monitor MySQL status?

Zabbix has a template that monitors MySQL, but cannot be used directly. We need to write scripts based on the Key provided by the template to obtain data.

1. Check which keys are available.

> Configuration-> Templates

# On this Template page, we can see 14 Items in the Template App MySQL Template. We need to write a script to obtain these 14 values.

# Com_select, Com_insert, Com_update, Com_delete, Com_begin, Com_commit, and Com_rollback
Questions, Slow_queries, Bytes_received, Bytes_sent, Ping, Uptime, Version

2. Write Shell scripts based on keys

Shell> mysql-uroot-p-e "grant usage on *. * to zabbix @ localhost identified by 'zabbix _ password'; "# create a monitoring User shell> vim/script/mysql_status.sh #! /Bin/bashUser = 'you _ user' Password = 'you _ password' Mysql = '/usr/local/mysql/bin/mysql 'mysqladmin ='/usr/local/mysql /bin/mysqladmin 'COMMAND () {$ Mysql-u $ User-p $ Password-e "show global status" | awk '$1 ~ /'"$1"' $/{print $2} '} case $1 in Com_select) command $1; Com_insert) command $1; Com_update) command $1; Com_delete) command $1; Com_begin) command $1; Com_commit) command $1; Com_rollback) command $1; Questions) command $1 ;; slow_queries) command $1; Bytes_received) command $1; Bytes_sent) command $1; Uptime) command $1; Version) $ Mysql-V | awk-F' [,] ''{print $6} '; Ping) $ Mysqladmin-u $ User-p $ Password ping | wc-l; *) echo "Usage: $0 {Com_select | Com_insert | Com_update | Com_delete | Com_begin | Com_commit | Com_rollback | Questions | Slow_queries | Bytes_received | Bytes_sent | Ping | Uptime | Version} "; esac

# I have not succeeded in using the 'which mysql' command path.
# After writing, test whether the values of each Key can be obtained.

shell > chmod a+x /script/mysql_status.sh

3. Add a custom key configuration file

shell > vim /usr/local/zabbix/etc/zabbix_agentd.conf.d/mysql_status.conf# Mysql_statusUserParameter=mysql.status[*],/script/mysql_status.sh $1UserParameter=mysql.ping,/script/mysql_status.sh PingUserParameter=mysql.version,/script/mysql_status.sh Version

# Note the Key value method in the template
# You can also directly add it to the end of/usr/local/zabbix/etc/zabbix_agentd.conf

Shell> vim/usr/local/zabbix/etc/zabbix_agentd.confInclude =/usr/local/zabbix/etc/zabbix_agentd.conf.d/*. confUnsafeUserParameters = 1 # Allow custom keys

# Add the preceding Configuration

4. Restart Zabbix_agentd.

shell > service zabbix_agentd restart

# Note: all the operations above are performed on the monitored end

5. Test the Zabbix server to obtain the Key.

shell > /usr/local/zabbix/bin/zabbix_get -s 14.25.97.14 -k mysql.ping1

# The key value can be obtained, indicating that the configuration is correct.
# Remember to enable port 10050 on the monitored side

6. Monitoring Mysql status using Zabbix

# Next, link the monitoring template that comes with Zabbix to the host.
# After a short meeting, you can see the effect. The version may take a relatively long time. Because the time range set in the template is 3600 seconds, ping will trigger a false positive for Mysql Down, because there is no value before.

7. Add a Graph for these metric items

# The built-in template has already made two images ready, so you can use them directly. I don't have any space here, so I can't see anything ..

8. Test Trigger alarm

# Unfortunately, the Trigger alarm conditions have been defined in the built-in template.

> Configuration-> Templates-> Trigger

Severity: # event alert level

Not classified unknown Installation Level, gray

General Information, bright green

Warning information, yellow

Average fault, orange

High-level fault, red

Disaster fatal fault, highlighted

Name: ## Trigger Name

Expression: # logical Regular Expression for trigger status Calculation

Status: # trigger switch

# How to set the trigger alarm condition? ^_^

# Well, if Mysql is in the down state, it will trigger the condition. But what after the trigger? (Send event notifications or execute remote commands)

9. Put this one first and do something else! (The monitoring has been completed, and the subsequent parts are placed elsewhere)

Chinese garbled characters on the Zabbix monitoring page

Problem description:

For example, I believe most people have encountered this problem. The Zabbix monitoring chart is garbled in Chinese.

It's easy to solve this problem: (The font is missing in the Zabbix webpage directory)

1. Open the C: \ Windows \ Fonts font directory of Windows and select a font you like (it is recommended that you choose a fresh one, which is too easy to see)

2. I chose the simkai regular object name. ttf: Upload the file to the Zabbix webpage directory on the server .. /html/zabbix/fonts (if the original file name is. for TTF, remember to change it. ttf)

3. Edit the ../zabbix/include/defines. inc. php file and find define ('zbx _ GRAPH_FONT_NAME ', 'dejavusans'). In the row, change DejaVuSans to simkai.

4. Refresh the page to see the effect.

Some Zabbix Tutorials:

Compile and install Zabbix2.4.5 source code in Ubuntu 14.04

Install and deploy the distributed monitoring system Zabbix 2.06

Install and deploy the distributed monitoring system Zabbix 2.06

Install and deploy Zabbix in CentOS 6.3

Zabbix distributed monitoring system practice

Under CentOS 6.3, Zabbix monitors apache server-status

Monitoring MySQL database Parameters Using Zabbix in CentOS 6.3

Install Zabbix 2.0.6 in 64-bit CentOS 6.2

ZABBIX details: click here
ZABBIX: click here

This article permanently updates the link address:

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.