From a48332b52967631352e0dec8a66402953cb68c10 Mon Sep 17 00:00:00 2001 From: Soulou Date: Thu, 30 Apr 2015 22:21:27 +0200 Subject: Version v5, graceful stop, email alert and better doc --- start-munin.sh | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'start-munin.sh') diff --git a/start-munin.sh b/start-munin.sh index b0fb3b0..66a2d4b 100644 --- a/start-munin.sh +++ b/start-munin.sh @@ -3,21 +3,41 @@ NODES=${NODES:-} MUNIN_USER=${MUNIN_USER:-user} MUNIN_PASSWORD=${MUNIN_PASSWORD:-password} -htpasswd -b -c /etc/munin/htpasswd.users "$MUNIN_USER" "$MUNIN_PASSWORD" +if [ -n "${SMTP_USERNAME}" -a -n "${SMTP_PASSWORD}" -a -n "${SMTP_HOST}" -a -n "${SMTP_PORT}" ] ; then + cat > /var/lib/munin/.mailrc < ${var:graph_title} -> warnings: ${loop<,>:wfields ${var:label}=${var:value}} / criticals: ${loop<,>:cfields ${var:label}=${var:value}}"' ${ALERT_RECIPIENT} >> /etc/munin/munin.conf +fi + +[ -e /etc/munin/htpasswd.users ] || htpasswd -b -c /etc/munin/htpasswd.users "$MUNIN_USER" "$MUNIN_PASSWORD" # generate node list for NODE in $NODES do - NAME=`echo $NODE | cut -d ":" -f1` - HOST=`echo $NODE | cut -d ":" -f2` + NAME=`echo $NODE | cut -d ":" -f1` + HOST=`echo $NODE | cut -d ":" -f2` + if ! grep -q $HOST /etc/munin/munin.conf ; then cat << EOF >> /etc/munin/munin.conf [$NAME] address $HOST use_node_name yes 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 @@ -30,7 +50,7 @@ Munin has not run yet. Please try again in a few moments. EOF -chown munin:munin /var/cache/munin/www/index.html +chown munin:munin -R /var/cache/munin/www chmod g+w /var/cache/munin/www/index.html fi @@ -46,4 +66,10 @@ echo $NODES /usr/sbin/nginx # show logs echo "Tailing /var/log/syslog..." -tail -F /var/log/syslog /var/log/munin/munin-update.log +tail -F /var/log/syslog /var/log/munin/munin-update.log & pid=$! + +sleep 1 + +trap "kill $pid $(cat /var/run/munin/munin-node.pid) $(cat /var/run/nginx.pid) $(cat /var/run/crond.pid) $(cat /var/run/rsyslogd.pid)" TERM QUIT INT + +wait -- cgit v1.2.3