Munin via SSH

Neogreen

Member
Hey,

Ich arbeite grade mit diesen Tutorial: http://netaddict.de/howtos:muninssh um eben Munin über SSH arbeiten zu lassen, bin aktuell beim Script allerdings gibt das folgende Fehler aus und scheint nicht zu funken:

PHP:
munin@server:~$ /var/lib/munin/munin-ssh-tunnel.sh
/var/lib/munin/munin-ssh-tunnel.sh: 1: /var/lib/munin/munin-ssh-tunnel.sh: bc: not found
/var/lib/munin/munin-ssh-tunnel.sh: 1: /var/lib/munin/munin-ssh-tunnel.sh: bc: not found
/var/lib/munin/munin-ssh-tunnel.sh: 1: /var/lib/munin/munin-ssh-tunnel.sh: bc: not found
done with this triple, check for tunnel localhost.localdomain port
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
SSH tunnel localhost.localdomain NOT alive ... Restarting ...
Bad local forwarding specification ':localhost:4949'
Weis wer rat?
 
Moin Neo
PHP:
/var/lib/munin/munin-ssh-tunnel.sh: 1: /var/lib/munin/munin-ssh-tunnel.sh: bc: not found
Du hast bc nicht installiert

Thorashh
 
Nun kommt folgendes:

PHP:
munin@server:~$ /var/lib/munin/munin-ssh-tunnel.sh
done with this triple, check for tunnel localhost.localdomain port
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
SSH tunnel localhost.localdomain NOT alive ... Restarting ...
Bad local forwarding specification ':localhost:4949'

Laut Munin ist nichts angekommen jedenfalls die graphen zeigen nichts an.
 
PHP:
root@server:~# cat /var/lib/munin/munin-ssh-tunnel.sh
#!/bin/sh
        # Start or restart ssh tunnel to munin clients in a DMZ
        # File with the munin configuration
        MUNINCONF=/etc/munin/munin.conf
        # IP-Address for localhost (local tunnel endpoint)
        IP=127.0.0.1
        # tempoary list
        MUNINLIST=/home/munin/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 munin@$CLIENTNAME
                                logger -p daemon.notice "SSH tunnel ${CLIENTNAME} NOT alive ... Restarting ..."
                                sleep 1
                        fi
                        COUNTER=0
                        echo
                fi
        done
 
Moin Neo
PHP:
munin@server:~$ /var/lib/munin/munin-ssh-tunnel.sh
done with this triple, check for tunnel localhost.localdomain port
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
SSH tunnel localhost.localdomain NOT alive ... Restarting ...
Bad local forwarding specification ':localhost:4949'
Das sieht so aus, als wäre deine munin.conf fehlerhaft.
Poste die bitte mal.

Thorashh
 
PHP:
root@server:~# cat /etc/munin/munin.conf
# Example configuration file for Munin, generated by 'make build'

# The next three variables specifies where the location of the RRD
# databases, the HTML output, logs and the lock/pid files.  They all
# must be writable by the user running munin-cron.  They are all
# defaulted to the values you see here.
#
# dbdir /var/lib/munin
htmldir /var/www/munin/
# logdir /var/log/munin
# rundir  /var/run/munin
#
# Where to look for the HTML templates
# tmpldir       /etc/munin/templates

# (Exactly one) directory to include all files from.
#
includedir /etc/munin/munin-conf.d

# Make graphs show values per minute instead of per second
#graph_period minute

# Graphics files are normaly generated by munin-graph, no matter if
# the graphs are used or not.  You can change this to
# on-demand-graphing by following the instructions in
# http://munin.projects.linpro.no/wiki/CgiHowto
#
#graph_strategy cgi

# munin-cgi-graph is invoked by the web server up to very many times at the
# same time.  This is not optimal since it results in high CPU and memory
# consumption to the degree that the system can thrash.  Again the default is
# 6.  Most likely the optimal number for max_cgi_graph_jobs is the same as
# max_graph_jobs.
#
#munin_cgi_graph_jobs 6

# If the automatic CGI url is wrong for your system override it here:
#
#cgiurl_graph /cgi-bin/munin-cgi-graph

# munin-graph runs in parallel, the number of concurrent processes is
# 6.  If you want munin-graph to not be parallel set to 0.  If set too
# high it will slow down munin-graph.  Some experiments are needed to
# determine how many are optimal on your system.  On a multi-core
# system with good SCSI disks the number can probably be quite high.
#
#max_graph_jobs 6

