Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-20038

Zabbix-agent2 mysql plugin replication slave status monitoring is broken

    XMLWordPrintable

Details

    Description

      Summary
      MySQL slave's replication status always shows status of the first slave channel in SHOW SLAVE STATUS query output (ignoring {#MASTER_HOST} parameter) due to an error in /src/go/plugins/mysql/handler_replication_status.go

      Steps to reproduce:

      1. Set up zabbix_agent2 of a latest version (5.0.16-1+focal)
      2. Install a MySQL server (5.7 or 8.0)
      3. Set up 2 replication channels with master hosts: host1.mydomain.com, host2.my_domain.com
      4. Execute
        zabbix_get -s mysql-host.mydomain.com -p 10050 -k mysql.replication.get_slave_status["Main","","","","","","","host1.mydomain.com"] | jq '.["Channel_Name"]'.

        Return: "host1.mydomain.com" - that's correct

      1. Execute
        zabbix_get -s mysql-host.mydomain.com -p 10050 -k mysql.replication.get_slave_status["Main","","","","","","","host2.mydomain.com"] | jq '.["Channel_Name"]'.

        Return: "host1.mydomain.com" - that's WRONG data that belongs to host1.mydomain.com

      Explanation:
      The declaration of replicationSlaveStatusHandler() function doesn't have a 'params' array like databaseSizeHandler() does. Instead Master_Name parameter passed by zabbix_get is assigned to '_' (empty variable).
      After the 'SHOW SLAVE STATUS' query gets executed it's result is parsed by rows2data() function which returns an array of objects with each item representing it's own replication channel's status. It is saved to 'data' variable.
      In /src/go/plugins/mysql/handler_replication_status.go file, line 46 during conversion to JSON the value of 'data[0]' is taken which can only return status of the first slave channel status there is in 'data' array.

      Patch:
      The git patch file is attached to this issue. It fixes the issue and implements the check of Master_Name replication channel existence.

      Attachments

        Activity

          People

            alarionovs Aleksandrs Larionovs (Zabbix Team)
            Medvedev Vlad
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: