diff --git a/Dockerfile b/Dockerfile index b8aef6d..13664b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,13 @@ FROM sutty/monit:latest MAINTAINER "f " -RUN apk add --no-cache knot +RUN echo +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 index c92e900..ded4fec 100644 --- a/monit.conf +++ b/monit.conf @@ -4,3 +4,7 @@ check process knot with pidfile /tmp/knot.pid 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..0072cea --- /dev/null +++ b/prometheusd.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -e + +case $1 in + start) rm -f /tmp/prometheus.pid ; daemonize -c /tmp -p /tmp/prometheus.pid -l /tmp/prometheus.pid -u nobody /usr/bin/knot-prometheus-exporter ${STATS:-/tmp/stats.yaml} ;; + stop) cat /tmp/prometheus.pid | xargs -r kill ;; +esac