From 84cf885986957341ab7e9a40be338962a4f1acbe Mon Sep 17 00:00:00 2001 From: f Date: Sat, 12 Sep 2020 19:42:22 -0300 Subject: [PATCH 1/5] knot --- Dockerfile | 8 ++++++++ monit.conf | 6 ++++++ 2 files changed, 14 insertions(+) create mode 100644 monit.conf diff --git a/Dockerfile b/Dockerfile index 59c5898..b8aef6d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,10 @@ FROM sutty/monit:latest MAINTAINER "f " + +RUN apk add --no-cache knot +COPY ./monit.conf /etc/monit.d/knot.conf + +EXPOSE 53 +EXPOSE 53/udp + +VOLUME /var/lib/knot diff --git a/monit.conf b/monit.conf new file mode 100644 index 0000000..c92e900 --- /dev/null +++ b/monit.conf @@ -0,0 +1,6 @@ +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 From 2c983d9e475f0310c51212b3a3adfcb97f43d163 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 21 Oct 2020 16:14:29 -0300 Subject: [PATCH 2/5] knot-prometheus-exporter --- Dockerfile | 5 ++++- monit.conf | 4 ++++ prometheusd.sh | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100755 prometheusd.sh 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 From dd0ae7325a00b08d0d8b27c8a732381deb1cf908 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 2 Feb 2021 21:08:15 -0300 Subject: [PATCH 3/5] ? --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 13664b3..faa5e31 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,6 @@ FROM sutty/monit:latest MAINTAINER "f " -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 From 0cc8e3064cfb9e76c3585f1211e1f79b380776f3 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 1 Apr 2021 15:51:39 -0300 Subject: [PATCH 4/5] chmod the stats file --- prometheusd.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/prometheusd.sh b/prometheusd.sh index 0072cea..1db6f03 100755 --- a/prometheusd.sh +++ b/prometheusd.sh @@ -1,7 +1,13 @@ #!/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 nobody /usr/bin/knot-prometheus-exporter ${STATS:-/tmp/stats.yaml} ;; + start) + rm -f /tmp/prometheus.pid + chmod 644 ${STATS} + daemonize -c /tmp -p /tmp/prometheus.pid -l /tmp/prometheus.pid -u nobody /usr/bin/knot-prometheus-exporter ${STATS} + ;; stop) cat /tmp/prometheus.pid | xargs -r kill ;; esac From 71be4a90b4b82e38242667827193b7e8aca0d8e7 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 1 Apr 2021 17:29:38 -0300 Subject: [PATCH 5/5] run exporter as knot user knot recreates the file on every dump --- prometheusd.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/prometheusd.sh b/prometheusd.sh index 1db6f03..47712fc 100755 --- a/prometheusd.sh +++ b/prometheusd.sh @@ -6,8 +6,7 @@ STATS=${STATS:-/tmp/stats.yaml} case $1 in start) rm -f /tmp/prometheus.pid - chmod 644 ${STATS} - daemonize -c /tmp -p /tmp/prometheus.pid -l /tmp/prometheus.pid -u nobody /usr/bin/knot-prometheus-exporter ${STATS} + 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