zabbix / zabbix-docker

Official Zabbix Dockerfiles
https://www.zabbix.com
GNU Affero General Public License v3.0
2.39k stars 1.38k forks source link

docker-compose_v2_centos_mysql_local.yaml: Zabbix agent on Zabbix server is unreachable for 5 minutes #390

Closed xtender closed 6 years ago

xtender commented 6 years ago

Hi,

There is something wrong with default docker-compose configuration docker-compose_v2_centos_mysql_local.yaml.

It starts fine, but I get "Zabbix agent on Zabbix server is unreachable for 5 minutes".

image

Port 10051 is open and zabbix server is listening it, but when I try to connect to this port, it closes connection:

[root@zabbix-server zabbix]# zabbix_get -s 127.0.0.1 -p 10051 -k agent.version
zabbix_get [267]: Check access restrictions in Zabbix agent configuration
[root@zabbix-server zabbix]# telnet 127.0.0.1 10051
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Connection closed by foreign host.
dotneft commented 6 years ago

The error means that Zabbix server can not connect to remote 127.0.0.1:10050 Zabbix agent. 10051 port is Zabbix server dedicated port. Please check our manual.

xtender commented 6 years ago

@dotneft no, if you check your config file https://github.com/zabbix/zabbix-docker/blob/4.0/docker-compose_v2_centos_mysql_latest.yaml you can see that it configured to 10051:

 zabbix-server:
  image: zabbix/zabbix-server-mysql:alpine-4.0-latest
  ports:
   - "10051:10051"

image

xtender commented 6 years ago

@dotneft and as I showed above, I can connect to this port, but zabbix server closes connection without response.

[root@zabbix-server zabbix]# telnet 127.0.0.1 10051
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
Connection closed by foreign host.
xtender commented 6 years ago

@dotneft Could you reopen this issue, please?

dotneft commented 6 years ago

It closes, because it is not Zabbix agent port! Please change Zabbix agent IP in host configuration to correct one.

KiltedKanuck commented 5 years ago

I am having the same issue. You mention that "Zabbix agent IP in host configuration to correct one" however I am not sure which file you are referring to. The docker-compose file or one of the .env_* files.

If I attach to the agent container, and view /etc/zabbix/zabbix_agent.conf, I see Server=zabbix-server. I can then ping zabbix-server from the command line.

Am I still missing something?

dopry commented 5 years ago

@xtender I think the issue is that the agent and server are running in separate containers with separate ips. When running in docker it might make sense to run them with the host network mode and to update the ip in configuration/hosts to the ip of the docker host. There may be a more streamlined way to do this... but zabbix, while distributed in containers isn't really configured out of the box to work with a containerized infrastructure.

@dotneft, I think we can all read the error. The question is why does it arise in the default compose examples? There is work to be done here to make the example work out of the box. Closing the issue just hides that work.

fabiobralmeida commented 5 years ago

Any solution?

dopry commented 5 years ago

I ended up setting the agent hostname in the container to match the docker host, using host networking mode and sharing the hosts pid namespace with the zabbix-agent. That seems to have gotten something reasonable working.

chuegel commented 5 years ago

same issue here

David-Development commented 5 years ago

As a workaround, you can open Zabbix, go to "Configuration" -> "Hosts". Edit the "Zabbix Server" entry by setting the "dns name" to "zabbix-agent". Make sure to select the dns button and hit save.

dotneft commented 5 years ago

Absolutely correct! Or use different DNS name for Zabbix agent container.