Ticket #3505 (new Feature Requests)

Opened 3 years ago

Last modified 1 year ago

Way to enable/disable individual trunks from outside of FreePBX GUI (command line, script, etc.)

Reported by: wiseoldowl Assigned to: p_lindheimer
Priority: major Milestone: 2.10
Component: Core - Trunks/Routing Version:
Keywords: Cc:
Confirmation: Unreviewed SVN Revision (if applicable):
Backend Engine: All Backend Engine Version:

Description

This feature request is posted after reading about the 999th thread about people losing sleep and/or hair because of the ASTERISK bug of losing almost all connectivity (even for internal extensions, zap trunks, etc.) if the Internet connection is interrupted.

The basic problem is that if there are ANY sip trunks enabled when the Internet goes down, Asterisk could potentially stop connecting calls. This has been discussed in other tickets including my previous Ticket #3199 so I will not rehash that discussion here. However, it occurs to me that there may be many reasons someone might want to be able to enable or disable individual trunks from within a bash or perl script, etc.

As far as I know, FreePBX doesn't offer any sort of command line interface to any of its functions. I'm suggesting here that it might be a good idea to consider having such an interface so that certain functions that are now only possible to control from within the GUI could be controlled from a script. And I would suggest that the capability of enabling or disabling individual trunks should be high on the list (as well as a way to force a FreePBX configuration reload, similar to clicking the orange bar in the GUI).

If by some chance this capability is already present, it has not ever come to my attention, so in that case please point me to the relevant documentation. But if, as I suspect, no such capability exists, I would suggest that it would be a well-received addition.

Change History

02/02/09 16:20:58 changed by francesco_r

I had this problem too and i have tried every possibile solution: local dns cache, force the ip address in /etc/hosts but the problem is that asterisk has a poor dns implementation. This problem is resolved in asterisk 1.6.1 (not 1.6.0), the DNS manager now run in background and perform DNS lookups asynchronously.
However you can try this script, taken from an another forum but adapted for freepbx 2.4/2.5. When internet is down it rename the /etc/asterisk/sip_registrations* files and reload asterisk. For me this resolved all hang problems.

# check if network is up
VAR=`ping -c 1 $1  > /dev/null; echo $?`
VAR2=`ping -c 1 $2  > /dev/null; echo $?`

#
 if [ $VAR -ne 0 ]; then
  if [ $VAR2 -ne 0 ]; then

    if [ -f /etc/asterisk/netup.ok ]; then
       rm /etc/asterisk/netup.ok
       mv /etc/asterisk/sip_registrations.conf /etc/asterisk/sip_registrations.conf.down
       mv /etc/asterisk/sip_registrations_custom.conf /etc/asterisk/sip_registrations_custom.conf.down
       /usr/sbin/asterisk -r -x "reload"
    fi
  fi
 else
  if [ -f /etc/asterisk/netup.ok  ]; then
     echo 1 > /dev/null
   else
      echo 1 > /etc/asterisk/netup.ok
      mv /etc/asterisk/sip_registrations.conf.down /etc/asterisk/sip_registrations.conf
      mv /etc/asterisk/sip_registrations_custom.conf.down /etc/asterisk/sip_registrations_custom.conf
      /usr/sbin/asterisk -r -x "reload"
   fi

 fi

You name this script for example:

/usr/sbin/check_wan.sh

and in crontab you add

*/3 * * * * /usr/sbin/check_wan.sh 4.2.2.2 208.67.222.222 1> /dev/null

So every 3 minutes check if two famous dns are available and if both are unreachable execute the script.

02/02/09 18:13:11 changed by francesco_r

I lost the first row on cut and paste:

#!/bin/sh

08/15/09 20:19:09 changed by p_lindheimer

  • version deleted.
  • component changed from - choose - to Core - Trunks/Routing.
  • milestone changed from 2.6 to 2.7.

02/28/10 10:53:46 changed by p_lindheimer

  • milestone changed from Cut Line to 2.8.

05/20/10 18:37:40 changed by p_lindheimer

  • milestone changed from 2.8 to Cut Line.

02/26/11 13:05:50 changed by p_lindheimer

  • milestone changed from Cut Line to 2.10.