-
Patch request
-
Resolution: Fixed
-
Trivial
-
None
-
None
-
OS: Ubuntu 20.04.2 LTS
Zabbix-agent2: 5.0.16-1+focal
DB Template: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/mysql_agent2/template_db_mysql_agent2.yaml (05.06.2021)
MySQL: 5.7.32-35, 8.0.25-15
jq: jq-1.6
-
Sprint 103 (Aug 2023), Sprint 104 (Sep 2023), Sprint 105 (Oct 2023)
-
1
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:
- Set up zabbix_agent2 of a latest version (5.0.16-1+focal)
- Install a MySQL server (5.7 or 8.0)
- Set up 2 replication channels with master hosts: host1.mydomain.com, host2.my_domain.com
- 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
- 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.