actually work

This commit is contained in:
f 2020-09-09 15:52:56 -03:00
parent f106771da9
commit 34ac360bfc
3 changed files with 24 additions and 4 deletions

View file

@ -2,6 +2,7 @@ FROM sutty/monit:latest
MAINTAINER "f <f@sutty.nl>" MAINTAINER "f <f@sutty.nl>"
RUN apk add --no-cache prometheus daemonize RUN apk add --no-cache prometheus daemonize
COPY ./monit.conf /etc/monit.d/prometheus.conf
COPY ./prometheusd.sh /usr/local/bin/prometheusd COPY ./prometheusd.sh /usr/local/bin/prometheusd
EXPOSE 9090 EXPOSE 9090

4
monit.conf Normal file
View file

@ -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

View file

@ -2,9 +2,24 @@
pid=/tmp/prometheus.pid pid=/tmp/prometheus.pid
var=/var/lib/prometheus 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}" \ 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" /usr/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path="${var}/data"
;;
esac
exit $?