• This forum has a zero tolerance policy regarding spam. If you register here to publish advertising, your user account will be deleted without further questions.

Munin SSH Tunnel

djrick

Registered User
Hallöchen,

Ich wollte gerade für 3 Munin Nodes einen SSH Tunnel aufsetzen.
Hier findet man sogar ein passendes Script dazu:
MuninSSHTunneling - Munin - Trac

Hier mal der Code:
Code:
'check')
        # Start or restart ssh tunnel to munin clients in a DMZ
        # File with the munin configuration
        MUNINCONF=/etc/opt/munin/munin.conf
        # IP-Address for localhost (local tunnel endpoint)
        IP=127.0.0.1
        # tempoary list
        MUNINLIST=/tmp/munin.list

        cat $MUNINCONF  | grep -v "#" | grep "address $IP" --before-context=1 --after-context=1 > $MUNINLIST
        # set an 'end of file' marker
        echo "--" >> $MUNINLIST

        COUNTER=0
        cat $MUNINLIST | while read line ; do
                if [ "$line" != "--" ] ; then
                        if [ "$COUNTER" = "0" ] ; then
                                CLIENTNAME=`echo $line | tr -d '[] '
                        fi
                        if [ "`echo $line | grep port`" ] ; then
                                PORT=`echo $line | awk '{ print $2 }'`
                        fi
                        #echo "looking for $CLIENTNAME : $PORT"
                        COUNTER=`echo "$COUNTER + 1" | bc`
                else
                        echo "done with this triple, check for tunnel $CLIENTNAME port $PORT"
                        if [ "`ps -eaf | grep ssh | grep nNgf | grep $PORT | grep -v grep`" ] ; then
                                echo "tunnel to $CLIENTNAME port $PORT is up"
                        else
                                echo "SSH tunnel ${CLIENTNAME} NOT alive ... Restarting ..."
                                /usr/bin/ssh -nNgf -L $PORT:localhost:4949 root@$CLIENTNAME 
                                logger -p daemon.notice "SSH tunnel ${CLIENTNAME} NOT alive ... Restarting ...
"
                                sleep 1
                        fi
                        COUNTER=0
                        echo
                fi
        done
        ;;

Das Problem ist beim Ausführen:
Code:
/etc/init.d/munin-node check
/etc/init.d/munin-node: line 238: unexpected EOF while looking for matching ``'
/etc/init.d/munin-node: line 256: syntax error: unexpected end of file

Zeile237 und 238:
Code:
                        echo "done with this triple, check for tunnel $CLIENTNAME port $PORT"
                        if [ "`ps -eaf | grep ssh | grep nNgf | grep $PORT | grep -v grep`" ] ; then

Zeile 255+256, ist dann das Ende der Datei.

Wo liegt der Fehler?
 
Die Zeile

logger -p daemon.notice "SSH tunnel ${CLIENTNAME} NOT alive ... Restarting ...

müsste sicherlich mit einem " enden, oder ist das lediglich beim Copy&Paste verloren gegangen?

So wäre es meiner Meinung nach richtig:

logger -p daemon.notice "SSH tunnel ${CLIENTNAME} NOT alive ... Restarting ..."
 
Das ist jedenfalls nicht der Fehler, die Bash meckert schon viele Zeilen davor. Das " ist lediglich in die nächste Zeile gerutscht.
 
Back
Top