INT 21h

Hi, I am Vladimir Smagin, SysAdmin. Telegram Email GPG / Микроблог

Zabbix automatic discovery and monitoring Docker containers

№ 9617 В разделе "Администрирование" от December 2nd, 2018,

At first, you need to install jq utility to generate JSON in bash. You are SA, you know how to do it.

JSON you want to receive from agent looks like:

{"data":[{"{#CONTAINER}":"git"},{"{#CONTAINER}":"ark_storage_api"},{"{#CONTAINER}":"telegram-microblog-poster"},{"{#CONTAINER}":"telegram-microblog-site"},{"{#CONTAINER}":"mqtt-zabbix-agent"},{"{#CONTAINER}":"sbnc"},{"{#CONTAINER}":"mqtt-bus"},{"{#CONTAINER}":"zabbix-server"},{"{#CONTAINER}":"telegram-post-bot"},{"{#CONTAINER}":"mat-generator"},{"{#CONTAINER}":"ark-log-server"},{"{#CONTAINER}":"zabbix-panel"},{"{#CONTAINER}":"splash"},{"{#CONTAINER}":"mariadb"},{"{#CONTAINER}":"postgres"}]}

Create new custom config on target host /etc/zabbix/zabbix_agentd.d/docker.conf

UserParameter=docker.running[*],docker ps -a -f name="$1" -f status=running -q
UserParameter=docker.containers_running,docker ps -f status=running -q|wc -l
UserParameter=docker.containers_all,docker ps -a -q|wc -l
UserParameter=docker.discovery,echo -n "$(docker ps -a -q --format='{{.Names}}')" \
    |/usr/bin/jq -R -s -c '{data:  split("\n") | map({"{#CONTAINER}": (.)}) }'

You can import my xml with template, or create your own below.

Sample graph in my template

Now create new template “Template Docker containers” with Application “Docker” and discovery rule “Docker containers discovery”. Just like on screenshot below.

Now create templates for Item and Trigger

At last step assign newly created template to your monitored host.

Great! Now you can see statuses and receive alerts.

Нет комментариев »

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Микроблог перейти

# 2018-11-26 09:15:41

Обнаружил в kubedb код google analytics UA-62096468-20, слежка включена по умолчанию.

# 2018-11-24 23:30:12

Несложно смог контейнеризовать nginx unit с предзагрузкой конфигурации перед стартом контейнера blindage.org/?p=9575


© Vladimir Smagin, 2005-2018. Копирование материалов без разрешения запрещено. GPG 0x29AE91B1A37721C3
Яндекс.Метрика

Fortune cookie: Hear about... the French soldier who kissed his wife's cheeks before he went to the front?