Change the way we genarate munin config files to fix broken config
authorAndy Witter <awitter@georgialibraries.org>
Mon, 4 Nov 2013 18:17:38 +0000 (13:17 -0500)
committerAndy Witter <awitter@georgialibraries.org>
Mon, 4 Nov 2013 18:17:38 +0000 (13:17 -0500)
GenaSYS.sh
templates/monitor/munin-node.conf [new file with mode: 0644]
templates/monitor/munin.conf [new file with mode: 0644]

index ad913cd..5b72b20 100755 (executable)
@@ -25,8 +25,8 @@
     PURPOSE_="Generate config files needed for Evergreen-ILS Cluster"
    SYNOPSIS_="$NAME_"
    REQUIRES_="standard GNU commands, apt, dpkg"
-    VERSION_="1.18"
-       DATE_="2010-09-23; last update: 2013-10-30"
+    VERSION_="1.19"
+       DATE_="2010-09-23; last update: 2013-11-04"
      AUTHOR_="Andy Witter <awitter@georgialibraries.org>"
         URL_="http://evergreen-ils.org"
    CATEGORY_="devel"
@@ -1491,6 +1491,9 @@ if [ "$USE_SYNDETICS" == "y" ]|| [ "$USE_SYNDETICS" == "Y" ]
        sed -i 's^<!-- <base_url>http://syndetics.com/index.aspx</base_url> -->^<base_url>http://syndetics.com/index.aspx</base_url>^g' $TMPOPENSRF_XML
 fi
 
+### Start setup of munin.conf file
+cp -f ${TEMPLATEDIR}/monitor/munin.conf $TMPMUNINCONF
+
 ### Set the hostnames and IPs of heads and drones.
 ### And create the configuration  files as needed. 
 
@@ -1600,15 +1603,18 @@ for BRICK in $(seq $BRICKCOUNT)
        printf '\tuse\t\tgeneric-host\n}\n' >>$TMPNAGIHOSTS
 
        ### Build munin-node.conf file.
-        eval echo "host_name \$BRICKHOSTNAME${BRICK}-head" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK})-head/etc/munin/munin-node.conf
+        #eval echo "host_name \$BRICKHOSTNAME${BRICK}-head" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK})-head/etc/munin/munin-node.conf
+       cp -f $TEMPLATEDIR/monitor/munin-node.conf ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK})-head/etc/munin/munin-node.conf
+        eval sed -i "s^MONITORED_NODENAME.CLUSTER_DOMAIN_NAME^$(eval echo \$BRICKHOSTNAME${BRICK}-head.$CLUSTERDOMAINNAME)^g" ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK})-head/etc/munin/munin-node.conf
         echo "allow $MONITOR01_IP" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK})-head/etc/munin/munin-node.conf
         echo "allow $MONITOR02_IP" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK})-head/etc/munin/munin-node.conf
-        eval echo "host \$BRICKHOSTNAME${BRICK}_HEAD_IP" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK})-head/etc/munin/munin-node.conf
+       #eval echo "host \$BRICKHOSTNAME${BRICK}_HEAD_IP" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK})-head/etc/munin/munin-node.conf
 
         ### Build munin.conf file. 
-        eval echo -e "[\$BRICKHOSTNAME${BRICK}-head.${CLUSTERDOMAINNAME}]" >>$TMPMUNINCONF
-        eval echo -e "\\\taddress \$BRICKHOSTNAME${BRICK}_HEAD_IP" >>$TMPMUNINCONF
-        eval echo -e "\\\tuse_node_name yes" >>$TMPMUNINCONF
+        eval echo -e "[${CLUSTERDOMAINNAME};\$BRICKHOSTNAME${BRICK}-head]" >>$TMPMUNINCONF
+        #eval echo -e "\\\taddress \$BRICKHOSTNAME${BRICK}_HEAD_IP" >>$TMPMUNINCONF
+       eval echo -e "\\\taddress \$BRICKHOSTNAME${BRICK}-head.${CLUSTERDOMAINNAME}" >>$TMPMUNINCONF
+        #eval echo -e "\\\thost_name \$BRICKHOSTNAME${BRICK}-head.${CLUSTERDOMAINNAME}" >>$TMPMUNINCONF
         echo >>$TMPMUNINCONF
 
 done
