Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MySQL Monitoring configuration tutorial for Zabbix Enterprise Monitoring

2025-01-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the Zabbix enterprise monitoring MySQL monitoring configuration tutorial, the content of the article is carefully selected and edited by the author, has a certain pertinence, and is of great significance to everyone's reference, the following is to understand the MySQL monitoring configuration tutorial of Zabbix enterprise monitoring with the author.

View the Items of the template

The Items defined by the template is as follows:

Take Items "MySQL uptime" as an example. The content of Key is as follows:

As you can see, the key part is that the key value mysql.status [Uptime] is equivalent to the variable name.

2.1.2 definition of Key pass parameters in Zabbix Agens part

1) pass the definition file of the parameter

Less / etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf

2) the definition format of passing parameters

It can be found as follows:

UserParameter=mysql.status [*], echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix mysql-N | awk'{print $2}'

The definition is separated by commas and can be simplified as follows:

User-defined parameter name, user-defined parameter value (shell command)

Note:

User-defined parameter name: "*" indicates that Zabbix Server can pass any specific variable parameter

User-defined parameter value: "$1" represents the variable parameter that can be passed in by Zabbix Server.

3) if the input parameter is "Uptime", it becomes

UserParameter=mysql.status [Uptime], echo "show global status where Variable_name='Uptime';" | HOME=/var/lib/zabbix mysql-N | awk'{print $2}'

4) the values of user-defined parameters can be specified by Shell (database authorization and connection database authorization configuration are required)

So the specified result is:

UserParameter=mysql.status [Uptime], 165538

In this way, the value of MySQL is sent to Zabbix Server

3 practice part

3.1 Environment description

Zabbix Server:

Ipaddress=10.168.0.160

Hostname=zabbix

Zabbix Agens:

Ipaddress=10.168.0.99

Hostname=mysqlSer

App=mysqld

For the configuration on the Zabbix Server&Agens side, please see:

Http://cmdschool.blog.51cto.com/2420395/1723530

3.2 user-defined parameters take effect

In Zabbix Agens:

Vim Editor / etc/zabbix/zabbix_agentd.conf enables the following two parameters

Include=/etc/zabbix/zabbix_agentd.d/UnsafeUserParameters=0

Note: the definition in "userparameter_mysql.conf" will not take effect until the above configuration is completed.

3.3.Grant Zabbix Agens data access

In Zabbix Server:

MySQL permission configuration

Mysql-uroot-pGRANT SELECT ON mysql.* TO 'zabbix'@'localhost' IDENTIFIED BY' zabbix';flush privileges;show grants for zabbix@localhost

3.4 configure Zabbix Agens database access

In Zabbix Agens:

3.4.1 determine the directory of the database connection file

View the path defined by the "HOME" directory with the following command

Cat / etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf | egrep-v "(^ # | ^ $)" | grep HOME

The display is as follows:

UserParameter=mysql.status [*], echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix mysql-N | awk'{print $2} 'UserParameter=mysql.size [*], echo "select sum ($(case" $3 "in both |") echo "data_length+index_length";; data | index) echo "$3_length";; free) echo "data_free" Esac) from information_schema.tables$ ([["$1" = "all" |! "$1"]] | | echo "where table_schema='$1'") $([["$2" = "all" | |! "$2"]] | | echo "and table_name='$2'"); "| HOME=/var/lib/zabbix mysql-NUserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin ping | grep-c alive

Note: the above indicates that the database connection file should be configured in "/ var/lib/zabbix"

3.4.2 determine the PID file path for MySQL

Use the following command to view the path of the PID file for MySQL

Grep pid-file / etc/my.cnf

The display is as follows:

Pid-file=/var/run/mysqld/mysqld.pid

3.4.3 configure database connection file

Create a database connection file based on the path obtained earlier

Vim Editor / var/lib/zabbix/.my.cnf enter the following:

[mysql] host = localhostuser = zabbixpassword = zabbixsocket = / var/lib/mysql/ mysql.sock [mysqladmin] host = localhostuser = zabbixpassword = zabbixsocket = / var/lib/mysql/mysql.sock

3.5 restart and make the configuration effective

In Zabbix Agens:

Restart the Agent service

/ etc/init.d/zabbix-agent restart

3.6 Command Line to confirm Custom KEY

In Zabbix Agens:

Echo "show global status where Variable_name='Uptime';" | HOME=/var/lib/zabbix mysql-N | awk'{print $2}'

In Zabbix Server:

Zabbix_get-s 10.168.0.99-k mysql.status [uptime] zabbix_get-s 10.168.0.99-k mysql.version

3.7 add a monitoring template for the host

Web console for In Zabbix

Configuration- > Hosts- > Click Host name-> Templates- > Select- > Template App MySQL- > Add- > Update

3.8 confirm the monitoring results

Monitoring- > Graphs

Host selects a specific "host name"

Graph selects "MySQL bandwidth" or "MySQL operations" to view the monitored image

After reading the above MySQL monitoring configuration tutorial on Zabbix Enterprise Monitoring, many readers must have some understanding. If you need to get more industry knowledge and information, you can continue to follow our industry information column.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report