Pbx dead when no internet connection,resolved

Discussion in 'General' started by tolengo, Feb 17, 2009.

  1. tolengo

    Joined:
    Oct 31, 2008
    Messages:
    117
    Likes Received:
    0
    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
     
  2. tolengo

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

    Joined:
    Oct 31, 2008
    Messages:
    117
    Likes Received:
    0
    Hi folks nobody wrote this or try?

    What do you think about?

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

    thank you.

    Johnny
     
  4. wiseoldowl

    Joined:
    Aug 19, 2008
    Messages:
    251
    Likes Received:
    0
    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.
     
  5. tolengo

    Joined:
    Oct 31, 2008
    Messages:
    117
    Likes Received:
    0
    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
     
  6. ElasMex

    Joined:
    Oct 22, 2007
    Messages:
    493
    Likes Received:
    0
    Hello

    I generate a cron task.
     
  7. tolengo

    Joined:
    Oct 31, 2008
    Messages:
    117
    Likes Received:
    0
    then please post your experiences here.

    nice day.

    Johnny
     
  8. tolengo

    Joined:
    Oct 31, 2008
    Messages:
    117
    Likes Received:
    0
    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
     
  9. kostasics

    Joined:
    Jan 16, 2009
    Messages:
    45
    Likes Received:
    0
    maybe we dont know hoe to doit ???
     
  10. johnme

    Joined:
    Nov 28, 2008
    Messages:
    148
    Likes Received:
    0

Share This Page