@@ -1729,15 +1735,18 @@ for BRICK in $(seq $BRICKCOUNT)
         printf '\tuse\t\tgeneric-host\n}\n' >>$TMPNAGIHOSTS
        
        ### Build munin-node.conf file.
-        eval echo "host_name \$BRICKHOSTNAME${BRICK}-head" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK})-head/etc/munin/munin-node.conf
+        #eval echo "host_name \$BRICKHOSTNAME${BRICK}-head" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK})-head/etc/munin/munin-node.conf
+       cp -f $TEMPLATEDIR/monitor/munin-node.conf ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK})-head/etc/munin/munin-node.conf
+        eval sed -i "s^MONITORED_NODENAME.CLUSTER_DOMAIN_NAME^$(eval echo \$BRICKHOSTNAME${BRICK}-head.$CLUSTERDOMAINNAME)^g" ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK})-head/etc/munin/munin-node.conf
         echo "allow $MONITOR01_IP" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK})-head/etc/munin/munin-node.conf
         echo "allow $MONITOR02_IP" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK})-head/etc/munin/munin-node.conf
-        eval echo "host \$BRICKHOSTNAME${BRICK}_HEAD_IP" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK})-head/etc/munin/munin-node.conf
+        #eval echo "host \$BRICKHOSTNAME${BRICK}_HEAD_IP" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK})-head/etc/munin/munin-node.conf
         
         ### Build munin.conf file. 
-       eval echo -e "[\$BRICKHOSTNAME${BRICK}-head.${CLUSTERDOMAINNAME}]" >>$TMPMUNINCONF
-        eval echo -e "\\\taddress \$BRICKHOSTNAME${BRICK}_HEAD_IP" >>$TMPMUNINCONF
-        eval echo -e "\\\tuse_node_name yes" >>$TMPMUNINCONF
+       eval echo -e "[${CLUSTERDOMAINNAME}\;\$BRICKHOSTNAME${BRICK}-head]" >>$TMPMUNINCONF
+        #eval echo -e "\\\taddress \$BRICKHOSTNAME${BRICK}_HEAD_IP" >>$TMPMUNINCONF
+       eval echo -e "\\\taddress \$BRICKHOSTNAME${BRICK}-head.${CLUSTERDOMAINNAME}" >>$TMPMUNINCONF
+       #eval echo -e "\\\thost_name \$BRICKHOSTNAME${BRICK}-head.${CLUSTERDOMAINNAME}" >>$TMPMUNINCONF
         echo >>$TMPMUNINCONF
                for DRONE in $(seq $DRONECOUNT)
                do
@@ -1819,16 +1828,21 @@ for BRICK in $(seq $BRICKCOUNT)
                printf '\tuse\t\tgeneric-host\n}\n' >>$TMPNAGIHOSTS
                
                ### Build munin-node.conf file.
