Ad Widget

Collapse

Zabbix-agent2 running in Alpine Docker cannot check Docker itself

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mlazzarotto
    Junior Member
    • Feb 2022
    • 14

    #1

    Zabbix-agent2 running in Alpine Docker cannot check Docker itself

    Hi, completely noob here, I have some experience with Nagios (which I use for work) and I've installed Zabbix server using docker-compose on a VM on Proxmox on my home lab.

    The agent (which is installed as alpine Docker container) works fine for checking the host os, but cannot get Docker stats.
    It says "Docker: Service is down" but Docker is not down.
    If I enter the host details, I see "Docker: Ping" as "Down (0)", and if I look at "Docker: Get info" I get this message:
    Cannot fetch data: Get "http://1.28/info": dial unix /var/run/docker.sock: connect: permission denied.

    I know that zabbix-agent2 container has access to /var/run/docker.sock because I added that to docker compose, and on the host I added a zabbix user which is member of docker group (which is owner of docker.sock).

    If I run the command zabbix_agent2 -t docker.ping from the agent container, I get docker.ping [s|0].
  • mlazzarotto
    Junior Member
    • Feb 2022
    • 14

    #2
    Bump
    This is the output if run from command line on the container agent.
    Code:
    bash-5.1$ zabbix_agent2 -v -t docker.ping
    2022/03/03 17:15:41.097561 using plugin 'Agent' (built-in) providing following interfaces: exporter
    2022/03/03 17:15:41.097963 using plugin 'Ceph' (built-in) providing following interfaces: exporter, runner, configurator
    2022/03/03 17:15:41.098208 using plugin 'Cpu' (built-in) providing following interfaces: exporter, collector, runner
    2022/03/03 17:15:41.098476 using plugin 'Docker' (built-in) providing following interfaces: exporter, configurator
    2022/03/03 17:15:41.098711 using plugin 'File' (built-in) providing following interfaces: exporter, configurator
    2022/03/03 17:15:41.098931 using plugin 'Hw' (built-in) providing following interfaces: exporter, configurator
    2022/03/03 17:15:41.099124 using plugin 'Kernel' (built-in) providing following interfaces: exporter
    2022/03/03 17:15:41.099296 using plugin 'Log' (built-in) providing following interfaces: exporter, configurator
    2022/03/03 17:15:41.099458 using plugin 'MQTT' (built-in) providing following interfaces: watcher, configurator
    2022/03/03 17:15:41.099607 using plugin 'Memcached' (built-in) providing following interfaces: exporter, runner, configurator
    2022/03/03 17:15:41.099733 using plugin 'Memory' (built-in) providing following interfaces: exporter
    2022/03/03 17:15:41.099880 using plugin 'Modbus' (built-in) providing following interfaces: exporter, configurator
    2022/03/03 17:15:41.100025 using plugin 'Mongo' (built-in) providing following interfaces: exporter, runner, configurator
    2022/03/03 17:15:41.100178 using plugin 'Mysql' (built-in) providing following interfaces: exporter, runner, configurator
    2022/03/03 17:15:41.100321 using plugin 'NetIf' (built-in) providing following interfaces: exporter
    2022/03/03 17:15:41.100473 using plugin 'Oracle' (built-in) providing following interfaces: exporter, runner, configurator
    2022/03/03 17:15:41.100617 using plugin 'Postgres' (built-in) providing following interfaces: exporter, runner, configurator
    2022/03/03 17:15:41.100813 using plugin 'Proc' (built-in) providing following interfaces: exporter, collector
    2022/03/03 17:15:41.100965 using plugin 'ProcExporter' (built-in) providing following interfaces: exporter
    2022/03/03 17:15:41.101121 using plugin 'Redis' (built-in) providing following interfaces: exporter, runner, configurator
    2022/03/03 17:15:41.101266 using plugin 'Smart' (built-in) providing following interfaces: exporter, configurator
    2022/03/03 17:15:41.101445 using plugin 'Sw' (built-in) providing following interfaces: exporter, configurator
    2022/03/03 17:15:41.101611 using plugin 'Swap' (built-in) providing following interfaces: exporter
    2022/03/03 17:15:41.101762 using plugin 'SystemRun' (built-in) providing following interfaces: exporter, configurator
    2022/03/03 17:15:41.101912 using plugin 'Systemd' (built-in) providing following interfaces: exporter
    2022/03/03 17:15:41.102062 using plugin 'TCP' (built-in) providing following interfaces: exporter, configurator
    2022/03/03 17:15:41.102212 using plugin 'UDP' (built-in) providing following interfaces: exporter, configurator
    2022/03/03 17:15:41.102363 using plugin 'Uname' (built-in) providing following interfaces: exporter
    2022/03/03 17:15:41.102610 using plugin 'Uptime' (built-in) providing following interfaces: exporter
    2022/03/03 17:15:41.102773 using plugin 'Users' (built-in) providing following interfaces: exporter, configurator
    2022/03/03 17:15:41.102925 using plugin 'VFSDev' (built-in) providing following interfaces: exporter, collector
    2022/03/03 17:15:41.103052 using plugin 'VFSDir' (built-in) providing following interfaces: exporter
    2022/03/03 17:15:41.103203 using plugin 'VfsFs' (built-in) providing following interfaces: exporter
    2022/03/03 17:15:41.103408 using plugin 'WebCertificate' (built-in) providing following interfaces: exporter, configurator
    2022/03/03 17:15:41.103581 using plugin 'WebPage' (built-in) providing following interfaces: exporter, configurator
    2022/03/03 17:15:41.103733 using plugin 'ZabbixAsync' (built-in) providing following interfaces: exporter
    2022/03/03 17:15:41.104054 using plugin 'ZabbixStats' (built-in) providing following interfaces: exporter, configurator
    2022/03/03 17:15:41.104211 lowering the plugin ZabbixSync capacity to 1 as the configured capacity 100 exceeds limits
    2022/03/03 17:15:41.104361 using plugin 'ZabbixSync' (built-in) providing following interfaces: exporter
    2022/03/03 17:15:41.104580 [Modbus] Config is valid
    2022/03/03 17:15:41.104853 starting manager
    2022/03/03 17:15:42.001038 [0] processing update request (1 requests)
    2022/03/03 17:15:42.001445 [0] registering new client
    2022/03/03 17:15:42.001760 [0] adding new request for key: 'system.hostname'
    2022/03/03 17:15:42.002109 [0] created direct exporter task for plugin 'Uname' itemid:0 key 'system.hostname'
    2022/03/03 17:15:42.002391 executing direct exporter task for key 'system.hostname'
    2022/03/03 17:15:42.002599 executed direct exporter task for key 'system.hostname'
    2022/03/03 17:15:42.002809 [2] processing update request (1 requests)
    2022/03/03 17:15:42.003009 [2] registering new client
    2022/03/03 17:15:42.003180 [2] adding new request for key: 'docker.ping'
    2022/03/03 17:15:42.003330 [2] created direct exporter task for plugin 'Docker' itemid:0 key 'docker.ping'
    2022/03/03 17:15:42.003475 [2] created configurator task for plugin Docker
    2022/03/03 17:15:42.003626 plugin Docker: executing configurator task
    2022/03/03 17:15:42.003816 executing direct exporter task for key 'docker.ping'
    2022/03/03 17:15:42.004120 executed direct exporter task for key 'docker.ping'
    docker.ping [s|0]
    2022/03/03 17:15:42.004438 manager has been stopped

    Comment

    • mlazzarotto
      Junior Member
      • Feb 2022
      • 14

      #3
      Fixed adding
      user: root
      to my compose code

      Code:
      zabbix-agent2:
      user: root
      container_name: zabbix-agent2
      restart: unless-stopped
      image: zabbix/zabbix-agent2:alpine-6.0-latest
      ...

      Comment

      • cyber
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Dec 2006
        • 4807

        #4
        Not knowing too much about docker etc... You fixed it by running it as root (who has all privileges), which in my mind is not a fix, but unsecure workaround..

        Comment

        • mlazzarotto
          Junior Member
          • Feb 2022
          • 14

          #5
          Originally posted by cyber
          Not knowing too much about docker etc... You fixed it by running it as root (who has all privileges), which in my mind is not a fix, but unsecure workaround..
          Yes, it's just a workaround but I didn't found any other fix, so...

          Comment

          • antoxic
            Junior Member
            • Mar 2022
            • 1

            #6
            My reply can be late, but adding group 998 to docker compose image helps.

            The problem is that zabbix user does not have permission to access the mounted docker socket, so from the compose file you add zabbix user to docker group.

            Code:
            group_add:
              - "998"
            my full zabbix-agent config from docker-compose.yml looks like this:
            Code:
            zabbix-agent:
            image: zabbix/zabbix-agent2:alpine-latest
            container_name: zabbix-agent
            privileged: true
            profiles:
            - full
            - all
            ports:
            - "10050:10050"
            volumes:
            - /etc/localtime:/etc/localtime:ro
            - /etc/timezone:/etc/timezone:ro
            - /var/run/docker.sock:/var/run/docker.sock:ro
            - ./zbx_env/etc/zabbix/zabbix_agentd.d:/etc/zabbix/zabbix_agentd.d:ro
            - ./zbx_env/var/lib/zabbix/modules:/var/lib/zabbix/modules:ro
            - ./zbx_env/var/lib/zabbix/enc:/var/lib/zabbix/enc:ro
            - ./zbx_env/var/lib/zabbix/ssh_keys:/var/lib/zabbix/ssh_keys:ro
            group_add:
            - "998"
            deploy:
            mode: global
            links:
            - zabbix-server
            env_file:
            - ./env_vars/.env_agent
            pid: "host"
            networks:
            zbx_net_backend:
            aliases:
            - zabbix-agent
            - zabbix-agent-passive
            - zabbix-agent-alpine
            stop_grace_period: 5s
            labels:
            com.zabbix.description: "Zabbix agent"
            com.zabbix.company: "Zabbix LLC"
            com.zabbix.component: "zabbix-agentd"
            com.zabbix.os: "alpine"
            restart: unless-stopped

            Comment

            Working...