zarplata / zabbix-agent-extension-mysql

Zabbix extension for monitoring mysql.
23 stars 18 forks source link

Agent doesn't send any data except number of processes #8

Open Sopamo opened 5 years ago

Sopamo commented 5 years ago

I already enabled logging to see what might be the issue, and it seems like the agent just doesn't send anything. (I replaced all ips and passwords with placeholders, the correct values are used on the server)

5552:20190401:190058.216 EXECUTE_STR() command:' /usr/bin/zabbix-agent-extension-mysql -z serverip -m "mysqlip:3306" --user mysqluser --pass mysqlpass --type global' len:2 cmd_result:'OK'
5552:20190401:190058.216 Sending back [OK]
5552:20190401:190058.216 __zbx_zbx_setproctitle() title:'listener #2 [waiting for connection]'
5558:20190401:190059.164 In send_buffer() host:'serverip' port:serverport entries:0/100
5558:20190401:190059.165 End of send_buffer():SUCCEED

When I execute the command manually:

/usr/bin/zabbix-agent-extension-mysql -z serverip -m "mysqlip:3306" --user mysqluser --pass mysqlpass --type mysql

It just returns:

OK

I expected it to return all the status data next to "OK". Is that not a correct assumption? In the web interface I see a value for mysql processes, but everything else shows "no data". Could you give me a pointer on where to debug further?

tears-of-noobs commented 5 years ago

Hi @Sopamo . This behavior is fine. OK means that the extension successfully gets metrics from your MySQL server and send it to Zabbix server. Be note that hostname of your server (where you execute extension) should be the same as on Zabbix server. If you wanna see the metrics in a terminal - use ngrep

ngrep port 10051
Sopamo commented 5 years ago

Thank you for your fast response. I double checked the hostname, it is identical in the zabbix configuration to the value of the command hostname and also in the configuration file of the zabbix agent. I also checked the network traffic via ngrep. There are packets being sent, but they contain no data:

ngrep port 30051 -e
interface: eth0 (server/255.255.255.255)
filter: (ip or ip6) and ( port 30051 )
T agent:57066 -> server:30051 [A]
#
T agent:57066 -> server:30051 [AP]
ZBXD.3.......{"request":"active checks","host":"hostname"}
#
T server:30051 -> agent:57066 [A]
#
T server:30051 -> agent:57066 [AP]
ZBXD. .......{"response":"success","data":[]}
#
T server:30051 -> agent:57066 [AF]
#
T agent:57066 -> server:30051 [A]
...

I'm running the server on port 30051 instead of 10051. I did configure the agent accordingly and communication seems to be working, so this shouldn't be a problem, right? Is there a way to check if the mysql script is able to fetch data from the mysql server?

tears-of-noobs commented 5 years ago

Seems I know what's the problem. It's here https://github.com/zarplata/zabbix-agent-extension-mysql/blob/master/main.go#L36. Port of Zabbix server is non-configurable through a template. I'll notify you when fixed it.

Sopamo commented 5 years ago

Thanks a lot! This was the issue, I manually specified the port in the zabbix-agent-extension-mysql.conf file and now it's working perfectly. Would be great if we could set the port in the template, but for me it's not necessary at the moment.