Ad Widget

Collapse

MySQL by Zabbix Agent problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aleksander237
    Junior Member
    • Apr 2022
    • 13

    #1

    MySQL by Zabbix Agent problem

    Hello,

    I want to monitor MySQL instance with zabbix agent. MySQL is installed on the linux server Ubuntu 20.04.6 LTS (up to date), and the zabbix agent is in the version 4.0.17. i followed this instruction. The only difference was, that the zabbix system user did not have the home directory, so I used command:

    Code:
    sudo usermod -d /var/lib/zabbix zabbix
    then tested the MySQL user/password configuration
    Code:
    sudo su -l zabbix -s /bin/bash
    mysql
    I can use mysql/mysqladmin programs without providing user/password as zabbix user. The MySQL's listening address and port are also correct in the zabbix macros.

    I can execute this command without any problems
    Code:
    zabbix_agentd -t "mysql.ping[localhost,3306]"
    when i run the command:
    Code:
    sudo zabbix_agentd -p
    I see some errors:
    Code:
    mysql.ping                                    [t|mysqladmin: connect to server at '-P' failed
    error: 'Unknown MySQL server host '-P' (-2)'
    Check that mysqld is running on -P and that the port is 3306.
    You can check this by doing 'telnet -P 3306']
    mysql.get_status_variables                    [t|ERROR 2005 (HY000): Unknown MySQL server host '-P' (-2)]
    mysql.version                                 [t|]
    mysql.db.discovery                            [t|ERROR 2005 (HY000): Unknown MySQL server host '-P' (-2)]
    mysql.dbsize                                  [t|ERROR 2005 (HY000): Unknown MySQL server host '-P' (-2)]
    mysql.replication.discovery                   [t|ERROR 2005 (HY000): Unknown MySQL server host '-P' (-2)]
    mysql.slave_status                            [t|ERROR 2005 (HY000): Unknown MySQL server host '-P' (-2)]
    The definition for ping command from the /etc/zabbix/zabbix_agentd.conf.d/template_db_mysql.sql.conf file is:
    Code:
    UserParameter=mysql.ping[*], mysqladmin -h"$1" -P"$2" ping
    so it looks like the zabbix agent do not inject localhost ($1) and port ($2) into executed commands.

    The Zabbix Agent works in the Active Mode only. In the Zabbix Server's user interface I see various server metrics, like cpu, memory, etc, and the metrics are updated according to the interval. Unfortunately the items from the MySQL template are not executed The columns Last Check, Last Value are empty. No errors though. If I force the execution nothing really happens besides the success confirmation on the top of the screen "Request sent successfully"

    I already saw this post, but my problem is different.

    What am I missing?

  • aleksander237
    Junior Member
    • Apr 2022
    • 13

    #2
    The MySQL template provided by Zabbix is for passive agent only.

    Comment

    • cyber
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Dec 2006
      • 4806

      #3
      Originally posted by aleksander237
      The MySQL template provided by Zabbix is for passive agent only.
      Which does not mean a thing... UserParameter does not care, is it defined as active or passive...

      But you may want to remove that space after a comma in UserParameter definition...

      Comment

      • dunnsland
        Member
        • Dec 2021
        • 81

        #4
        Hello,

        What was the solution to this post?
        I am facing exactly the same issue. I have followed the instructions but still cannot see mysql stats added to my monitoring.
        I have tried to run the following command without success.

        root@ipbackup:/var/lib/zabbix# zabbix_agentd -t mysql.ping
        mysql.ping [t|mysqladmin: connect to server at '-P' failed
        error: 'Unknown MySQL server host '-P' (-2)'
        Check that mysqld is running on -P and that the port is 3306.
        You can check this by doing 'telnet -P 3306']

        If I try to use the full syntax, I do not understand why the zabbix_agentd is using the user root to authenticate on the mysql. Why is it not using the /var/lib/zabbix/.my.cng file?

        root@ipbackup:/var/lib/zabbix# zabbix_agentd -t "mysql.ping[localhost,3306]"
        mysql.ping[localhost,3306] [t|mysqladmin: connect to server at 'localhost' failed
        error: 'Access denied for user 'root'@'localhost' (using password: NO)']

        If I try to test from within the zabbix dashboard / configuration then I get a different error.See below

        Click image for larger version

Name:	image.png
Views:	305
Size:	7.7 KB
ID:	499376

        Any ideas

        Lawrence

        Comment

        Working...