Zabbix monitoring MySQL

Source: Internet
Author: User

Using Zabbix real-time monitoring of MySQL performance, to achieve all aspects of MySQL performance control;


Zabbix default will have a monitor template for MySQL (template App MySQL), just can't use directly, need to be monitored by the machine to do some settings;


First, the need to write a script placed on the monitored machine, which is the same as the custom monitoring, just the template with Zabbix;

Cat zabbix_mysql_status.sh

#!/bin/sh  #Create  by feixiangdada 2015.12.17 mysql_sock= "/tmp/mysql.sock"    args=1 if [ $# -ne  "$ARGS"  ];then     echo  "please  input one arguement: " fi case $1 in     uptime)          result= '/usr/local/mysql/bin/mysqladmin -s $ Mysql_sock status|cut -f2 -d ":" |cut -f1 -d "T"               echo  $result               ;;          com_update)               result= '/usr/local/mysql/bin/mysqladmin -s  $MYSQL _sock  extended-status |grep -w  "Com_update" |cut -d "|"  -f3 '              echo  $result               ;;          slow_queries)           result= '/usr/local/mysql/bin/mysqladmin -s  $MYSQL _sock status |cut -f5  -d ":" |cut -f1 -d "O"                   echo  $result                   ;;      com_select)          result= '/usr/ local/mysql/bin/mysqladmin -s  $MYSQL _sock extended-status |grep -w  "Com_select" | Cut -d "|"  -f3 '                   echo  $result                  ;;      com_rollback)          result= '/usr/ local/mysql/bin/mysqladmin -s  $MYSQL _sock extended-status |grep -w  "Com_rollback "|cut -d" | "  -f3 '                   echo  $result                   ;;      questions)          result= '/usr/ local/mysql/bin/mysqladmin -s  $MYSQL _sock status|cut -f4 -d ":" |cut -f1 -d "S "'                  echo   $result                   ;; &nBsp;    com_insert)          result= '/usr/ local/mysql/bin/mysqladmin -s  $MYSQL _sock extended-status |grep -w  "Com_insert" | Cut -d "|"  -f3 '                   echo  $result                   ;;      com_delete)          result= '/usr/ local/mysql/bin/mysqladmin -s  $MYSQL _sock extended-status |grep -w  "Com_delete" | Cut -d "|"  -f3 '                   echo  $result                   ;;      com_commit)          result= '/usr/local/mysql/bin/mysqladmin -s  $MYSQL _sock extended-status  |grep -w  "Com_commit" |cut -d "|"  -f3 '                   echo  $result                   ;;      bytes_sent)          result= '/usr/ local/mysql/bin/mysqladmin -s  $MYSQL _sock extended-status |grep -w  "Bytes_sent"  |cut -d "|"  -f3 '                   echo  $result                   ;;      bytes_received)          result= '/ Usr/local/mysql/bin/mysqladmin -s  $MYSQL _sock extended-status |grep -w  "bytes_received"  |cut -d "|"  -f3 '                   echo  $result                   ;;      com_begin)          result= '/usr/ local/mysql/bin/mysqladmin -s  $MYSQL _sock extended-status |grep -w  "Com_begin" | Cut -d "|"  -f3 '                   echo  $result                   ;;                                   *)          echo  "usage:$0 (uptime| com_update| slow_queries| Com_select| com_rollback| Questions) "         ;;  esac

The note in this script is:

1. Mysql.sock the path, according to their own path to modify;

2. Configure the MY.CNF:

Add the following to the MY.CNF:

[Mysqladmin]host=localhostuser=zabbix #用户修改成自己的password =zabbix #密码需要对上用户

Need to restart MySQL after modification (if 5.5 below can ignore this step)


Second, the zabbix_agentd.conf on the control machine add the following:

Userparameter=mysql.version,mysql-vuserparameter=mysql.ping,mysqladmin-uzabbix-pzabbix-s/tmp/mysql.sock Ping | Grep-c aliveuserparameter=mysql.status[*],/usr/local/zabbix/share/zabbix/alertscripts/mysql_status.sh

Restart the ZABBIX_AGENTD service:

Service Zabbix_agentd Restart


Third, in the monitoring of the Zabbix to add MySQL templates (template App mysql) can be;

As follows:

650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M00/78/00/wKiom1ZzdLrTXUcfAAaQDd9tvSk558.jpg "style=" float: none; "title=" zabbix.jpg "alt=" Wkiom1zzdlrtxucfaaaqdd9tvsk558.jpg "/>

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/77/FF/wKioL1ZzdMiSXh48AAKnDEsFjw8162.png "style=" float: none; "title=" Zabbix2.png "alt=" Wkiol1zzdmisxh48aakndesfjw8162.png "/>


This article from the "Shallow faint" blog, please be sure to keep this source http://cuixiang.blog.51cto.com/8204722/1725906

Zabbix monitoring MySQL

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.