[ninux-not-wireless] ADSL e IP dinamico
Alessandro (aka ArkaNet)
arkantiko at gmail.com
Sat Apr 13 14:39:25 CEST 2013
Ale ma non è un discorso di esistere o meno ... il gruppo più bello è
proprio la community ;)
Comunque ho appena sfornato la RC1
Rispetto al precedente
- controlla l'esistenza della directory
- semplifica l'inserimento del gateway e dell'host oggetto dei test
- crea un file di log giornliero
- alleggerisce il log (meno righe)
#######################[CUT ME]#######################
#!/bin/bash
#
# EASY IP LOGGER RC1
#
DIR="/var/log/IP_LOG/"
if [ -d ${DIR} ]
then
DIR=$DIR
else
mkdir /var/log/IP_LOG
DIR="/var/log/IP_LOG/"
fi
HOST="www.google.com"
GW="192.168.1.254"
while true; do
FILE=${DIR}`date "+%Y_%m_%d"`.log
test_ping=$(echo $(ping -c 1 ${HOST} | grep "packet loss" | awk '
BEGIN { FS = ", " } ; {print $3} ' | awk ' {print $1} ' | cut -d'%' -f1))
test_gw=$(echo $(ping -c 1 ${GW} | grep "packet loss" | awk ' BEGIN
{ FS = ", " } ; {print $3} ' | awk ' {print $1} ' | cut -d'%' -f1))
if [ ${test_ping} -eq 0 -a ${test_gw} -eq 0 ]
then
echo -e $(curl -s checkip.dyndns.com | awk ' BEGIN { FS = ": " } ; {print
$2} ' | cut -d '<' -f1 | while read host; do echo -e "[$(date
+"\033[01;32m%F\033[00m \033[01;31m%T\033[00m")] MY IP IS REACHABLE:
[${host}]"; done) >> ${FILE}
elif [ ${test_ping} -ne 0 -a ${test_gw} -eq 0 ]
then
echo -e "[$(date +"\033[01;32m%F\033[00m
\033[01;31m%T\033[00m")] YOUR INTERNET CONNECTION UNAVAILABLE" >> ${FILE}
echo -e "[$(date +"\033[01;32m%F\033[00m
\033[01;31m%T\033[00m")] BUT YOUR GW [${GW}] IS REACHABLE" >> ${FILE}
else
echo -e "[$(date +"\033[01;32m%F\033[00m \033[01;31m%T\033[00m")] YOUR
INTERNET CONNECTION IS UNAVAILABLE" >> ${FILE}
echo -e "[$(date +"\033[01;32m%F\033[00m \033[01;31m%T\033[00m")] AND YOUR
GW [${GW}] IS UNREACHABLE" >> ${FILE}
fi
sleep 60
done
exit 0
#######################[CUT ME]#######################
--
*Arka
*
Il giorno 13 aprile 2013 13:59, Alessandro Gubitosi <
gubi.ale at gotanotherway.com> ha scritto:
> **
> E poi dicono che il gruppo software non esiste-non funziona...
> Queste sono cose degne da wiki :)
> Grande grazie
>
> Il 12/04/2013 11:29, Alessandro (aka ArkaNet) ha scritto:
>
> Capita spesso a chi possiede una semplice linea adsl con IP dinamico
> di vedere il proprio IP cambiare frequentemente
> ecco un semplice script per tenerne traccia
>
> -----------------------------------------------------------[CUT
> ME]-----------------------------------------------------------
>
> #!/bin/bash
> #
> # EASY IP LOGGER
> #
> mkdir /var/log/IP_CHECK
> touch /var/log/IP_CHECK/ip.log
> DIR="/var/log/IP_CHECK/ip.log"
>
> while true; do
> echo -e "\n#################### [$(date +"\033[01;32m%F\033[00m
> \033[01;31m%T\033[00m")] ######################" >> $DIR
> test_ping=$(ping -c 3 www.google.com | while read pong; do echo -e
> "[$(date +"\033[01;32m%F\033[00m \033[01;31m%T\033[00m")] ${pong}"; done)
> test_ip=$(curl -s checkip.dyndns.com | awk ' BEGIN { FS = ": " } ;
> {print $2} ' | cut -d '<' -f1 | while read ip; do echo -e "[$(date
> +"\033[01;32m%F\033[00m \033[01;31m%T\033[00m")] ${ip}"; done)
> echo -e "${test_ping}\n" >> $DIR
> echo "${test_ip}" >> $DIR
> echo -e
> "#################################################################\n" >>
> $DIR
> sleep 60
> done
> exit 0
>
> -----------------------------------------------------------[CUT
> ME]-----------------------------------------------------------
>
>
> --
>
> *Arka*
>
>
> _______________________________________________
> Not-wireless mailing listNot-wireless at ml.ninux.orghttp://ml.ninux.org/mailman/listinfo/not-wireless
>
>
> _______________________________________________
> Not-wireless mailing list
> Not-wireless at ml.ninux.org
> http://ml.ninux.org/mailman/listinfo/not-wireless
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ml.ninux.org/pipermail/not-wireless/attachments/20130413/cbf5da42/attachment-0001.html>
More information about the Not-wireless
mailing list