I use MariaDB 10.5.22 with multiple replications and want to monitor them with Zabbix. I had a few options for templates, "Template DB MySQL by Zabbix agent", "Template DB MySQL by ODBC", and "Template DB MySQL by Zabbix agent 2". Zabbix agent (no 2) was the one that I could make work.
1. Install Zabbix agent. My repository has 6.0.27. If it's already installed, skip to step 3.
2. Restart MariaDB since the installation of Zabbix agent killed it for some reason. (?!?)
Note: You may need to adjust this for your flavor of Linux.
3. Edit /etc/zabbix_agentd.conf.
5. Log in to MariaDB and create a user:
Note: if MariaDB is not bound to 127.0.0.1, change localhost appropriately in this and also the next step.
6. Create /var/lib/zabbix/.my.cnf
7. Create /etc/zabbix/zabbix_agentd.d/template_db_mysql.conf
Note: $3 is used a couple of times. This is for backwards compatibility with techniques that store the database host and port as macros.
8. Restart zabbix-agent.
9. From your Zabbix server, test to see if things are working. If not, hopefully the output of the below commands gives you enough information to start troubleshooting.
10. 11. Add "Template DB MySQL by Zabbix agent" to your host.
Let me know if you use this. Good luck.
1. Install Zabbix agent. My repository has 6.0.27. If it's already installed, skip to step 3.
Code:
yum install zabbix-agent
Code:
systemctl start mariadb
3. Edit /etc/zabbix_agentd.conf.
- In the Server section, enter the IP of your Zabbix server if not already set.
Code:Server=zabbix.server.ip,127.0.0.1
- In the Hostname section, set your database server's hostname if not already set.
- In the Include section, add this line: (you may choose a different directory if you prefer; just remember it for later)
Code:Include=/etc/zabbix/zabbix_agentd.d/*.conf
Code:
mkdir /etc/zabbix/zabbix_agentd.d
Code:
GRANT PROCESS, SHOW DATABASES, SLAVE MONITOR, SHOW VIEW ON *.* TO `zbx_monitor`@`localhost` IDENTIFIED BY 'SuperSecretPasswordHere'
6. Create /var/lib/zabbix/.my.cnf
Code:
[client] user='zbx_monitor' password='SuperSecretPasswordHere' host=localhost
Code:
UserParameter=mysql.ping[*], mysqladmin ping UserParameter=mysql.get_status_variables[*], mysql -sNX -e "show global status" UserParameter=mysql.version[*], mysqladmin -s version UserParameter=mysql.db.discovery[*], mysql -sN -e "show databases" UserParameter=mysql.dbsize[*], mysql -sN -e "SELECT COALESCE(SUM(DATA_LENGTH + INDEX_LENGTH),0) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='$3'" UserParameter=mysql.replication.discovery[*], mysql -sNX -e "show all slaves status" UserParameter=mysql.slave_status[*], mysql -sNX -e "show slave \"$3\" status"
8. Restart zabbix-agent.
Code:
systemctl restart zabbix-agent
Code:
zabbix_get -s database.server.ip -k vfs.fs.size[/,pused]
Code:
zabbix_get -s database.server.ip -k mysql.replication.discovery[]
Let me know if you use this. Good luck.