diff --git a/zabbix-agent/Dockerfile b/zabbix-agent/Dockerfile new file mode 100644 index 0000000..c364ba8 --- /dev/null +++ b/zabbix-agent/Dockerfile @@ -0,0 +1,12 @@ +ARG BUILD_FROM +FROM $BUILD_FROM + +ENV LANG C.UTF-8 + +# Copy scripts for add-on +COPY run.sh / + +RUN apk add -U jq zabbix-agent sudo && \ + chmod a+x /run.sh + +CMD [ "/run.sh" ] diff --git a/zabbix-agent/config.json b/zabbix-agent/config.json new file mode 100644 index 0000000..83e993a --- /dev/null +++ b/zabbix-agent/config.json @@ -0,0 +1,31 @@ +{ + "name": "Zabbix Agent", + "url": "https://git.asperti.com/paspo/hassio-addons", + "version": "0.1.0", + "slug": "zabbix-agent", + "description": "Zabbix Agent for hass.io", + "startup": "services", + "boot": "auto", + "audio": false, + "gpio": false, + "arch": [ + "aarch64", + "amd64", + "armhf", + "i386" + ], + "ports": { + "10050/tcp": 10050 + }, + "map": [ + "config" + ], + "options": { + "server": "zabbix-server", + "hostname": "hassio" + }, + "schema": { + "server": "str", + "hostname": "str" + } +} diff --git a/zabbix-agent/run.sh b/zabbix-agent/run.sh new file mode 100644 index 0000000..29ea7a2 --- /dev/null +++ b/zabbix-agent/run.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -e + +CONFIG_PATH=/data/options.json +CUSTOM_CFG_PATH=/config/zabbix-agent + +SERVER=$(jq --raw-output ".server" $CONFIG_PATH) +HOSTNAME=$(jq --raw-output ".hostname" $CONFIG_PATH) + +echo " +Server=$SERVER +ServerActive=$SERVER +Hostname=$HOSTNAME +LogType=console +Include=/config/zabbix-agent/*.conf +" > /etc/zabbix/zabbix_agentd.conf + +sudo -u zabbix zabbix_agentd -f