步骤:配置
> 主机
> 点击主机的主机
> 模版
点击那个模版进去看看模版的描述
Requirements for template operation:
1.Install Zabbix agent and MySQL client.
2.Copy Template_DB_MySQL.conf into folder with Zabbix agent configuration (/etc/zabbix/zabbix_agentd.d/ by default). Don't forget restart zabbix-agent.
3.Create MySQL user for monitoring. For example:
CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY '<password>';
GRANT USAGE,REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%';
For more information read the MYSQL documentation https://dev.mysql.com/doc/refman/8.0/en/grant.html , please.
4.Create .my.cnf in home directory of Zabbix agent for Linux (/var/lib/zabbix by default ) or my.cnf in c:\ for Windows. For example:
[client]
user=zbx_monitor
password=<password>
由此可得,关联mysql模板还需要创建检测用户和相关模板文件。
mysql> CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY 'zabbix';
mysql> GRANT USAGE,REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%';
mysql> flush privileges;
[root@test-server zabbix]# find / -name userparameter_mysql.conf
/etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
/usr/share/doc/zabbix-agent-4.4.7/userparameter_mysql.conf
cp /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf /etc/zabbix/zabbix_agentd.d/mysql.conf
[root@test-server zabbix_agentd.d]# zabbix_agentd -t mysql.ping -c /etc/zabbix/zabbix_agentd.d/mysql.conf
mysql.ping [m|ZBX_NOTSUPPORTED] [Unsupported item key.]
修改/etc/zabbix/zabbix_agentd.d/mysql.conf
UserParameter=mysql.ping[*], HOME=/etc/zabbix mysqladmin ping
UserParameter=mysql.get_status_variables[*],HOME=/etc/zabbix mysql -sNX -e "show global status"
UserParameter=mysql.version[*],HOME=/etc/zabbix mysqladmin version
UserParameter=mysql.uptime,HOME=/etc/zabbix mysqladmin status | cut -f2 -d ":" | cut -f1 -d "T" | tr -d " "
UserParameter=mysql.db.discovery[*],HOME=/etc/zabbix mysql -sN -e "show databases"
UserParameter=mysql.dbsize[*], HOME=/etc/zabbix mysql -sN -e "SELECT SUM(DATA_LENGTH + INDEX_LENGTH) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='$3'"
UserParameter=mysql.replication.discovery[*], HOME=/etc/zabbix mysql -sNX -e "show slave status"
UserParameter=mysql.slave_status[*], HOME=/etc/zabbix mysql -sNX -e "show slave status"
在/etc/zabbix
下新建.my.cnf
,内容如下:
[client]
user=zbx_monitor
password=zabbix
systemctl restart zabbix-agent
“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill
标 题:zabbix 4.4.7监控mysql