# Drop [email protected] and [email protected] an email everytime
# something changes (OK -> WARNING, CRITICAL -> OK, etc)
#contact.someuser.command mail -s "Munin notification" [email protected]
#contact.anotheruser.command mail -s "Munin notification" [email protected]
#
# For those with Nagios, the following might come in handy. In addition,
# the services must be defined in the Nagios server as well.
#contact.nagios.command /usr/bin/send_nsca nagios.host.comm -c /etc/nsca.conf

# a simple host tree
[localhost.localdomain] #
    address 127.0.0.1  #
    use_node_name yes #
# use real hostnames in []
[TS.TS3Instanz]
    address **********
    use_node_name yes
    port 4950
[Hetzner.EX4]
    address **********
    use_node_name yes
    port 4951
[TS.TS3Instanz]
    address **********
    use_node_name yes
    port 4952
[TS.TS3Instanz]
    address **********
    use_node_name yes
    port 4954
# A more complex example of a host tree
#
## First our "normal" host.
# [fii.foo.com]
#       address foo
#
## Then our other host...
# [fay.foo.com]
#       address fay
#
## Then we want totals...
# [foo.com;Totals] #Force it into the "foo.com"-domain...
#       update no   # Turn off data-fetching for this "host".
#
#   # The graph "load1". We want to see the loads of both machines...
#   # "fii=fii.foo.com:load.load" means "label=machine:graph.field"
#       load1.graph_title Loads side by side
#       load1.graph_order fii=fii.foo.com:load.load fay=fay.foo.com:load.load
#
#   # The graph "load2". Now we want them stacked on top of each other.
#       load2.graph_title Loads on top of each other
#       load2.dummy_field.stack fii=fii.foo.com:load.load fay=fay.foo.com:load.load
#       load2.dummy_field.draw AREA # We want area instead the default LINE2.
#       load2.dummy_field.label dummy # This is needed. Silly, really.
#
#   # The graph "load3". Now we want them summarised into one field
#       load3.graph_title Loads summarised
#       load3.combined_loads.sum fii.foo.com:load.load fay.foo.com:load.load
#       load3.combined_loads.label Combined loads # Must be set, as this is
#                                                 # not a dummy field!
#
## ...and on a side note, I want them listen in another order (default is
## alphabetically)
#
# # Since [foo.com] would be interpreted as a host in the domain "com", we
# # specify that this is a domain by adding a semicolon.
# [foo.com;]
#       node_order Totals fii.foo.com fay.foo.com
#
Vorher ohne den Umbau auf SSH ging alles aber habe eben die Ports hinzugefügt, die Ports sind aber auch an der gegenstelle geändert worden.
 
Last edited by a moderator:
Moin Neo

Deine munin.conf muss exakt dem Beispiel entsprechen.
Code:
[hostname]
address 123.45.67.89
port 4950
Keine Leerzeilen dazwischen.
Weitere Parameter kannst Du dann nach der Portzeile eintragen.

Thorashh

P.S.:
Ich würde mir an deiner Stelle mal stunnel anschauen.
Da kannst Du komplett auf solche Quick&Dirty Hacks verzichten.
 
Last edited by a moderator:
PHP:
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
Darum musst Du Dich kümmern.
Abgesehen davon, ist das Script von Jemandem geschrieben, der keine Ahnung von Shellscripting hat. Du solltest Dir ein professionelleres Script suchen, oder von Jemandem schreiben lassen, der davon etwas versteht.
 
Moin Neo

Das Skript ist echt Schrott.

Ersetz mal folgende Zeile
Code:
cat $MUNINCONF  | grep -v "#" | grep "address $IP" --before-context=1 --after-context=1 > $MUNINLIST
durch
Code:
grep -v "#" ${MUNINCONF} | grep --before-context=1 --after-context=1 'address' > $MUNINLIST

Mein voriger Post gilt weiterhin.

Thorashh
 
Danke dir, nun bin ich etwas weiter...

Verbindung scheint nun hergestellt zu werden, allerdings abeitet das teil immer nur 1Server ab und lässt alle anderen aus.
Bzw könnte es daran liegen das die anderen ihren SSH Server nicht auf dem Standart port haben? allerdings sind diese alle unterschiedlich..

Sowie werden die aktuellen Daten nichtmehr angezeigt.
 
Last edited by a moderator:
Back
Top