diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2019-08-28 19:43:26 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2019-08-28 19:43:26 +0200 |
commit | d6e30533d7730331452c5f61a98c9d1eec486a0b (patch) | |
tree | b23b00fe8d94c656f92d228fc2243942c14cb298 /start-munin.sh | |
parent | bf1b72fa544f9b2eb41867dd08d379242261ed35 (diff) | |
download | munin-d6e30533d7730331452c5f61a98c9d1eec486a0b.tar.gz munin-d6e30533d7730331452c5f61a98c9d1eec486a0b.tar.bz2 munin-d6e30533d7730331452c5f61a98c9d1eec486a0b.tar.xz munin-d6e30533d7730331452c5f61a98c9d1eec486a0b.zip |
OpenShift support
Diffstat (limited to 'start-munin.sh')
-rwxr-xr-x | start-munin.sh | 58 |
1 files changed, 24 insertions, 34 deletions
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}" <<EOF @@ -48,17 +50,6 @@ if [ $rc -ne 0 -a -n "${ALERT_RECIPIENT}" -a -n "${ALERT_SENDER}" ] ; then fi fi -# generate the Munin auth username/password file -if [ ! -f /etc/munin/htpasswd.users ]; then - uc=0 - IFS=' ' read -ra ARR_USERS <<< "$MUNIN_USERS" - IFS=' ' read -ra ARR_PASSWORDS <<< "$MUNIN_PASSWORDS" - for u in "${ARR_USERS[@]}"; do - printf "${u}:`openssl passwd -apr1 ${ARR_PASSWORDS[uc]}`\n" >> /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 <html> <head> <title>Munin</title> @@ -134,35 +125,34 @@ Munin has not run yet. Please try again in a few moments. </body> </html> 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 |