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

Linux Disk Quota Management Graphical Example

Disk quota is the storage limit of a specified di...

Use vue3 to implement a human-cat communication applet

Table of contents Preface Initialize the project ...

Win10 uses Tsinghua source to quickly install pytorch-GPU version (recommended)

Check whether your cuda is installed Type in the ...

jQuery implements a simple carousel effect

Hello everyone, today I will share with you the i...

How to use vue-bootstrap-datetimepicker date plugin in vue-cli 3

Demand Background Recently, I plan to use Vue and...

Understanding the CSS transform-origin property

Preface I recently made a fireworks animation, wh...

Ideas and codes for implementing Vuex data persistence

What is vuex vuex: is a state manager developed s...

JavaScript design pattern learning proxy pattern

Table of contents Overview Implementation Protect...

Initial summary of the beginner's website building tutorial

After writing these six articles, I started to fee...

Vue implements a scroll bar style

At first, I wanted to modify the browser scroll b...

Binary Type Operations in MySQL

This article mainly introduces the binary type op...

Three ways to share component logic in React

Without further ado, these three methods are: ren...