Pbx dead when no internet connection,resolved

tolengo

Joined
Oct 31, 2008
Messages
117
Likes
0
Points
0
#1
Hi guys i create a simple script to resolve the SIP registrations when no internet connection, with this you will can call on between extensions even if no interntet.
Its like a patch for asterisk hihihiih:laugh:


#!/bin/bash
################################################
# CREATED BY JOHNNY TOLENGO madero@email.cz #
################################################

#first we need to create a file in /etc/asterisk/register_status
#after this may you want to add to cron to run it :)
#other thing you can add to this script is some cycle with brakes to ping to more ip addresses its about your security if the one ip will not ping then you will can
#call to the outside by sip so.. be carefull
#nothing more just enjoy it!!

#dont forget comment all the echos :)

#pide una direccion IP al usuario y reliza un 3 pings con interva

#ip to ping
myip=google.com

#reading the file
ESTADO=`cat /etc/asterisk/register_status`
#extracting the value from de file
VALOR="on"
VALOR2="off"
#ping 3times
#if the ping is active do -->
if $(ping -c3 -i 2 $myip > /dev/null);then

#if status is ON
if [ "$ESTADO" = "$VALOR" ]; then
echo all its OK
#if status is OFF
else
sed -i s/off/on/g /etc/asterisk/register_status
rm -f /etc/asterisk/sip_registrations.conf
mv /etc/asterisk/sip_registrations_backup.conf /etc/asterisk/sip_registrations.conf
echo changed to the original
fi

else
if [ "$ESTADO" = "$VALOR2" ]; then
echo all its ok off status no pinging
#if status is OFF
else
sed -i s/on/off/g /etc/asterisk/register_status
mv /etc/asterisk/sip_registrations.conf /etc/asterisk/sip_registrations_backup.conf
touch /etc/asterisk/sip_registrations.conf
chmod 664 /etc/asterisk/sip_registrations.conf
chown asterisk /etc/asterisk/sip_registrations.conf
chgrp asterisk /etc/asterisk/sip_registrations.conf
echo changed to an empty sip_registrations.conf
fi




fi


For some other ideas just write.

Johnny
 

tolengo

Joined
Oct 31, 2008
Messages
117
Likes
0
Points
0
#2
i dont know why it was posted 3 times, i cant edit :angry: .
Please somebody to edit the thread it.
 

tolengo

Joined
Oct 31, 2008
Messages
117
Likes
0
Points
0
#3
Hi folks nobody wrote this or try?

What do you think about?

I need your opinions, Rafa, Dicko,danardf,bob...

thank you.

Johnny
 

wiseoldowl

Joined
Aug 19, 2008
Messages
251
Likes
0
Points
0
#4
Boy, this code looks familiar... I can't put my finger on where I've seen it (or something very similar) before, but it shares the same fatal flaw that kept me from trying that code, which is that it only pings ONE location. I don't care if it's google.com, EVERY site goes down from time to time and I don't want to declare my connectivity gone just because one site is not returning pings! It's not good enough to retry the ping multiple times to the same location, you need to check two or three different locations and only if NONE of them are reachable do you decide the Internet is down.
 

tolengo

Joined
Oct 31, 2008
Messages
117
Likes
0
Points
0
#5
I know that i just posted an example of course that you can't implement this in some bigger structure with ONE pinging IP, for other better utilities its enought to create some cycle with 5 pings or more. I didn't it because i am busy 24 hr a day but i will otherwise i think it super solution for a fatal Asterisk error.

Bye

Johnny
 

ElasMex

Joined
Oct 22, 2007
Messages
493
Likes
0
Points
16
#6
Hello

I generate a cron task.
 

tolengo

Joined
Oct 31, 2008
Messages
117
Likes
0
Points
0
#7
then please post your experiences here.

nice day.

Johnny
 

tolengo

Joined
Oct 31, 2008
Messages
117
Likes
0
Points
0
#8
It's really interesting nobody reacts to this post maybe every body except 4 people including me has an "SPECIAL ASTERISK EDITION" which has not this BUG :D :D :D
 

kostasics

Joined
Jan 16, 2009
Messages
45
Likes
0
Points
0
#9
maybe we dont know hoe to doit ???
 

johnme

Joined
Nov 28, 2008
Messages
148
Likes
0
Points
0
#10

Members online

No members online now.

Latest posts

Forum statistics

Threads
30,902
Messages
130,887
Members
17,567
Latest member
achilont13
Top