From d6e30533d7730331452c5f61a98c9d1eec486a0b Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Wed, 28 Aug 2019 19:43:26 +0200 Subject: OpenShift support --- start-munin.sh | 58 ++++++++++++++++++++++++---------------------------------- 1 file changed, 24 insertions(+), 34 deletions(-) (limited to 'start-munin.sh') diff --git a/start-munin.sh b/start-munin.sh index 71b2359..e224de1 100755 --- a/start-munin.sh +++ b/start-munin.sh @@ -1,22 +1,24 @@ #!/bin/bash + NODES=${NODES:-} SNMP_NODES=${SNMP_NODES:-} SSH_NODES=${SSH_NODES:-} MUNIN_USERS=${MUNIN_USERS:-${MUNIN_USER:-user}} MUNIN_PASSWORDS=${MUNIN_PASSWORDS:-${MUNIN_PASSWORD:-password}} -MAIL_CONF_PATH='/var/lib/munin/.mailrc' +MAIL_CONF_PATH='/munin/db/.mailrc' SMTP_USE_TLS=${SMTP_USE_TLS:-false} SMTP_ALWAYS_SEND=${SMTP_ALWAYS_SEND:-true} SMTP_MESSAGE_DEFAULT='[${var:group};${var:host}] -> ${var:graph_title} -> warnings: ${loop<,>:wfields ${var:label}=${var:value}} / criticals: ${loop<,>:cfields ${var:label}=${var:value}}' SMTP_MESSAGE="${SMTP_MESSAGE:-$SMTP_MESSAGE_DEFAULT}" -truncate -s 0 "${MAIL_CONF_PATH}" -# set volume ownerships -chown -R munin:munin /var/log/munin -chown -R munin:munin /var/lib/munin -chown -R munin:munin /var/run/munin -chown -R munin:munin /var/cache/munin +mkdir -p /munin/{db,run,log,www/cache} +[ -a /munin/db/cgi-tmp ] || ln -s ../www/cache /munin/db/cgi-tmp +[ -a /var/lib/munin/cgi-tmp ] || ln -s /munin/www/cache /var/lib/munin/cgi-tmp +[ -a /var/log/nginx ] || ln -s /tmp /var/log/nginx + + +truncate -s 0 "${MAIL_CONF_PATH}" if [ "${SMTP_USE_TLS}" = true ] ; then cat >> "${MAIL_CONF_PATH}" <> /etc/munin/htpasswd.users - (( uc++ )) - done -fi - # generate node list for NODE in $NODES do @@ -121,10 +112,10 @@ EOF fi done -[ -d /var/cache/munin/www ] || mkdir /var/cache/munin/www + # placeholder html to prevent permission error -if [ ! -e /var/cache/munin/www/index.html ]; then -cat << EOF > /var/cache/munin/www/index.html +if [ ! -e /munin/www/index.html ]; then +cat << EOF > /munin/www/index.html Munin @@ -134,35 +125,34 @@ Munin has not run yet. Please try again in a few moments. EOF -chown munin:munin -R /var/cache/munin/www -chmod g+w /var/cache/munin/www/index.html fi # start rsyslogd -/usr/sbin/rsyslogd -# start cron -/usr/sbin/cron -# Issue: 'NUMBER OF HARD LINKS > 1' prevents cron exec in container -# https://github.com/phusion/baseimage-docker/issues/198 -touch /etc/crontab /etc/cron.d/* -# start local munin-node -/usr/sbin/munin-node +truncate -s 0 /tmp/rsyslogd.pid +#/usr/sbin/rsyslogd -i /tmp/rsyslogd.pid + +# start munin updates +truncate -s 0 /munin/log/munin-update.log +/usr/local/bin/supercronic -split-logs /etc/munin/munin.cron & cron_pid=$! + + echo "Using the following munin nodes:" echo $NODES echo "(ssh) $SSH_NODES" echo "(snmp) $SNMP_NODES" # start spawn-cgi to enable CGI interface with munin (dynamix graph generation) -spawn-fcgi -s /var/run/munin/fcgi-graph.sock -U munin -u munin -g munin /usr/lib/munin/cgi/munin-cgi-graph +spawn-fcgi -p 9000 /usr/lib/munin/cgi/munin-cgi-graph +spawn-fcgi -p 9001 /usr/lib/munin/cgi/munin-cgi-html # start nginx /usr/sbin/nginx # show logs echo "Tailing syslog and munin-update log..." -tail -F /var/log/syslog /var/log/munin/munin-update.log & pid=$! +tail -F /munin/log/munin-update.log & pid=$! echo "tail -F running in $pid" sleep 1 -trap "echo 'stopping processes' ; kill $pid $(cat /var/run/munin/munin-node.pid) $(cat /var/run/nginx.pid) $(cat /var/run/crond.pid) $(cat /var/run/rsyslogd.pid)" SIGTERM SIGINT +trap "echo 'stopping processes' ; kill $pid $cron_pid $(cat /tmp/nginx.pid) $(cat /tmp/rsyslogd.pid)" SIGTERM SIGINT echo "Waiting for signal SIGINT/SIGTERM" wait -- cgit v1.2.3