Surveillance de Modem SpeedTouch Télé2 par Munin

Surveillance de Modem SpeedTouch Télé2 par Munin

Je suis actuellement en train de travailler sur des scripts de monitoring pour le modem Neuf Box de SFR. J’ai retrouvé quelques scripts pour la surveillance du précédent modem SpeedTouch de télé2. Je ne les ai pas gardé très longtemps, en effet destiné à comprendre pourquoi la box plantait régulièrement, il la rendait encore plus instable….

Donc voici ces scripts (ils sont fournis en licence GPL):

Le premier sert à surveiller les débits sur lesquels se règle le modem:

#!/bin/sh
##############################################################################
##                     DESCRIPTION                                          ##
##############################################################################
#
# Par Florent Fortin
# sous Licence GPL
#
#  Ce script reupère les donnée sur la page "detecttion des intrusions" et
#formate ces donnée pour munin
#
#le script comprent les commandes:
#  -> autoconf
#  -> config
#  -> <vide>

##############################################################################
##                     Variable de configuration                            ##
##############################################################################

#l'adresse ip du modem routeur TELE2
IP_TELE2="192.168.1.254"

#############################################################################
##                CONSTANTE POUR FACILITE L'EVOLUTION DU SCRIPT            ##
#############################################################################
#
#ces constantes sont là pour s'adapter à d'eventuelles modifications
#du firmware du modem ou pour permetre au script d'évoluer
#

#page de l'interface WEB qui liste les tentative d'intrusion
PAGE_TELE2="/cgi/b/dsl/dt/?be=0&l0=1&l1=0"
#son titre pour verifier que c'est bien elle:
PAGE_TELE2_TITLE="SpeedTouch - Connexion DSL"

#fichier temporaire ou sera stocké cette page pour faire les traitements
PAGE_FILE="/tmp/temp.TELE2.page.bandwidth"

#############################################################################
##                          SCRIPT                                         ##
#############################################################################

if [ "$1" = "autoconf" ]; then
    #on recupère la page
    wget -q -O"$PAGE_FILE" "http://$IP_TELE2$PAGE_TELE2"
    #on verifie que c'est la bonne page avec son titre
    ret=$(grep "<title>$PAGE_TELE2_TITLE</title>" "$PAGE_FILE" | wc -l)
       if [ "$ret" = "1" ] ; then
        echo yes
        exit 0
    else
        echo no
        exit 1
    fi
fi

if [ "$1" = "config" ]; then
     echo 'graph_title TELE2 BandWidth'
     echo 'graph_args --base 1000 -l 0'
     echo 'graph_vlabel Kbps/s'
     echo 'graph_category TELE2'

     echo 'BW_IN.label BandeWidth Up'
     echo 'BW_OUT.label BandeWidth Down'
     exit 0

fi

  wget -q -O"$PAGE_FILE" "http://$IP_TELE2$PAGE_TELE2"

  ret=$(grep "Bande passante" "$PAGE_FILE" | cut -d\> -f5 | cut -d\< -f1 | cut -d\/ -f1)
  echo "BW_IN.value  $ret"
  ret=$(grep "Bande passante" "$PAGE_FILE" | cut -d\> -f5 | cut -d\< -f1 | cut -d\/ -f2)
  echo "BW_OUT.value $ret"

Le deuxième surveille les erreurs survenues pendant la transition DSL:

#!/bin/sh
##############################################################################
##                     DESCRIPTION                                          ##
##############################################################################
#
# Par Florent Fortin
# sous Licence GPL
#
#  Ce script reupère les donnée sur la page "detecttion des intrusions" et
#formate ces donnée pour munin
#
#le script comprent les commandes:
#  -> autoconf
#  -> config
#  -> <vide>

##############################################################################
##                     Variable de configuration                            ##
##############################################################################

#l'adresse ip du modem routeur TELE2
IP_TELE2="192.168.1.254"

#############################################################################
##                CONSTANTE POUR FACILITE L'EVOLUTION DU SCRIPT            ##
#############################################################################
#
#ces constantes sont là pour s'adapter à d'eventuelles modifications
#du firmware du modem ou pour permetre au script d'évoluer
#

