Ad Widget

Collapse

No consigo monitorizar mysql con el template mysql by zabbix agent

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • uticox
    Junior Member
    • May 2023
    • 3

    #1

    No consigo monitorizar mysql con el template mysql by zabbix agent

    Buenas tardes. No consigo monitorizar mi base de datos Mysql utilizando el template mysql by zabbix agent. Dispongo de la siguiente configuración:

    Mysql version 8.0.27
    rpm -qa |grep zabbix
    zabbix6.0-agent-6.0.16-1.el8.x86_64
    zabbix6.0-6.0.16-1.el8.x86_64
    pcp-export-zabbix-agent-5.3.1-5.0.2.el8.x86_64
    zabbix6.0-selinux-6.0.16-1.el8.noarch​

    /etc/zabbix/zabbix_agentd.d/template_db_mysql.conf

    #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...ion-files.html
    #The file must have three strings:
    #[client]
    #user='zbx_monitor'
    #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" zz0.cq8h1oiqyljzz​

    /etc/zabbix_agentd.conf
    PidFile=/run/zabbix/zabbix_agentd.pid
    LogFile=/var/log/zabbix/zabbix_agentd.log
    LogFileSize=0
    Server=ip server
    ListenPort=10050
    ServerActive=ip server
    Hostname=Nameserver
    Include=/etc/zabbix/zabbix_agentd.d/template_db_mysql.conf​

    /var/lib/zabbix/.my.cnf

    [client]
    user='zabbix'
    password='mipassword'

    He probado con la opción sin éxito:
    default-authentication-plugin=caching_sha2_password

    Error de zabbix server log:
    noname.xml:1: parser error : Start tag expected, '<' not found
    ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.x.X:3306' (13)


    Pruebas realizadas. En la macro del template tambien he probado con la 127.0.0.1

    Si realizo un telnet en la propia maquina donde esta mysql obtengo esta respuesta:
    ​[root@xxx-db zabbix_agentd.d]# telnet localhost 3306
    Trying ::1...
    Connected to localhost.
    Escape character is '^]'.
    U
    8.0.27-commercialxKSfD29B�(c-5`6B
    caching_sha2_password2#08S01Got timeout reading communication packetsConnection closed by foreign host.

    Desde el servidor:
    [root@xxx-reports ~]# telnet 192.168.89.20 3306
    Trying 192.168.x.X...
    Connected to 192.168.x.X.
    Escape character is '^]'.
    U
    8.0.27-commercialy*
    M8r


    Help meeeee

    ​​​
    Last edited by uticox; 18-05-2023, 10:15.
  • Potato-Warrior
    Junior Member
    • May 2023
    • 12

    #2
    i dont understand but if ur mysql sever is on a separate machine u need to create a mysql user for that ip/server like

    for database

    CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'Password/1234';

    grant all privileges on zabbix.* to zabbix@localhost;


    FLUSH PRIVILEGES;

    for Application server but in mysql on ur database


    CREATE USER 'zabbix'@'Allicationserver-IP' IDENTIFIED BY 'Password/1234';

    GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'zabbix'@'Allicationserver-IP' WITH GRANT OPTION;

    FLUSH PRIVILEGES;


    if u have a separate web-interface-server aswell



    CREATE USER 'zabbix'@'Webinterface-IPserver-IP' IDENTIFIED BY 'Password/1234';

    GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'zabbix'@'Webinterface-IP-IP' WITH GRANT OPTION;

    FLUSH PRIVILEGES;

    This is how i did it and its working for now.
    good luck.

    Comment

    • uticox
      Junior Member
      • May 2023
      • 3

      #3
      the user is created correctly and with the appropriate permissions, but not connecting. I think it is not taking correctly the file hosted in /var/lib/zabbix that contain the user and the password.

      Comment

      Working...