Zabbix Monitoring Mysql Status

Source: Internet
Author: User


Brief introduction:

How do I use Zabbix to monitor Mysql status?

Zabbix has its own template for monitoring Mysql, but it cannot be used directly. We need to write our own script to get the data according to the Key provided by the template

1. See what keys are available

> Configuration-Templates

# # on this template page, you can see the template App MySQL templates have 14 items, we need to write our own script to get these 14 values

# # are: Com_select, Com_insert, Com_update, Com_delete, Com_begin, Com_commit, Com_rollback
Questions, Slow_queries, bytes_received, Bytes_sent, Ping, Uptime, Version

2. Write Shell script according to Key

Shell > Mysql-uroot-p-E"Grant Usage on * * to [e-mail protected] identified by ' Zabbix_password ';"# Establish 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 '$ ~/' " $"'$/{print $}'} Case$1 inchcom_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$passwordPing|WC-l;;*)Echo "Usage: $ {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

# # About two command paths, I use the ' which MySQL ' Operation without success
# # Before you finish the test, can you get the value of each Key

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 value of Key in the template
# # can also be added directly 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 Key

# # Add the above configuration

4. Restart Zabbix_agentd

Shell > Service Zabbix_agentd Restart

Note that all of the above is on the monitored side

5, Zabbix service side test can get Key

14.25. 97.14 -K MySQL. Ping 1

# # can get the value to the key, indicating that there is no problem with the configuration
# # is monitored, remember to turn on port 10050

6. Zabbix Monitor Mysql status

# # Next, link the Zabbix's own monitor template to the host
# # After a small meeting, you can see the effect, version may compare a long point, because the template set the time range is 3,600 seconds, Ping will mistakenly report Mysql down, because only before there is no value.

7. Add Graph to these monitoring items

# # comes with the template has done two pictures, so direct use can, I here is no load, so nothing to see.

8. Test Trigger Alarm

# # Unfortunately, your own template has also been defined in the Trigger alarm conditions, to look

> Templates, Trigger, Configuration

Severity: # # Event Alarm Level

Not classified unknown mount level, grey

Information General information, bright green

Warning warning message, yellow

Average General Fault, Orange

High Level fault, red

Disaster fatal fault, bright red

Name: # # Trigger names

Expression: # # logical Regular expression for a trigger state calculation

Status: # # Trigger switch

# # How to set trigger alarm conditions next Write ^_^

# # OK, if Mysql is in the down state, it will trigger the condition, but after the trigger? (Of course, to send an event notification, or to execute a remote command)

9, first put this put, to do something else! (Monitoring has been completed, and the rest of the section continues elsewhere)

Zabbix Monitoring Mysql Status

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.