Zabbix adding custom monitoring items (monitoring MySQL status)

Source: Internet
Author: User

Zabbix Adding custom monitoring items (monitoring MySQL status)

First, the experimental environment

Zabbixserver 192.168.1.103 version: V3.0.4

Zabbixagent 192.168.1.128

Mysql 192.168.1.102


Second, monitoring requirements

Monitor The status of MySQL when the state is abnormal and alert

third,MySQL add monitoring and monitoring scripts

3.1, using the Mysqladmin tool to detect MySQL status

[Email protected]:~# mysqladmin-uroot-p1qaz#edc Ping

650) this.width=650; "src=" Https://note.youdao.com/yws/res/1242/C3BB717842594BA288CF69AA9445AAEA "style=" width : 554px; "alt=" C3bb717842594ba288cf69aa9445aaea "/>

Description: If MySQL status is normal, will display mysqld is alive, otherwise you will be prompted not to connect. For the server side,mysqld is alive such a sentence is not good understanding, the server side is best to receive only 1 and 0,1 indicates that the service is available,0 means the service is not available. Well, then, improve the command .

3.2, command improvements

[Email protected]:~# Mysqladmin-uroot-p1qaz#edc Ping | Grep-c Alive

650) this.width=650; "src=" Https://note.youdao.com/yws/res/1241/6A909777BB984436A1143210E89761FC "style=" width : 553px; "alt=" 6A909777BB984436A1143210E89761FC "/>

Note: The user name and password are placed in the command for later maintenance is not good, so we create a/var/lib/zabbix under the MySQL username and password configuration file ". My.cnf"

3.2.1, the process is as follows

[Email protected]: # mkdir/var/lib/zabbix/

[Email protected]: # vim/var/lib/zabbix/.my.cnf #"Note that the. my.cnf, preceded by a decimal, indicates that the file is a hidden file"

Add the following content:

650) this.width=650; "src=" Https://note.youdao.com/yws/res/1245/904DB2DD32744D7A89B6C7268854FCA3 "style=" width : 295px; "alt=" 904db2dd32744d7a89b6c7268854fca3 "/>

Test it.

[Email protected]:# home=/var/lib/zabbix mysqladmin Ping | Grep-c Alive

650) this.width=650; "src=" Https://note.youdao.com/yws/res/1240/79D49087ADF345EC94BFBB3B9BB79A8E "style=" width : 553px; "alt=" 79d49087adf345ec94bfbb3b9bb79a8e "/>

3.3, add this monitoring command to the Zabbix Agent and correspond to a Key

3.3.1, uncomment the Include configuration item in the AGENTD configuration file

[Email protected]:~# vim/usr/local/etc/zabbix_agentd.conf

650) this.width=650; "src=" https://note.youdao.com/yws/res/1236/CECEB4FB7F01423EB72CEF9050B8CA61 "style=" width : 554px; "alt=" Ceceb4fb7f01423eb72cef9050b8ca61 "/>

3.3.2, creating a child configuration file

[Email protected]:~# cd/usr/local/etc/zabbix_server.conf.d/

[Email protected]:/usr/local/etc/zabbix_server.conf.d# vim userparameter_mysql.conf

Add the following content:

Userparameter=mysql.ping,home=/var/lib/zabbix Mysqladmin Ping | Grep-c Alive

650) this.width=650; "src=" Https://note.youdao.com/yws/res/1243/D98DB52CB376472783D895DEE3C6AD5B "style=" width : 554px; "alt=" d98db52cb376472783d895dee3c6ad5b "/>

Description

"Userparameter" in this command means that this is a user-defined script;"=" is the content of the script;"mysql.ping" is Key," ,the "POST" command is called when the Zabbix Server initiates a request to the Agent to obtain the key "Mysql.ping". and returns the return value to the Server.

3.4, test is normal

Zabbix_agentd-t mysql.ping

650) this.width=650; "src=" https://note.youdao.com/yws/res/1239/26BAD609EFBB4D7F9B85E597D20F9D68 "style=" width : 553px; "alt=" 26bad609efbb4d7f9b85e597d20f9d68 "/>

3.5, on the server side, can also use the Zabbix_get command to test data from the server side for the specified client side.

Zabbix_get-s 127.0.0.1-p 10050-i 192.168.1.103-k mysql.ping

650) this.width=650; "src=" Https://note.youdao.com/yws/res/1244/B098692763CA429C94FD8358739156EF "style=" width : 553px; "alt=" B098692763ca429c94fd8358739156ef "/>

Description: I am here –I 192.168.1.103 for the source IPbecause I am here with the virtual IP Access server side

4. Add monitoring items to the admin panel

4.1, you can add a custom template, create a template

650) this.width=650; "src=" https://note.youdao.com/yws/res/1234/A5B60A2F201845629E1FF660BDC1BC01 "style=" width : 442px; "alt=" A5b60a2f201845629e1ff660bdc1bc01 "/>

4.2 After defining the template name, click Add

650) this.width=650; "src=" Https://note.youdao.com/yws/res/1233/DE3B52238FB34C389F299EB5610DDAAF "style=" width : 553px; "alt=" De3b52238fb34c389f299eb5610ddaaf "/>

4.3, create a monitoring item in a custom template that we just customized (add a custom key), click items

650) this.width=650; "src=" Https://note.youdao.com/yws/res/1238/532F21539A5E43DFADEF1E4B7217E5CA "style=" width : 553px; "alt=" 532f21539a5e43dfadef1e4b7217e5ca "/>

650) this.width=650; "src=" https://note.youdao.com/yws/res/1231/F10BF75AC87E473FA57BD53532193A08 "style=" width : 553px; "alt=" f10bf75ac87e473fa57bd53532193a08 "/>

4.4, create items, then click Add

650) this.width=650; "src=" https://note.youdao.com/yws/res/1235/CD5B1810B13449A4AA860ED97906F841 "style=" width : 553px; "alt=" cd5b1810b13449a4aa860ed97906f841 "/>

4.5, Associate the template you just added to a monitored host

650) this.width=650; "src=" https://note.youdao.com/yws/res/1232/51962E304BC5490EA1A181065ECBAD21 "style=" width : 553px; "alt=" 51962e304bc5490ea1a181065ecbad21 "/>

650) this.width=650; "src=" https://note.youdao.com/yws/res/1237/6B49B5EE7F034BA7A9471C4C93C34D33 "style=" width : 554px; "alt=" 6b49b5ee7f034ba7a9471c4c93c34d33 "/>

At this end of the configuration, the trigger can be configured to determine the value of the retrieved database state, thereby generating an alarm, or sending the alarm message to the administrator via mail or by invoking the SMS interface


This article is from the "it cock thread aggregation q group 223843163" blog, please be sure to keep this source http://trtan.blog.51cto.com/8272891/1866023

Zabbix adding custom monitoring items (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.