How does Zabbix monitor mysql services on zabbix server ?, Zabbixmysql

Source: Internet
Author: User

How does Zabbix monitor mysql services on zabbix server ?, Zabbixmysql

How to monitor mysql services on Zabbix server

1. Configure mysql

In the/etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf file, specify how the zabbix agent obtains information about the mysql service, and create ". my. the cnf file is used to specify how zabbix agent logs into the database. The zabbix user is used by default. You can find the password in the zabbix_server.conf file.

[Root @ zabbix_server ~] # Cd/etc/zabbix/zabbix_agentd.d [root @ zabbix_server variables] # Keys [root @ zabbix_server variables] # cat userparameter_mysql.conf | grep mysql # Flexible parameter to grab global variables. on the frontend side, use keys like mysql. status [Com_insert]. # Key syntax is mysql. status [variable]. userParameter = mysql. status [*], echo "show global status where Variable_name = '$1'; "| HOME =/var/lib/zabbix mysql-N | awk '{print $2}' # Flexible parameter to determine database or table size. on the frontend side, use keys like mysql. size [zabbix, history, data]. # Key syntax is mysql. size [<database>, <table>, <type>]. userParameter = mysql. size [*], bash-c '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-n' UserParameter = mysql. ping, HOME =/var/lib/zabbix mysqladmin ping | grep-c aliveUserParameter = mysql. version, mysql-V [root @ zabbix_server zabbix_agentd.d] # mkdir-p/var/lib/zabbix [root @ zabbix_server ~] # Mysql_secure_installation # Add a secret code [root @ zabbix_server ~] # Mysql-ppasswd # test login to MariaDB [(none)]> [root @ zabbix_server ~] # Mysqladmin-uroot-ppasswd ping | grep-c alive # obtain mysql Service Information 1 [root @ zabbix_server zabbix] # cd/var/lib/zabbix/[root @ zabbix_server zabbix] # vim. my. cnf [mysql] host = localhostuser = rootpassword = passwd # this password is the root user's login password socket =/var/lib/mysql. sock [mysqladmin] host = localhostuser = rootpassword = passwdsocket =/var/lib/mysql. sock [root @ zabbix_server zabbix] # systemctl restart zabbix-agent.service [Root @ zabbix_server el7] # yum install-y zabbix-get-3.2.6-1.el7.x86_64.rpm [root @ zabbix_server ~] # Zabbix_get-s 127.0.0.1-k mysql. versionmysql Ver 15.1 Distrib 5.5.44-MariaDB, for Linux (x86_64) using readline 5.1 [root @ zabbix_server ~] # Zabbix_get-s 127.0.0.1-k mysql. ping # test to obtain mysql service information

To monitor the mysql service of a remote host, create a zabbix user and authorize

MariaDB [(none)]> grant usage on. TO 'zabbix' @ 'localhost' identified by 'passwd ';

MariaDB [(none)]> flush privileges; click Configuration> host> Zabbix server> Template> SELECT> Template App MySQL

Click Configuration> host> Zabbix server to view two new monitoring images.

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.