Get help with installing, upgrading and running a PBX such as Asterisk.
User avatar
By WelshPaul
Posts Signature Likes Avatar Topics
#1808
As mentioned elsewhere I have FreePBX running on an Raspberry pi. (RasPBX)

I have several trunks registered, Voipfone, Voicehost and Sipgate to name a few. I have had issues with the Voipfone trunk where everything appears to work ok for a few days then out of nowhere inbound calls fail. The caller will hear one ring then the engaged tone. :-/

I have setup the following script to run as a cron job every minute - it will watch for the failure and reload asterisk to resolve it. Just follow the instructions! :P

Type:
Code: Select all
nano /home/pi/scripts/asterisk-reload-watchdog.sh
Copy and paste into above:
Code: Select all
#!/bin/bash

asterisk -rx "sip show registry" | grep -q "No Authentication"

if [ $? == 0 ]; then
  amportal a r
fi
Now press CTRL X then Y to save the and exit the file.

Next we need to set the permissions of the file we just created, to do this type:
Code: Select all
chmod +x /home/pi/scripts/asterisk-reload-watchdog.sh
Now that we have our script we just need to setup a cronjob to run it every 60 seconds. To do this type:
Code: Select all
sudo crontab -e
Copy and paste into above:
Code: Select all
*/1 * * * * /usr/bin/sudo /home/pi/scripts/asterisk-reload-watchdog.sh >> /home/pi/scripts/asterisk-reload-watchdog.log
Now press CTRL X then Y to save the and exit the file.
0
User avatar
By WelshPaul
Posts Signature Likes Avatar Topics
#1809
For anyone running Asterisk use the following:

Type:
Code: Select all
nano /root/scripts/asterisk-reload-watchdog.sh
Copy and paste into above:
Code: Select all
#!/bin/bash

/usr/sbin/asterisk -rx "sip show registry" | grep -q "No Authentication"

if [ $? == 0 ]; then
  /etc/init.d/asterisk reload
fi
Now press CTRL X then Y to save the and exit the file.

Next we need to set the permissions of the file we just created, to do this type:
Code: Select all
chmod +x /root/scripts/asterisk-reload-watchdog.sh
Now that we have our script we just need to setup a cronjob to run it every 60 seconds. To do this type:
Code: Select all
env EDITOR=nano crontab -e
Copy and paste into above:
Code: Select all
*/1 * * * * /root/scripts/asterisk-reload-watchdog.sh >> /root/scripts/asterisk-reload-watchdog.log
Now press CTRL X then Y to save the and exit the file.
0
#4688
I've also been experiencing 'No Authentication' with voipfone more and more often this year. I also have another trunk draytel and another non credential (ip authenticated) trunk on the same freepbx server without issues.

I will try your script!
0
User avatar
By WelshPaul
Posts Signature Likes Avatar Topics
#6017
A few years has passed since my original post and things have changed...
  1. FreePBX no longer uses "amportal" as its depreciated, FreePBX now uses the "fwconsole" command.
  2. CHAN_PJSIP has replaced CHAN_SIP.
As a result of the above changes I have updated the script to work with PJSIP and it now uses the "fwconsole" command to reload asterisk.

Type:
Code: Select all
nano /home/pi/scripts/asterisk-reload-watchdog.sh
Copy and paste into above:
Code: Select all
#!/bin/bash

asterisk -rx "pjsip show registrations" | grep -q "No Authentication"

if [ $? == 0 ]; then
  fwconsole reload
fi
Now press CTRL X then Y to save the and exit the file.

Next we need to set the permissions of the file we just created, to do this type:
Code: Select all
chmod +x /home/pi/scripts/asterisk-reload-watchdog.sh
Now that we have our script we just need to setup a cronjob to run it every 60 seconds. To do this type:
Code: Select all
sudo crontab -e
Copy and paste into above:
Code: Select all
*/1 * * * * /usr/bin/sudo /home/pi/scripts/asterisk-reload-watchdog.sh >> /home/pi/scripts/asterisk-reload-watchdog.log
Now press CTRL X then Y to save the and exit the file.
0
Sipgate Basic and multiple SIP clients

Ok, thanks. Was worried that using the same sip user in…

Your device was probably listed on Cisco's provisioning…

This means it is very dangerous to post here other t…

https://www.ukvoipforums.com/viewtopic.php?t=58#p5950

Sign up for VIP membership