Zabbix using your own template to monitor MySQL

Source: Internet
Author: User

1. Add MySQL template to Web page

Configuration > Hosts > Select Host or Add new host > tempaltes, search for MySQL, add popup templates, and then update

2, configuration userparameter_mysql.conf

Locate the configuration file

[Email protected] ~]# Find/-name Userparameter_mysql.conf/usr/share/doc/zabbix22-agent-2.2.16/userparameter_ Mysql.conf

Build a directory to put configuration files in/etc/zabbix

[Email protected] ~]# mkdir/etc/zabbix/zabbix_agentd.d/

Copy the configuration file to this directory

[[Email protected] ~] #cp/USR/SHARE/DOC/ZABBIX22-AGENT-2.2.16/USERPARAMETER_MYSQL.CONF/ETC/ZABBIX/ZABBIX_AGENTD.D /

Create a user to get data about MySQL

Mysql>grant USAGE on *. * to ' Zabbix ' @ ' localhost ' identified by ' 123 '; Mysql>flush privileges;

Add a configuration file to associate with MySQL MY.CNF

[Email protected] ~]# vim/etc/zabbix/.my.cnf [mysql]host = Localhostuser = Zabbixpassword = 123socket =/tmp/mysql.sock[ Mysqladmin]host = Localhostuser = Zabbixpassword = 123socket =/tmp/mysql.sock

Modify the directory where the Userparameter_mysql.conf:HOME directory is new. my.cnf files

[[email protected] ~] #sed  -i  ' [email protected] /var/lib/[email protected]/etc/zabbix/@g '  /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf 
[[email protected] ~]# grep -v  "^#"  /etc/zabbix/zabbix_agentd.d/userparameter_ mysql.conf userparameter=mysql.status[*],echo  "show global status where variable _name= ' $ '; "  | HOME=/etc/zabbix mysql -N | awk  ' {print $$2} ' userparameter= mysql.size[*],bash -c  ' echo  "Select sum ($ (case " $ " in both|" ")  echo  "Data_length+index_length";;  data|index)  echo  "$3_length";;  free)  echo  "Data_free";;  ESAC)  from information_schema.tables$ ([[  "$"  =  "All"  | |  !  "$  ]] |" |  echo  " where table_schema=\" $1\ "") $ ([[  "$"  =  "All"  | |  !  "$  ]] |" |  echo  "and table_name=\" $2\ "");  | home=/etc/zabbix mysql -n ' Userparameter=mysql.ping,home=/etc/zabbix mysqladmin  ping | grep -c aliveuserparameter=mysql.version,mysql -v 

Modify the zabbix_agentd.conf file to add a row for the directory where userparameter_mysql.conf resides

[Email protected] ~]# vim/etc/zabbix/zabbix_agentd.d/userparameter_mysql.confinclude=/etc/zabbix/zabbix_ agentd.conf.d/

Restart Zabbix-agentd

[[Email protected] ~]# service Zabbix-agentd restartshutting down Zabbix agent: [OK]sta rting Zabbix agent: [OK]

Test

[[Email protected] ~] #zabbix_get-S 192.168.1.102-p 10050-k mysql.ping1[[email protected] ~]# zabbix_get-s 192.168.1.10 2-p 10050-k mysql.versionmysql Ver 14.14 distrib 5.1.71, for Redhat-linux-gnu (x86_64) using ReadLine 5.1


Zabbix using your own template to monitor MySQL

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.