Kaynağa Gözat

Support for SSH_NODES, like NODES and SNMP_NODES

B. van Berkum 6 yıl önce
ebeveyn
işleme
1e3a1a5534
2 değiştirilmiş dosya ile 23 ekleme ve 0 silme
  1. 1 0
      README.md
  2. 22 0
      start-munin.sh

+ 1 - 0
README.md

@@ -36,6 +36,7 @@ The port is always optional, default is 4949
 
 * `NODES` format: `name1:ip1[:port1] name2:ip2[:port2] …`
 * `SNMP_NODES` format: `name1:ip1[:port1]` …
+* `SSH_NODES` format: `name1:ip1[:port1]` …
 
 ## Port
 

+ 22 - 0
start-munin.sh

@@ -1,6 +1,7 @@
 #!/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'
@@ -100,6 +101,26 @@ EOF
     fi
 done
 
+for SSH_NODE in $SSH_NODES
+do
+  NAME=`echo $SSH_NODE | cut -d ":" -f1`
+  HOST=`echo $SSH_NODE | cut -d ":" -f2`
+  PORT=`echo $SSH_NODE | cut -d ":" -f3`
+  if [ ${#PORT} -eq 0 ]; then
+      PORT=4949
+  fi
+  if ! grep -q "'^$HOST$'" /etc/munin/munin.conf ; then
+    cat << EOF >> /etc/munin/munin.conf
+[$NAME]
+    address ssh://$HOST/usr/bin/nc localhost 4949
+    use_node_name yes
+    port $PORT
+
+EOF
+    echo "Added SSH node '$NAME' '$HOST'"
+    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
@@ -128,6 +149,7 @@ touch /etc/crontab /etc/cron.d/*
 /usr/sbin/munin-node
 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