-                eval echo "host_name \$BRICKHOSTNAME${BRICK}_DRONE${DRONE}" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK}-drone0${DRONE})/etc/munin/munin-node.conf
-                echo "allow $MONITOR01_IP" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK}-drone0${DRONE})/etc/munin/munin-node.conf
-                echo "allow $MONITOR02_IP" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK}-drone0${DRONE})/etc/munin/munin-node.conf
-                eval echo "host \$BRICKHOSTNAME${BRICK}_DRONE${DRONE}_IP" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK}-drone0${DRONE})/etc/munin/munin-node.conf
-
-                ### Build munin.conf file. 
-                eval echo -e "[\$BRICKHOSTNAME${BRICK}_DRONE${DRONE}.${CLUSTERDOMAINNAME}]" >>$TMPMUNINCONF
-                eval echo -e "\\\taddress \$BRICKHOSTNAME${BRICK}_DRONE${DRONE}_IP" >>$TMPMUNINCONF
-                eval echo -e "\\\tuse_node_name yes" >>$TMPMUNINCONF
-                echo >>$TMPMUNINCONF
+                #eval echo "host_name \$BRICKHOSTNAME${BRICK}_DRONE${DRONE}" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK}-drone0${DRONE})/etc/munin/munin-node.conf
+                #echo "allow $MONITOR01_IP" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK}-drone0${DRONE})/etc/munin/munin-node.conf
+                #echo "allow $MONITOR02_IP" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK}-drone0${DRONE})/etc/munin/munin-node.conf
+               cp -f $TEMPLATEDIR/monitor/munin-node.conf ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK}-drone0${DRONE})/etc/munin/munin-node.conf
+               eval sed -i "s^MONITORED_NODENAME.CLUSTER_DOMAIN_NAME^$(eval echo \$BRICKHOSTNAME${BRICK}-drone0${DRONE}.$CLUSTERDOMAINNAME)^g" ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK}-drone0${DRONE})/etc/munin/munin-node.conf
+               echo "allow $MONITOR01_IP" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK}-drone0${DRONE})/etc/munin/munin-node.conf
+               echo "allow $MONITOR02_IP" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK}-drone0${DRONE})/etc/munin/munin-node.conf
+                #eval echo "host \$BRICKHOSTNAME${BRICK}_DRONE${DRONE}_IP" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK}-drone0${DRONE})/etc/munin/munin-node.conf
+
+               ### Build munin.conf file. 
+               eval echo -e "[${CLUSTERDOMAINNAME}\;\$BRICKHOSTNAME${BRICK}_DRONE${DRONE}]" >>$TMPMUNINCONF
+               #eval echo -e "\\\taddress \$BRICKHOSTNAME${BRICK}_DRONE${DRONE}_IP" >>$TMPMUNINCONF
+               eval echo -e "\\\taddress \$BRICKHOSTNAME${BRICK}_DRONE${DRONE}.${CLUSTERDOMAINNAME}" >>$TMPMUNINCONF
+               #eval echo -e "\\\thost_name \$BRICKHOSTNAME${BRICK}-head.${CLUSTERDOMAINNAME}" >>$TMPMUNINCONF
+               echo >>$TMPMUNINCONF
                done
        #echo
        printf ")\n" >> ${OUTDIR}/$(eval echo \$BRICKHOSTNAME${BRICK})/$(eval echo \$BRICKHOSTNAME${BRICK})-head/openils/conf/.oils_brick.cfg
@@ -2365,30 +2379,34 @@ do
        MUNIN_HOST=$( echo "${MUNINODE}" | tr  '[:lower:]'  '[:upper:]' )
        MUNIN_CFG_FILE="${OUTDIR}/${MUNINODE}/etc/munin/munin-node.conf"
        mkdir -p "${OUTDIR}/${MUNINODE}/etc/munin"
-        echo "### Generated by GenaSYS $_VERSION for Evergreen $EG_VER" >> ${MUNIN_CFG_FILE}
-       echo "host_name ${MUNINODE}.${CLUSTERDOMAINNAME}" >> ${MUNIN_CFG_FILE}
-       printf "allow $MONITOR01_IP   # IP address of the monitor server\n" >> ${MUNIN_CFG_FILE}
-       printf "allow $MONITOR02_IP   # IP address of the monitor server\n" >> ${MUNIN_CFG_FILE}
-       if echo $MUNINODE | grep -q lvs0
-       then
-               eval echo -e "host \$${MUNIN_HOST#*-}_PRIVATE_IP    \# Host IP address" >> ${MUNIN_CFG_FILE}
-       else
-               eval echo -e "host \$${MUNIN_HOST#*-}_IP    \# Host IP address" >> ${MUNIN_CFG_FILE} 
-       fi
+       cp -f ${TEMPLATEDIR}/monitor/munin-node.conf "${MUNIN_CFG_FILE}"
+        #echo "### Generated by GenaSYS $_VERSION for Evergreen $EG_VER" >> ${MUNIN_CFG_FILE}
+       #echo "host_name ${MUNINODE}.${CLUSTERDOMAINNAME}" >> ${MUNIN_CFG_FILE}
+       sed -i "s^MONITORED_NODENAME.CLUSTER_DOMAIN_NAME^${MUNINODE}.${CLUSTERDOMAINNAME}^g" ${MUNIN_CFG_FILE}
+       printf "allow ${MONITOR01_IP}\n" >> ${MUNIN_CFG_FILE}
+       printf "allow ${MONITOR02_IP}\n" >> ${MUNIN_CFG_FILE}
+       #if echo $MUNINODE | grep -q lvs0
+       #then
+       #       eval echo -e "host \$${MUNIN_HOST#*-}_PRIVATE_IP    \# Host IP address" >> ${MUNIN_CFG_FILE}
+       #else
+        #      eval echo -e "host \$${MUNIN_HOST#*-}_IP    \# Host IP address" >> ${MUNIN_CFG_FILE} 
+       #fi
 done
 ## Build munin.conf for monitor servers.
 for MUNINODE in ${MACHINES_NO_BRICKS}
 #for MUNINODE in ${ALL_MACHINES_LIST}
 do
        MUNIN_HOST=$( echo "${MUNINODE}" | tr  '[:lower:]'  '[:upper:]' )
