Monitoring mysql/mariadb

[Standard template] uses keys like mysql.ping ["{$ MYSQL.HOST}", "{$ MYSQL.PORT}"]. This may be useful if zabbix-agent is not on the same host with the base, or if the port differs from the standard one on the base. In the usual case, it seems to me an unnecessary complication.

A small addition to the installation from the link above:

After creating a user in mysql and distributing rights to it, remember to write flush privileges;. The file for connecting to mysql must be available zabbix, do chmod 440 / var / lib / zabbix / .my.cnf. If you do chmod 777 with all your heart, then it will refuse to take data from there. It can be thrown anywhere, in the same / etc / zabbix for example, since anyway, you will have to specify the path to it in the UserParameter.

It is also worth making zabbix the owner of these folders: sh chown -R zabbix: zabbix / etc / zabbix && chown -R zabbix: zabbix / var / lib / zabbix, If not the standard mariadb is installed on Centos, but for examplerh-mariadb102-mariadb, then the mysql and mysqladmin utilities will not be in / usr / bin / but / opt / rh / rh-mariadb102 / root / usr / bin. Therefore, when using UserParameter in the agent config, besides HOME, you also need to add PATH or write the full path to the utility: UserParameter = mysql.ping, HOME = / var / lib / zabbix PATH =" $ PATH: / opt / rh / rh-mariadb102 / root / usr / bin "mysqladmin ping. Alternatively, you can install the same package with the usual mariadb =) It was not possible to add the path through /etc/profile.d/ or / etc / environment. You can also try to make zabbix a regular user and add PATH = $ {PATH}: / opt / rh / rh-mariadb102 / root / usr / bin to .bashrc An attempt to fix the systemd unit and start the agent from another user gave nothing ... 1

On a crutch, you can see $ PATH or printenv from zabbix by adding Server 127.0.0.1 to the agent config:

yum install -y zabbix-get
echo "UserParameter=test1, echo \$PATH" >> /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf 
zabbix_get -s 127.0.0.1 -p 10050 -k test1
Built on GitHub with MkDocs and Pure theme