#page de l'interface WEB qui liste les tentative d'intrusion
PAGE_TELE2="/cgi/b/dsl/dt/?be=0&l0=1&l1=0"
#son titre pour verifier que c'est bien elle:
PAGE_TELE2_TITLE="SpeedTouch - Connexion DSL"

#fichier temporaire ou sera stocké cette page pour faire les traitements
PAGE_FILE="/tmp/temp.TELE2.page.error"

#############################################################################
##                          SCRIPT                                         ##
#############################################################################

if [ "$1" = "autoconf" ]; then
    #on recupère la page
    wget -q -O"$PAGE_FILE" "http://$IP_TELE2$PAGE_TELE2"
    #on verifie que c'est la bonne page avec son titre
    ret=$(grep "<title>$PAGE_TELE2_TITLE</title>" "$PAGE_FILE" | wc -l)
       if [ "$ret" = "1" ] ; then
		echo yes
		exit 0
	else
		echo no
		exit 1
	fi
fi

if [ "$1" = "config" ]; then
     echo 'graph_title TELE2 Errors'
     echo 'graph_args --base 1000 -l 0'
     echo 'graph_vlabel Attaque/s'
     echo 'graph_category TELE2'

     echo 'Erreurs_FEC_IN.label Erreurs FEC Montant'
     echo 'Erreurs_FEC_IN.type DERIVE'
     echo 'Erreurs_FEC_IN.min 0'

     echo 'Erreurs_FEC_OUT.label Erreurs FEC Desendant (*1000)'
     echo 'Erreurs_FEC_OUT.type DERIVE'
     echo 'Erreurs_FEC_OUT.min 0'

     echo 'Erreurs_CRC_IN.label Erreurs CRC Montant'
     echo 'Erreurs_CRC_IN.type DERIVE'
     echo 'Erreurs_CRC_IN.min 0'

     echo 'Erreurs_CRC_OUT.label Erreurs CRC Desendant'
     echo 'Erreurs_CRC_OUT.type DERIVE'
     echo 'Erreurs_CRC_OUT.min 0'

     echo 'Erreurs_HEC_IN.label Erreurs HEC Montant'
     echo 'Erreurs_HEC_IN.type DERIVE'
     echo 'Erreurs_HEC_IN.min 0'

     echo 'Erreurs_HEC_OUT.label Erreurs HEC Desendant'
     echo 'Erreurs_HEC_OUT.type DERIVE'
     echo 'Erreurs_HEC_OUT.min 0'

     exit 0

fi

  wget -q -O"$PAGE_FILE" "http://$IP_TELE2$PAGE_TELE2"

  ret=$(grep "Erreurs FEC" "$PAGE_FILE" | cut -d\> -f5 | cut -d\< -f1 | cut -d\  -f1 | awk '{ gsub("\.","");print}' )
  echo "Erreurs_FEC_IN.value  $ret"
#on prend le muntilple de 1000 pour les fec pour garder une echelle comparable entres les grandeur
  ret=$(grep "Erreurs FEC" "$PAGE_FILE" | cut -d\> -f5 | cut -d\< -f1 | cut -d\/ -f2 | awk '{ gsub("\.[0-9][0-9][0-9]$","");print}' | awk '{ gsub("\.","");print}' )
  echo "Erreurs_FEC_OUT.value $ret"
  ret=$(grep "Erreurs FEC" "$PAGE_FILE" | cut -d\> -f5 | cut -d\< -f1 | cut -d\  -f1 | awk '{ gsub("\.","");print}' )
  echo "Erreurs_CRC_IN.value  $ret"
  ret=$(grep "Erreurs CRC" "$PAGE_FILE" | cut -d\> -f5 | cut -d\< -f1 | cut -d\/ -f2 | awk '{ gsub("\.","");print}' )
  echo "Erreurs_CRC_OUT.value $ret"
  ret=$(grep "Erreurs CRC" "$PAGE_FILE" | cut -d\> -f5 | cut -d\< -f1 | cut -d\  -f1 | awk '{ gsub("\.","");print}' )
  echo "Erreurs_HEC_IN.value  $ret"
  ret=$(grep "Erreurs HEC" "$PAGE_FILE" | cut -d\> -f5 | cut -d\< -f1 | cut -d\/ -f2 | awk '{ gsub("\.","");print}' )
  echo "Erreurs_HEC_OUT.value $ret"

