Finito
Codice:
#!/bin/sh
COUNTER=0
SLEEP_SECONDS=60
#infinite loop
while [ 1 ]; do
#get SNR Margin value
SNR=`adslctl info --show | grep SNR | sed 's/[^0-9]//g' | sed 's/[0-9][0-9][0-9][0-9]$//'`
if [ ${#SNR} = 0 ]; then
#SNR Margin not available, maybe router is training line
sleep $SLEEP_SECONDS
continue
fi
#get SNR Retrain Limit value
RETRAIN_SNR=`nvram get adsl_retrain_snr | sed 's/name=//'`
if [ ${#RETRAIN_SNR} = 0 ]; then
#value not available, first time running this script set the value to 6
nvram set adsl_retrain_snr=6
RETRAIN_SNR="6"
fi
if [ $SNR -gt $RETRAIN_SNR ]; then
#no need to retrain line
sleep $SLEEP_SECONDS
continue
fi
#delete log after 10 retrain
if [ $COUNTER -eq 10 ]; then
rm /tmp/retrain.log
COUNTER=0
fi
let COUNTER++
#retrain line and write to /tmp/retrain.log SNR value
uptime >> /tmp/retrain.log
echo "SNR Margin value is $SNR dB and limit is $RETRAIN_SNR...training line" >> /tmp/retrain.log
adslctl configure --snr `nvram get adsl_snr | sed 's/name=//'`
sleep $SLEEP_SECONDS
done
Lo script dovrebbe essere adatto per tutti i router del firmware DGTeam (se non sbaglio hanno tutti chipset Broadcom).
Se qualcuno vuole testare questo script sul router...è possibile creare un file in questo modo:
cat > /tmp/retrainlimit.sh
A questo punto incollate il testo. Se il cursore vi rimane in fondo alla parola "done" premete invio. Premete due volte CTRL+D.
chmod +x /tmp/retrainlimit.sh
Ora è pronto per essere eseguito. Ovviamente il file resta solo fino al riavvio del router. Però visti gli uptime in questo thread non mi sembra un grosso problema.
Lo script setta automaticamente a 6 la variabile adsl_retrain_snr in nvram.
Se volete, successivamente potete intervenire su questo valore (che rimarrà anche dopo il reboot) con il comando:
nvram set adsl_retrain_snr=X
Il funzionamento è semplice: ogni minuto viene rilevato il valore di SNR e viene fatto il retrain se il SNR attuale è minore di X+1 dB.
Per visualuzzare il log basta eseguire il comando:
cat /tmp/retrain.log
Per eseguire lo script (resterà in esecuzione fino al riavvio del router):
/tmp/retrainlimit.sh &
Ora date exit e chiudete la sessione di telnet (non si chiuderà da sola).
Il log viene eliminato dopo 10 volte che viene fatto il retrain (per evitare di riempire la ram).