Hi,
I have Zabbix Agent 7 installed, and it has worked well. I wanted to add MySQL metrics following these instructions, and I got it working using some hacks that I would like to avoid, if at all possible. Mainly two things, for now:
- It doesn't use the "expected"
- It does not pick up the MySQL credentials from my home path, so I'm forced to explicitly set them using
Context:
Relevant Zabbix agent parameters:
The agent runs as the
Zabbix home with MySQL credentials:
Without explicitly setting credentials path:
Don't understand where it's getting that username from, exactly.
Most of this is probably explained by these results, but my question, then, is whether I can somehow set the environment of the zabbix user appropriately:
I have Zabbix Agent 7 installed, and it has worked well. I wanted to add MySQL metrics following these instructions, and I got it working using some hacks that I would like to avoid, if at all possible. Mainly two things, for now:
- It doesn't use the "expected"
PATH, so I'm forced to use full paths for binaries.- It does not pick up the MySQL credentials from my home path, so I'm forced to explicitly set them using
--defaults-extra-file.Context:
Relevant Zabbix agent parameters:
Bash:
UserParameter=mysql.ping[*], /usr/local/bin/mysqladmin --defaults-extra-file=/var/db/zabbix/.my.cnf -h"$1" -P"$2" ping
UserParameter=mysql.ping2[*], /usr/local/bin/mysqladmin -h"$1" -P"$2" ping
UserParameter=test.env,env
UserParameter=test.id,id
UserParameter=test.home,echo $HOME
The agent runs as the
zabbix user, as per ps, and the id parameter.
Bash:
$ zabbix_get -s 10.7.11.116 -k test.id
uid=122(zabbix) gid=122(zabbix) groups=122(zabbix)
Zabbix home with MySQL credentials:
Bash:
$ getent passwd zabbix
zabbix:*:122:122:Zabbix NMS:/var/db/zabbix:/bin/sh
$ ls -lA /var/db/zabbix/
total 1
-rw------- 1 zabbix zabbix 72 Nov 13 15:28 .my.cnf
sudo -u zabbix mysql gets me into the MySQL prompt, so the credentials are fine.Without explicitly setting credentials path:
Bash:
$ zabbix_get -s 10.7.11.116 -k mysql.ping2[localhost,3306]
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'etfz'@'localhost' (using password: NO)'
Most of this is probably explained by these results, but my question, then, is whether I can somehow set the environment of the zabbix user appropriately:
Bash:
$ zabbix_get -s 10.7.11.116 -k test.env
LANG=C.UTF-8
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DEBUG_DO=:
PWD=/
DEBUG_SKIP=
HOME=/
_TTY=/dev/pts/3
MM_CHARSET=UTF-8
DEBUGGING=
BLOCKSIZE=K
RC_PID=88090
$ zabbix_get -s 10.7.11.116 -k test.home
/
Bash:
$ sudo -u zabbix env
EDITOR=nano
LANG=C.UTF-8
TERM=xterm-clear
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/etfz/bin
MAIL=/var/mail/zabbix
LOGNAME=zabbix
USER=zabbix
HOME=/var/db/zabbix
SHELL=/bin/sh
SUDO_COMMAND=/usr/bin/env
SUDO_USER=etfz
SUDO_UID=1009
SUDO_GID=0
SUDO_HOME=/home/etfz
SUDO_TTY=/dev/pts/0