Et le dernier, qui surveille les paquets et actions pouvant servir aux intrusions:

#!/bin/sh
##############################################################################
##                     DESCRIPTION                                          ##
##############################################################################
#
# par Florent Fortin
# sous license GPL
#
#  Ce script récupère les donnée sur la page "détection des intrusions" et
#formate ces donnée pour munin
#
#le script comprent les commandes:
#  -> autoconf
#  -> config
#  -> 

##############################################################################
##                     Variable de configuration                            ##
##############################################################################

#l'adresse ip du modem routeur TELE2
IP_TELE2="192.168.1.254"

#############################################################################
##                CONSTANTE POUR FACILITE L'EVOLUTION DU SCRIPT            ##
#############################################################################
#
#ces constantes sont là pour s'adapter à d'eventuelles modifications
#du firmware du modem ou pour permetre au script d'évoluer
#

#page de l'interface WEB qui liste les tentative d'intrusion
PAGE_TELE2="/cgi/b/ids/ov/?be=0&l0=2&l1=7"
#son titre pour verifier que c'est bien elle:
PAGE_TELE2_TITLE="SpeedTouch - Détection des intrusions"

#fichier temporaire ou sera stocké cette page pour faire les traitement
PAGE_FILE="/tmp/temp.TELE2.page.intrusions"

#Liste des intrusion possible
INTRUSIONS="fragment_sweep zero-length_fragment_size small_fragment_size fragment_size_overrun \
fragment_overlap fragment_out-of-order ip_protocol_scan tcp_port_scan tcp_syn_scan \
stealth_tcp_null_scan stealth_tcp_fin_scan stealth_tcp_xmas_scan stealth_tcp_full_xmas_scan \
stealth_tcp_vecna_scan stealth_tcp_syn-fin_scan udp_port_scan ping_sweep_scan tcp_syn_flood \
udp_flood ping_flood icmp_unreachable_storm smurf_broadcast_attack smurf_storm_attack \
fraggle_broadcast_attack fraggle_storm_attack land_attack tcp_null_port tcp_data_on_syn_segment \
tcp_invalid_urgent_offset udp_null_port icmp_type_unknown p_code_unknown ip_zero_payload tcp_rate_limiting \
udp_rate_limiting icmp_rate_limiting ip_rate_limiting"

#############################################################################
##                          SCRIPT                                         ##
#############################################################################

if [ "$1" = "autoconf" ]; then
    #on recupère la page
    wget -q -O"$PAGE_FILE" "http://$IP_TELE2$PAGE_TELE2"
    #on verifie que c'est la bonne page avec son titre
    ret=$(grep "$PAGE_TELE2_TITLE" "$PAGE_FILE" | wc -l)
       if [ "$ret" = "1" ] ; then
		echo yes
		exit 0
	else
		echo no
		exit 1
	fi
fi

if [ "$1" = "config" ]; then
     echo 'graph_title TELE2 Detection des intrusions'
     echo 'graph_args --base 1000 -l 0'
     echo 'graph_vlabel UNITE'
     echo 'graph_category TELE2'
     for i in $INTRUSIONS
        do
           name=$(echo $i | awk '{ gsub("-","_");print}')
           echo "$name.label $i"
#A verifier si on laisse en DERIVE
           echo "$name.type DERIVE"
           echo "$name.min 0"
        done
     exit 0

fi

wget -q -O"$PAGE_FILE" "http://$IP_TELE2$PAGE_TELE2"
for i in $INTRUSIONS
  do
      name=$(echo $i | awk '{ gsub("-","_");print}')
      ret=$(grep "$i" "$PAGE_FILE" | cut -d\> -f5 | cut -d\< -f1)
      echo "$name.value $ret"
  done