-       echo "[${MUNINODE}.${CLUSTERDOMAINNAME}]" >> $TMPMUNINCONF
+       echo "[${CLUSTERDOMAINNAME};${MUNINODE}]" >> $TMPMUNINCONF
        if echo $MUNINODE | grep -q lvs0
        then   
-               eval echo -e "\\\taddress \$${MUNIN_HOST#*-}_PRIVATE_IP" >> $TMPMUNINCONF
+               #eval echo -e "\\\taddress \$${MUNIN_HOST#*-}_PRIVATE_IP" >> $TMPMUNINCONF
+               eval echo -e "\\\taddress ${MUNINODE}.${CLUSTERDOMAINNAME}" >> $TMPMUNINCONF
        else   
-               eval echo -e "\\\taddress \$${MUNIN_HOST#*-}_IP" >> $TMPMUNINCONF
+               #eval echo -e "\\\taddress \$${MUNIN_HOST#*-}_IP" >> $TMPMUNINCONF
+               eval echo -e "\\\taddress ${MUNINODE}.${CLUSTERDOMAINNAME}" >> $TMPMUNINCONF
        fi
-       echo -e "\tuse_node_name yes" >> $TMPMUNINCONF
+       #echo -e "\thost_name ${MUNINODE}.${CLUSTERDOMAINNAME}" >> $TMPMUNINCONF
        echo >> $TMPMUNINCONF
 done
 
diff --git a/templates/monitor/munin-node.conf b/templates/monitor/munin-node.conf
new file mode 100644 (file)
index 0000000..79c2559
--- /dev/null
@@ -0,0 +1,17 @@
+#Based on standard munin-node.conf from http://munin-monitoring.org/wiki/munin-node.conf
+log_level 4
+log_file /var/log/munin/munin-node.log
+port 4949
+pid_file /var/run/munin/munin-node.pid
+background 1
+host *
+user root
+group root
+setsid yes
+ignore_file ~$
+ignore_file \.bak$
+ignore_file %$
+ignore_file \.dpkg-(tmp|new|old|dist)$
+ignore_file \.rpm(save|new)$
+host_name MONITORED_NODENAME.CLUSTER_DOMAIN_NAME
+allow 127.0.0.1
diff --git a/templates/monitor/munin.conf b/templates/monitor/munin.conf
new file mode 100644 (file)
index 0000000..6a186e7
--- /dev/null
@@ -0,0 +1,12 @@
+### Configfile for Munin master
+dbdir       /var/lib/munin
+htmldir     /var/www/munin
+logdir      /var/log/munin
+rundir      /var/run/munin
+
+### This is an example of the correct way to activate Nagios warnings
+# contact.nagios.command /usr/local/nagios/bin/send_nsca nagioshost.example.com -c /usr/local/nagios/etc/send_nsca.cfg -to 60
+
+### From and including the first host, no more global directives can be defined.
+### Everything after one host definition belongs to that host, until another host definition is found.
+