Ad Widget

Collapse

zabbix mysql template using the incorrect database user

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • extremeeryan
    Junior Member
    • Jul 2019
    • 7

    #1

    zabbix mysql template using the incorrect database user

    I'm trying to set up mysql monitoring with this template: https://www.zabbix.com/integrations/mysql. We use zabbix server version 5.0.

    I followed all of the instructions and placed the userparameter file in /etc/zabbix/zabbix_agentd.d on the host we're attempting to monitor. I also have the following at /var/lib/zabbix/.my.cnf:

    Code:
    [client]
    user=zbx_monitor
    password=<password>
    Previously, the zabbix user had /nonexistent set as its home directory. I created /var/lib/zabbix and set that to be the home directory:

    Code:
    # cat /etc/passwd | grep zabbix
    zabbix:x:112:120::/var/lib/zabbix:/bin/false
    
    # ls -la /var/lib/zabbix/
    total 12
    drwxrwx--- 2 zabbix zabbix 4096 Nov 6 14:48 .
    drwxr-xr-x 46 root root 4096 Dec 27 2019 ..
    -rw-r--r-- 1 zabbix root 91 Nov 6 13:37 .my.cnf
    When I try to retrieve items from the zabbix server, however, it's still trying to access the database with the "zabbix" user instead of "zbx_monitor":

    Code:
    # zabbix_get -s host -k mysql.ping["host","3306"]
    mysqladmin: connect to server at 'host' failed
    error: 'Access denied for user 'zabbix'@'localhost' (using password: NO)'
    I have restarted the agent multiple times. For reference, here is the complete userparameter file obtained from https://git.zabbix.com/projects/ZBX/...b/mysql_agent:

    Code:
    #template_db_mysql.conf created by Zabbix for "Template DB MySQL" and Zabbix 4.2
    #For OS Linux: You need create .my.cnf in zabbix-agent home directory (/var/lib/zabbix by default)
    #For OS Windows: You need add PATH to mysql and mysqladmin and create my.cnf in %WINDIR%\my.cnf,C:\my.cnf,BASEDIR\my.cnf https://dev.mysql.com/doc/refman/5.7/en/option-files.html
    #The file must have three strings:
    #[client]
    #user='zbx_monitor'
    #password='<password>'
    #
    UserParameter=mysql.ping[*], mysqladmin -h"$1" -P"$2" ping
    UserParameter=mysql.get_status_variables[*], mysql -h"$1" -P"$2" -sNX -e "show global status"
    UserParameter=mysql.version[*], mysqladmin -s -h"$1" -P"$2" version
    UserParameter=mysql.db.discovery[*], mysql -h"$1" -P"$2" -sN -e "show databases"
    UserParameter=mysql.dbsize[*], mysql -h"$1" -P"$2" -sN -e "SELECT COALESCE(SUM(DATA_LENGTH + INDEX_LENGTH),0) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='$3'"
    UserParameter=mysql.replication.discovery[*], mysql -h"$1" -P"$2" -sNX -e "show slave status"
    UserParameter=mysql.slave_status[*], mysql -h"$1" -P"$2" -sNX -e "show slave status"
    Is there something obvious that I'm missing?

    Thanks,

    Emmet
Working...