The most complete and correct Zabbix monitoring MySQL configuration method in history

Source: Internet
Author: User
Tags mysql version

1, configuration--host--Create a host

2. Select Linux Server in other groups or create a new group

3. Host name is MySQL

4. Select click Add in the template, choose the template App MySQL, click Archive

5. Add MySQL Monitor script:

Cd/usr/local/zabbix/share/zabbix/alertscripts

VI check_mysql.sh

#!/bin/bash

# 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

6. Modify Zabbix Agent Parameters

Vi/usr/local/zabbix/etc/zabbix_agentd.conf

# 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 $

# get MySQL Run status

userparameter=mysql.ping,mysqladmin-uzabbix-p123456-p3306-h127.0.0.1 Ping | Grep-c Alive

7. Restart Zabbix Service

Service Zabbix_agentd Restart


This article is from the "13015170" blog, please be sure to keep this source http://13025170.blog.51cto.com/13015170/1962649

The most complete and correct Zabbix monitoring MySQL configuration method in history

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.