Automatically monitoring of docker using Zabbix

Standard

Docker is a perfect tool to quickly create many environments to new services. That creation process is so easy, in some cases this is done automatically by other tool or script.

static1.squarespace.com

Monitor to avoid surprises

Problems can happens and IT team should be ready to figure it out before causing unavailability.

Problem

How can a monitoring team follow this quickly creation process and keep all this new assets in monitoring system? We need to automatically monitor all containers.

Solution

I developed some scripts to list docker containers, add it in Zabbix using LLD feature and monitor these new hosts.

Unfortunately we need special access to monitor that information in docker, so I used sudo and root cron job.

Follow the items monitored by this solution:

  • CPU used percent
  • Memory used percent
  • Bytes received and sent per second
  • Packages received and sent
  • Packages received and sent, but dropped
  • Packages received and sent with erros

Do you wanna know the solution before test? Take a look at the video:

I tested tested in the follow environment:

  • python 2.7.9
  • docker 1.6
  • zabbix agent and server 2.4

If you test in a different one, please let me know.

  • andre yokoda

    Hi, Could you please help me?
    When I execute file ./docker_stats.py on Ubuntu 16.04.2 LTS error below occurs?

    Traceback (most recent call last):
    File “./docker_stats.py”, line 4, in
    from docker_servive import DockerService
    ImportError: No module named docker_servive

    root@lnx-soft031209:/etc/zabbix# pip freeze | grep docker
    docker-compose==1.5.2
    docker-py==1.2.3
    docker-pycreds==0.2.1
    dockerpty==0.3.4

    Docker –> Server Version: 1.12.6

    And Zabbix server:

    Template Docker Host: check containers system.run[/usr/bin/sudo /etc/zabbix/docker_stats.py] 1m 90d 365d Zabbix agent Not supported

    Information:
    Received value [Traceback (most recent call last): File “/etc/zabbix/docker_stats.py”, line 4, in from docker_servive import DockerServiceImportError: No module named docker_servive] is not suitable for value type [Numeric (unsigned)] and data type [Decimal]

    Any ideia????

  • andre yokoda

    Boa noite,

    Fiz os procedimentos conforme a documentação: https://github.com/gomex/docker-zabbix/blob/master/README.md

    Mas deu erro no meu meu zabbix agent quando tenta executar o arquivo docker_stats.py:
    09:/etc/zabbix# ./docker_stats.py
    Traceback (most recent call last):
    File “./docker_stats.py”, line 4, in
    from docker_servive import DockerService
    ImportError: No module named docker_servive

    Rodando o zabbix agent na minha máquina:
    Docker Server Version: 1.12.6
    Operating System: Ubuntu 16.04.2 LTS

    No meu zabbix server dá um informação:

    Template Docker Host: check containers system.run[/usr/bin/sudo /etc/zabbix/docker_stats.py] 1m 90d 365d Zabbix agent Not supported

    Received value [Traceback (most recent call last): File “/etc/zabbix/docker_stats.py”, line 4, in from docker_servive import DockerServiceImportError: No module named docker_servive] is not suitable for value type [Numeric (unsigned)] and data type [Decimal]

    Alguma ideia que possa ser?

    • Marc Pires

      Cara também estou usando esse script e dá uma olhada pois no stats está tentando importar do docker_servive e o certo seria docker_service.

  • andre yokoda

    09:/etc/zabbix# pip freeze | grep docker
    docker-compose==1.5.2
    docker-py==1.2.3
    docker-pycreds==0.2.1
    dockerpty==0.3.4