Setup a MySql/MariaDB Monitoring User:

root@web01:~# mysql -u root -p


mysql> create user 'zabbix'@'localhost' IDENTIFIED BY 'Password';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT USAGE ON *.* TO 'zabbix'@'localhost' IDENTIFIED BY 'Password';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

– To monitor MySql / MariaDB  create a file called userparameter_mysql.conf in /etc/zabbix/zabbix_agentd.conf.d

root@srv01:~# vi /etc/zabbix/zabbix_agentd.conf.d/userparameter_mysql.conf

– Add this lines

 
UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/etc/zabbix mysql -N | awk '{print $$2}' # My line

UserParameter=mysql.size[*],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$([[$

UserParameter=mysql.ping,HOME=/etc/zabbix mysqladmin ping | grep -c alive 

UserParameter=mysql.uptime,HOME=/etc/zabbix mysqladmin status | cut -f2 -d ":" | cut -f1 -d "T" | tr -d " "
UserParameter=mysql.threads,HOME=/etc/zabbix mysqladmin status | cut -f3 -d ":" | cut -f1 -d "Q" | tr -d " "
UserParameter=mysql.questions,HOME=/etc/zabbix mysqladmin status | cut -f4 -d ":"|cut -f1 -d "S" | tr -d " "
UserParameter=mysql.slowqueries,HOME=/etc/zabbix mysqladmin status | cut -f5 -d ":" | cut -f1 -d "O" | tr -d " "
UserParameter=mysql.qps,HOME=/etc/zabbix mysqladmin status | cut -f9 -d ":" | tr -d " "
UserParameter=mysql.version,mysql -V

Next, we need to give Zabbix the login information for our new user. Create a file called .my.cnf in /etc/zabbix and fill it with these lines:

root@srv01:~# nano /etc/zabbix/.my.cnf

[mysql]

user=zabbix

password=Password

[mysqladmin]

user=zabbix

password=Password

– Restart the zabbix agent service using the following command:

root@srv01:~# systemctl restart zabbix-agent