kloczek / zabbix-templates

Zabbix templates
111 stars 65 forks source link

/usr/bin/mysql: unknown variable 'login-path=monitoring' #17

Open JeroenOmaha opened 5 years ago

JeroenOmaha commented 5 years ago

I get a /usr/bin/mysql: unknown variable 'login-path=monitoring' on all items in Zabbix.

Executing on host: zabbix_agentd -t "mysql.version" gives proper response: mysql.version [t|mysql Ver 15.1 Distrib 10.3.10-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2]

kloczek commented 5 years ago

Ha you just hit something which I forgot to document :/ Service MySQL template has macro:

{$MYSQL_CMD} => HOME=/var/lib/zabbix /usr/bin/mysql --login-path=monitoring -Nse

You need to create /var/lib/zabbix directory and using mysql_config_editor program store in it .mylogin.cnf file with details about username, password and address of the mysql server.

Just use command like below:

[root@domek ~]# HOME=/var/lib/zabbix mysql_config_editor set --user=monitoring --host=localhost --password
Enter password: 
[root@domek ~]# HOME=/var/lib/zabbix mysql_config_editor print
[client]
user = monitoring
password = *****
host = localhost

Than you need to change ownership of the /var/lib/zabbix [root@domek ~]# chown -R zabbix:zabbix /var/lib/zabbix; chmod 700 /var/lib/zabbix; chmod 600 /var/lib/zabbix/.*

FYI I've started writing my own agent loadable module to provide template template items abstractions but this module is not finished yet. https://github.com/kloczek/zbx_mod_mysql Whit this module will be not necessary to use external commands.

xainty commented 5 years ago

@kloczek after I do those steps I lost connection to my DB on zabbix, and coudn't open zabbix's website:

Error connecting to database: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111).

Any idea why this happened? And how can I avoid it?

kloczek commented 5 years ago

First: are you able to connect to the mysql database using mysql client command? I suppose that you not been able to do that :)