Ich bin vor ca. einer Woche mit meiner Webseite zum Anbieter Host Europe GmbH gewechselt. Ausgewählt habe ich den Virtual XL Server 4.0.

    Die Performance ist wirklich gut für eine virtuelle Maschine, auch die Festplattenzugriffe sind spitze. Doch hatte ich das Problem, dass ich immer wieder für kurze Zeit mit numtcpsock an das Ressourcen Limits von Host Europe gestoßen bin. Leider war dies nie der Fall, wenn ich gerade per SSH mit dem Server verbunden war. Also musste eine Überwachungslösung her.

    Um das Problem nun zu lokalisieren, habe ich erst einmal die Limitierungen meiner Maschine mit denen bei Host Europe angegebenen Werten verglichen.

    cat /proc/user_beancounters

    Hier sah soweit alles gut aus. Anschließend habe ich mir ein Script gebaut, dass mir eine Liste der offenen Verbindungen zumailt, wenn diese 400 überschreitet.

    prozesse=$(netstat -a |wc -l)
    
    if [ $prozesse -gt 400 ] ; then
       # Anzahl der TCP/UDP Prozesse
       lsof | egrep '(TCP|UDP)' | sort > /tmp/test.txt
       netstat -a | egrep '(tcp|udp)' >> /tmp/test.txt
       mail user@doman.tld < /tmp/test.txt
    fi

    Ich habe 400 als Schwellenwert angegeben, da ich im Schnitt 250-300 Verbindungen offen habe. 400 erschien mir daher ein akzeptabler Schwellenwert. Das Script habe ich dann jede Minute einmal laufen lassen, da die Anzahl der Verbindungen immer nur kurzzeitig in die Höhe geschnellt ist. Dies alles habe ich dann gestern Abend eingerichtet.

    Heute Morgen hatte ich dann prompt 19 E-Mails mit den offenen Verbindungen in meinem Briefkasten. Der Grund das Problem war nach dem ersten Durchscrollen der Liste schon offensichtlich:

    [...]
    sslh   24038   sslh   4u  IPv4   21644932   TCP localhost:https->localhost:43757 (ESTABLISHED)
    sslh   24038   sslh   6u  IPv4   21644937   TCP localhost:43758->localhost:https (ESTABLISHED)
    sslh   24039   sslh   3u  IPv4   10544952   TCP *:https (LISTEN)
    sslh   24039   sslh   4u  IPv4   21644935   TCP localhost:https->localhost:43758 (ESTABLISHED)
    sslh   24039   sslh   6u  IPv4   21644940   TCP localhost:43759->localhost:https (ESTABLISHED)
    sslh   24040   sslh   3u  IPv4   10544952   TCP *:https (LISTEN)
    sslh   24040   sslh   4u  IPv4   21644938   TCP localhost:https->localhost:43759 (ESTABLISHED)
    sslh   24040   sslh   6u  IPv4   21644943   TCP localhost:43760->localhost:https (ESTABLISHED)
    sslh   24041   sslh   3u  IPv4   10544952   TCP *:https (LISTEN)
    sslh   24041   sslh   4u  IPv4   21644941   TCP localhost:https->localhost:43760 (ESTABLISHED)
    sslh   24041   sslh   6u  IPv4   21644946   TCP localhost:43761->localhost:https (ESTABLISHED)
    sslh   24042   sslh   3u  IPv4   10544952   TCP *:https (LISTEN)
    sslh   24042   sslh   4u  IPv4   21644944   TCP localhost:https->localhost:43761 (ESTABLISHED)
    sslh   24042   sslh   6u  IPv4   21644949   TCP localhost:43762->localhost:https (ESTABLISHED)
    sslh   24043   sslh   3u  IPv4   10544952   TCP *:https (LISTEN)
    sslh   24043   sslh   4u  IPv4   21644947   TCP localhost:https->localhost:43762 (ESTABLISHED)
    sslh   24043   sslh   6u  IPv4   21644952   TCP localhost:43763->localhost:https (ESTABLISHED)
    sslh   24044   sslh   3u  IPv4   10544952   TCP *:https (LISTEN)
    sslh   24044   sslh   4u  IPv4   21644950   TCP localhost:https->localhost:43763 (ESTABLISHED)
    sslh   24044   sslh   6u  IPv4   21644955   TCP localhost:43764->localhost:https (ESTABLISHED)
    sslh   24045   sslh   3u  IPv4   10544952   TCP *:https (LISTEN)
    sslh   24045   sslh   4u  IPv4   21644953   TCP localhost:https->localhost:43764 (ESTABLISHED)
    sslh   24045   sslh   6u  IPv4   21644958   TCP localhost:43765->localhost:https (ESTABLISHED)
    sslh   24046   sslh   3u  IPv4   10544952   TCP *:https (LISTEN)
    sslh   24046   sslh   4u  IPv4   21644956   TCP localhost:https->localhost:43765 (ESTABLISHED)
    sslh   24046   sslh   6u  IPv4   21644962   TCP localhost:43766->localhost:https (ESTABLISHED)
    sslh   24047   sslh   3u  IPv4   10544952   TCP *:https (LISTEN)
    sslh   24047   sslh   4u  IPv4   21644960   TCP localhost:https->localhost:43766 (ESTABLISHED)
    sslh   24047   sslh   6u  IPv4   21644965   TCP localhost:43767->localhost:https (ESTABLISHED)
    [...]

    Insgesamt kamen für sslh 1006 Verbindungen zustande.

    Ich nutze sslh um den SSH Dienst auch über den Port 443 nutzen zu können, ohne ihn fest darauf einrichten zu müssen. sslh fungiert als Splitter, er erkennt ob eine Verbindung eine SSH oder SSL Verbindungen ist und leitet diese entsprechende weiter. Anscheinend kam sslh mit der zwischenzeitlich erhöhten Anfrage an SSL Verbindungen nicht so ganz klar. Jetzt habe ich sslh erst einmal deaktiviert. Schauen wir mal, wie sich der Server jetzt verhält.

    3 Kommentare

    1. „/tmp/test.txt“ sollte nicht fest kodiert werden, sondern mittels mktemp eine eindeutige Datei generiert werden:

      prozesse=$(netstat -a |wc -l)
      krit_wert=400
      empfaenger=“root“
      # oder:
      # empfaenger=“user@doman.tld“

      if [ $prozesse -gt $krit_wert ] ; then
      tempfile=`mktemp`
      # Anzahl der TCP/UDP Prozesse
      lsof | egrep ‚(TCP|UDP)‘ | sort > $tempfile
      netstat -a | egrep ‚(tcp|udp)‘ >> $tempfile
      mail -s „numtcpsock hat kritischen wert $krit_wert auf `hostname –fqdn` erreicht“ $recipient < $tempfile
      fi

    2. Korrekturen:
      1. „$recipient“ durch „$empfaenger“ ersetzt
      2. falscher Zeilenumbruch umgangen in der mail-Zeile mit „“
      3. Langer Gedankenstrich muss durch zwei Bindestriche ersetzt werden (wird leider von wordpress ersetzt)

      prozesse=$(netstat -a |wc -l)
      krit_wert=400
      empfaenger=”root”
      # oder:
      # empfaenger=”user@doman.tld”

      if [ $prozesse -gt $krit_wert ] ; then
      tempfile=`mktemp`
      # Anzahl der TCP/UDP Prozesse
      lsof | egrep ‘(TCP|UDP)’ | sort > $tempfile
      netstat -a | egrep ‘(tcp|udp)’ >> $tempfile
      mail -s “numtcpsock hat kritischen wert $krit_wert auf `hostname –fqdn` erreicht”
      $empfaenger < $tempfile
      fi

    Reply To Christian Scholz Cancel Reply