How to deploy zabbix_agent in docker

How to deploy zabbix_agent in docker

zabbix_agent deployment:

Recommendation: zabbix_agent is deployed separately using docker-compose

Startup method:

1. Start in run mode

docker run --rm --network zabbix --name zabbix_agent --link zabbix_server:zabbix-server -e ZBX_HOSTNAME="mythird" -e ZBX_SERVER_PORT="10051" -e ZBX_SERVER_HOST="172.22.0.3" -p 3998:10050 -d zabbix/zabbix-agent:alpine-3.0-latest

2. docker-compose.yml

Directory structure:

[root@container1 zabbix_agent]# cat etc/env_agent 
ZBX_SERVER_HOST=172.22.0.3
ZBX_SERVER_PORT=10051
ZBX_HOSTNAME=kgtest
ZBX_LISTENPORT=3050
ZBX_LOGTYPE=file
ZBX_LOGFILE=/tmp/zabbix_agentd.log

a. When deployed in the same docker-compose.yml as zabbix_server/zabbix_proxy, the only difference is the setting of links, in the format of servicename: name of zabbix

  zabbix_agent:
    image: zabbix/zabbix-agent:alpine-3.0-latest
    container_name: zabbix_agent
    ports:
     - "10050:10050"
    environment:
     ZBX_HOSTNAME: kg
    volumes:
     - /etc/localtime:/etc/localtime:ro
    links:
     - zabbix_server:zabbix-server
    user: root
    privileged: true
    restart: always
    networks:
     - zabbix

b. Single deployment:

A. Docker bridge mode: If it is on the same machine, you need to use the same network as zabbix_server/zabbix_proxy

[root@container1 zabbix_agent]# cat docker-compose.yml 
version: "3"
services:
  zabbix_agent:
    image: zabbix/zabbix-agent:alpine-3.0-latest
    container_name: zabbix_agent3
    ports:
     - "3999:3050"
    env_file:
     - ./etc/env_agent
    volumes:
     - /etc/localtime:/etc/localtime:ro
     - ./etc/docker-entrypoint.sh:/usr/bin/docker-entrypoint.sh:ro   
     - ./etc/zabbix_agentd.d:/etc/zabbix/zabbix_agentd.d  
     - ./scripts:/data/zabbix/scripts
     - ./logs:/tmp
    user: root
    privileged: true
    restart: always
    networks:
     - zabbix
networks:
  zabbix:
    external: true

B. Use docker's host mode: to monitor the number of TCP connections

Note: When using host mode, you must open the port that zabbix_agent maps to on the local machine in the firewall.

[root@kg zabbix_agent]# cat docker-compose.yml 
version: "3"
services:
  zabbix_agent:
    image: zabbix/zabbix-agent:alpine-3.0-latest
    container_name: zabbix_agent
    ports:
     - "3050:3050"
    env_file:
     - ./etc/env_agent
    volumes:
     - /etc/localtime:/etc/localtime:ro
     - ./etc/docker-entrypoint.sh:/usr/bin/docker-entrypoint.sh:ro
     - ./etc/zabbix_agentd.d:/etc/zabbix/zabbix_agentd.d
     - ./scripts:/data/zabbix/scripts
     - ./logs:/tmp
    user: root
    privileged: true
    restart: always
    #In order to implement TCP connection monitoring, you need to use the host network mode network_mode: host

Check if zabbix_agent is working properly:

First, after starting zabbix_agent, test whether the agent is reachable in the server/proxy container:

Web interface settings:

a. If the agent is not automatically discovered, you need to manually add the agent host.

When the agent and server/proxy are on the same machine, the IP address must be the intranet IP address assigned by Docker, and the port is the port in the container, not the port mapped to the local machine.

b. Set to automatically discover the agent machine

Note: If you set it to be added to a host group, you need to create the host group first.

Possible problems:

1. Error: temporarily disabling Zabbix agent checks on host "kgtest": host unavailable

Solution:

a. If it is bridge mode, please check whether the agent's ZBX_HOSTNAME is the same as the host name in the host configuration.

b. If it is host mode, please check whether the firewall has opened the agent mapping to the local port. Test: telnet local IP port

2. Error: Received empty response from Zabbix Agent at [192.168.5.114]. Assuming that agent dropped connection because of access permissions.

Among them, 192.168.5.114 is the external/intranet IP of the agent

reason:

a. Use zabbix_proxy proxy: The agent's ZBX_SERVER_HOST is set to the IP of zabbix_proxy (172.22.0.6), but the host configuration in the web interface selects no agent.

Solution:

Select to use the specified agent program

b. Directly connect to zabbix_server:

A. The agent's ZBX_SERVER_HOST is set to 127.0.0.1 instead of the zabbix_server IP (172.22.0.3)

Solution:

Set the agent's ZBX_SERVER_HOST to the IP address of zabbix_server

B. The log in zabbix_agent reports an error: Message from 172.20.0.6 is missing header. Message ignored.

Reason: This is because the zabbix_agent and zabbix_server versions are different and incompatible. zabbix_agent uses the new version, but zabbix_server uses the old version.

Solution: Check the versions of zabbix_agent and zabbix_server

3. When performing automatic discovery in the Chinese interface, the following error message appears:

After switching to the English version interface, there will be no problem in operation

You need to change the encoding format of character_set_server in mysql in zabbix_server. It is found that the online operation of mysql cannot solve the problem. It is necessary to change the mysql service startup script in zabbix_server. For the solution, you can check my other article "Docker deployment zabbix_server"

This is the end of this article about the steps to deploy zabbix_agent with docker. For more information about deploying zabbix_agent with docker, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Zabbix monitoring docker application configuration
  • Create a code example of zabbix monitoring system based on Dockerfile
  • Detailed explanation of the process of installing Zabbix using Docker and configuring custom monitoring items

<<:  8 JS reduce usage examples and reduce operation methods

>>:  Navicat connects to MySQL8.0.11 and an error 2059 occurs

Recommend

Usage of Linux userdel command

1. Command Introduction The userdel (user delete)...

How to delete folders, files, and decompress commands on Linux servers

1. Delete folders Example: rm -rf /usr/java The /...

Detailed explanation of docker network bidirectional connection

View Docker Network docker network ls [root@maste...

MySQL 8.0.17 installation and configuration graphic tutorial

This article records the graphic tutorial of MySQ...

Implementation of element input box automatically getting focus

When making a form in a recent project, I need to...

A brief discussion on the lazy loading attribute pattern in JavaScript

Table of contents 1. Introduction 2. On-demand at...

What are the rules for context in JavaScript functions?

Table of contents 1. Rule 1: Object.Method() 1.1 ...

This article helps you understand PReact10.5.13 source code

Table of contents render.js part create-context.j...

Element-ui directly clicks on the cell in the table to edit

Table of contents Achieve results Implementation ...

mysql delete multi-table connection deletion function

Deleting a single table: DELETE FROM tableName WH...

js implements a simple countdown

This article example shares the specific code of ...

Example of how to set div background transparent

There are two common ways to make div background ...