diff --git a/Dockerfile b/Dockerfile index d93a8d9..0c100fc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,3 +2,13 @@ ARG ALPINE_VERSION=3.13.6 ARG BASE_IMAGE=sutty/monit FROM ${BASE_IMAGE}:${ALPINE_VERSION} MAINTAINER "f " + +RUN apk add --no-cache knot knot-prometheus-exporter daemonize +COPY ./monit.conf /etc/monit.d/knot.conf +COPY ./prometheusd.sh /usr/local/bin/prometheusd + +EXPOSE 53 +EXPOSE 53/udp +EXPOSE 5000 + +VOLUME /var/lib/knot diff --git a/monit.conf b/monit.conf new file mode 100644 index 0000000..ded4fec --- /dev/null +++ b/monit.conf @@ -0,0 +1,10 @@ +check process knot with pidfile /tmp/knot.pid + start program = "/usr/sbin/knotd -d" + stop program = "/usr/sbin/knotc stop" + if 5 restarts within 8 cycles then alert + if failed port 53 type udp protocol dns for 3 times within 5 cycles then restart + if failed port 53 type tcp protocol dns for 3 times within 5 cycles then restart + +check process prometheus with pidfile /tmp/prometheus.pid + start program = "/usr/local/bin/prometheusd start" + stop program = "/usr/local/bin/prometheusd stop" diff --git a/prometheusd.sh b/prometheusd.sh new file mode 100755 index 0000000..47712fc --- /dev/null +++ b/prometheusd.sh @@ -0,0 +1,12 @@ +#!/bin/sh +set -e + +STATS=${STATS:-/tmp/stats.yaml} + +case $1 in + start) + rm -f /tmp/prometheus.pid + daemonize -c /tmp -p /tmp/prometheus.pid -l /tmp/prometheus.pid -u knot /usr/bin/knot-prometheus-exporter ${STATS} + ;; + stop) cat /tmp/prometheus.pid | xargs -r kill ;; +esac