From f106771da9285fbe926d013ba8366076c922971e Mon Sep 17 00:00:00 2001 From: f Date: Wed, 9 Sep 2020 15:26:37 -0300 Subject: [PATCH 1/4] prometheus --- Dockerfile | 6 ++++++ prometheusd.sh | 10 ++++++++++ 2 files changed, 16 insertions(+) create mode 100755 prometheusd.sh diff --git a/Dockerfile b/Dockerfile index 59c5898..9aa7cdf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,8 @@ FROM sutty/monit:latest MAINTAINER "f " + +RUN apk add --no-cache prometheus daemonize +COPY ./prometheusd.sh /usr/local/bin/prometheusd + +EXPOSE 9090 +VOLUME /var/lib/prometheus diff --git a/prometheusd.sh b/prometheusd.sh new file mode 100755 index 0000000..c5ccb17 --- /dev/null +++ b/prometheusd.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +pid=/tmp/prometheus.pid +var=/var/lib/prometheus +log=/dev/log + +chown prometheus:prometheus /var/lib/prometheus/data + +daemonize -p "${pid}" -l "${pid}" -u prometheus -c "${var}" -a -o "${log}" -e "${log}" \ + /usr/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path="${var}/data" From 34ac360bfcaf92bb07564d3b807b507b8aad9426 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 9 Sep 2020 15:52:56 -0300 Subject: [PATCH 2/4] actually work --- Dockerfile | 1 + monit.conf | 4 ++++ prometheusd.sh | 23 +++++++++++++++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 monit.conf diff --git a/Dockerfile b/Dockerfile index 9aa7cdf..488e854 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,7 @@ FROM sutty/monit:latest MAINTAINER "f " RUN apk add --no-cache prometheus daemonize +COPY ./monit.conf /etc/monit.d/prometheus.conf COPY ./prometheusd.sh /usr/local/bin/prometheusd EXPOSE 9090 diff --git a/monit.conf b/monit.conf new file mode 100644 index 0000000..b956685 --- /dev/null +++ b/monit.conf @@ -0,0 +1,4 @@ +check process postfix with pidfile /var/spool/postfix/pid/master.pid + start program = "/usr/local/bin/prometheusd start" + stop program = "/usr/local/bin/prometheusd stop" + if 5 restarts within 8 cycles then alert diff --git a/prometheusd.sh b/prometheusd.sh index c5ccb17..ff8e549 100755 --- a/prometheusd.sh +++ b/prometheusd.sh @@ -2,9 +2,24 @@ pid=/tmp/prometheus.pid var=/var/lib/prometheus -log=/dev/log -chown prometheus:prometheus /var/lib/prometheus/data +case $1 in + stop) + test -f "${pid}" || exit 0 -daemonize -p "${pid}" -l "${pid}" -u prometheus -c "${var}" -a -o "${log}" -e "${log}" \ - /usr/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path="${var}/data" + cat "${pid}" | xargs -r kill + + rm "${pid}" + ;; + start) + rm -f "${pid}" + + chown prometheus:prometheus /var/lib/prometheus/data + chmod -R u=rwX,g=rX,o= /var/lib/prometheus + + daemonize -p "${pid}" -l "${pid}" -u prometheus -c "${var}" \ + /usr/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path="${var}/data" + ;; +esac + +exit $? From 2750843746619089b6b2901888295423b8287f34 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 2 Feb 2021 21:04:43 -0300 Subject: [PATCH 3/4] this was prometheus --- monit.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monit.conf b/monit.conf index b956685..e28a78f 100644 --- a/monit.conf +++ b/monit.conf @@ -1,4 +1,4 @@ -check process postfix with pidfile /var/spool/postfix/pid/master.pid +check process prometheus with pidfile /tmp/prometheus.pid start program = "/usr/local/bin/prometheusd start" stop program = "/usr/local/bin/prometheusd stop" if 5 restarts within 8 cycles then alert From cc4daf6346cad7bc40016289047d552c0ebcffbb Mon Sep 17 00:00:00 2001 From: f Date: Tue, 2 Feb 2021 21:05:01 -0300 Subject: [PATCH 4/4] use the same dir --- prometheusd.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prometheusd.sh b/prometheusd.sh index ff8e549..6fee544 100755 --- a/prometheusd.sh +++ b/prometheusd.sh @@ -14,8 +14,8 @@ case $1 in start) rm -f "${pid}" - chown prometheus:prometheus /var/lib/prometheus/data - chmod -R u=rwX,g=rX,o= /var/lib/prometheus + chown prometheus:prometheus "${var}" + chmod -R u=rwX,g=rX,o= "${var}" daemonize -p "${pid}" -l "${pid}" -u prometheus -c "${var}" \ /usr/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path="${var}/data"