Zabbix monitoring MySQL Performance

Source: Internet
Author: User
Tags mysql version

Today to see how Zabbix monitor MySQL performance, this way using MySQL comes with the template, you can monitor the following: OPS (increased deletion check), MySQL request traffic bandwidth, MySQL response traffic bandwidth, the final will be attached to the corresponding monitoring map!

Writing check_mysql.sh Scripts

To get MySQL performance metrics data, you need to modify the appropriate database information

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

# vim/usr/local/zabbix-2.4.4/scripts/chk_mysql. SH

#脚本如下:

#!/bin/bash

# -------------------------------------------------------------------------------

# FileName:check_mysql.sh

# revision:1.0

# date:2015/06/09

# Author:dengyun

# email: [Email protected]

# Website:www.ttlsa.com

# Description:

# Notes: ~

# -------------------------------------------------------------------------------

# copyright:2015 (c) Dengyun

# LICENSE:GPL

# User Name

Mysql_user= ' Zabbix '

# password

Mysql_pwd= ' 123456 '

# Host address/IP

Mysql_host= ' 127.0.0.1 '

# port

Mysql_port= ' 3306 '

# Data connection

Mysql_conn= "/usr/bin/mysqladmin-u${mysql_user}-p${mysql_pwd}-h${mysql_host}-p${mysql_port}"

# parameters are correct

If [$#-ne "1"];then

echo "Arg error!"

Fi

# Get Data

Case $ in

Uptime)

result= ' ${mysql_conn} status|cut-f2-d ":" |cut-f1-d "T" '

Echo $result

;;

Com_update)

result= ' ${mysql_conn} extended-status |grep-w "Com_update" |cut-d "|"-f3 '

Echo $result

;;

Slow_queries)

result= ' ${mysql_conn} status |cut-f5-d ":" |cut-f1-d "O"

Echo $result

;;

Com_select)

result= ' ${mysql_conn} extended-status |grep-w "Com_select" |cut-d "|"-f3 '

Echo $result

;;

Com_rollback)

result= ' ${mysql_conn} extended-status |grep-w "Com_rollback" |cut-d "|"-f3 '

Echo $result

;;

Questions)

result= ' ${mysql_conn} status|cut-f4-d ":" |cut-f1-d "S" '

Echo $result

;;

Com_insert)

result= ' ${mysql_conn} extended-status |grep-w "Com_insert" |cut-d "|"-f3 '

Echo $result

;;

Com_delete)

result= ' ${mysql_conn} extended-status |grep-w "Com_delete" |cut-d "|"-f3 '

Echo $result

;;

Com_commit)

result= ' ${mysql_conn} extended-status |grep-w "Com_commit" |cut-d "|"-f3 '

Echo $result

;;

Bytes_sent)

result= ' ${mysql_conn} extended-status |grep-w "bytes_sent" |cut-d "|"-f3 '

Echo $result

;;

bytes_received)

result= ' ${mysql_conn} extended-status |grep-w "bytes_received" |cut-d "|"-f3 '

Echo $result

;;

Com_begin)

result= ' ${mysql_conn} extended-status |grep-w "Com_begin" |cut-d "|"-f3 '

Echo $result

;;

*)

echo "Usage:$0 (uptime| com_update| slow_queries| Com_select| com_rollback| questions| Com_insert| com_delete| Com_commit| Bytes_sent| bytes_received| Com_begin) "

;;

Esac


650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

Modify Zabbix_agentd.conf

To add a custom key, add the following on the last line:

# get MySQL version userparameter=mysql.version,mysql-v# get MySQL performance metrics, this is the script defined above userparameter=mysql.status[*],/usr/local/ zabbix-2.4.4/scripts/chk_mysql.sh $1# get MySQL run status userparameter=mysql.ping,mysqladmin-uzabbix-p123456-p3306- h127.0.0.1 Ping | Grep-c Alive

Note: Be aware of modifying your database information and Zabbix path information

Restart Zabbix
# killall zabbix-agentd#/usr/local/zabbix-2.4.4/bin/zabbix_agentd or # service Zabbix_agentd restart

Link MySQL Templates

Template is provided by Zabbix system, go to Zabbix Web background,configuration-->hosts--> Click on your host name--> Select Template tab, select "Templates App MySQL ", then click Update to

Zabbix monitoring MySQL

Data View

If the configuration is not abnormal, then you can see in graph 2 charts, respectively, request traffic bandwidth, response traffic bandwidth, OPS, click monitoring-->graphs--> Select your host, select graph "MySQL Bandwidth "," MySQL operations ", the monitoring chart is as follows (image can be clicked to enlarge view):

Zabbix monitoring MySQL

Zabbix monitoring MySQL

Common error Resolution Ideas

If you find that the monitoring does not have data, please troubleshoot the following issues

1. Zabbix whether the client restarts

2. Whether the script has execute permission

3. Does the database have permissions

4. Is there a problem with the environment variables

5. Look at the Zabbix item column and move the mouse over the Red fork with an error message.

6. If the database password is saved in the script, it will cause the monitoring no data will continue to error warning:using a password on the command line interface can be insecure. Need to add configuration such as account password to MY.C NF.


Zabbix monitoring MySQL Performance

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.