Auto Restart Motif

I have a FreePBX server that runs our home telephone system. On occasion our internet connection will time out and that sets the motif system off track as motif does not automatically detect this problem. Changing ISPs is not an option and we have had the line from the VRAD and the modem replaced several times. There is no fixing the timeout issue and it is not a huge deal as it does not occur that often. The problem is that we are unaware that motif is not functioning until someone tells us. We have the server automatically restart every night at 12 o’clock but I would like to try to work out a better solution. Would it be possible to write a script that calls a number periodically and if the number does not answer in x amount of time the motif module restarts? I understand that this is not ideal but, it is the best solution I can think of as the internet time out issues is beyond my control. If you need any further information please let me know as I would be happy to provide it. I would also like to note that on most things you are going to have to be very verbose as I am not an expert in Asterisk or FreePBX.

Thanks In Advance

What the heck is motif?

motif (chan_motif) you know…*11 gtalk channel

Oh no I don’t know. tc1000 will have to help you out. I don’t know anything about Google Talk. Seems like a huge waste of time to me. Maybe I am missing the point.

This could apply to asterisk as a whole. Make a call, if no one answers, restart the server. It does not have to be specific to motif.

Also, why cluttler up the thread by posting useless comments that does not help us reach the goal? I don’t care how much of a waste of time you think it is. I care about is accomplishing the goal.

I answered back because I replied first?

2 cents is 2 cents.

Restarting the server after a call event would not be a feature with widespread appeal.

There seems to be a small group of folks who have constant NAT issues and need to do things like this. It’s always preferably to fix the network than to restart the service.

I don’t know if G-Talk represents any specific challenges.

Certainly setting up a script and restarting a module IE: asterisk -rx ‘motif reload’ is not an issue, it can be called fro the dial plan.

There is a place to put a script that will be run on your trunk when it fails, but there is a problem in that is is only called on an outgoing call, there is another problem with a failed network in that the inbound calls won’t work, so “how dos it know” it’s broken . .

Perhaps a cron one-liner that runs every minute something like:-

if [ ping -q -w 5 -c 1 8.8.8.1 > /dev/null;echo $? -eq 0 -a -f /tmp/pinggood ];then echo “everything is cool” ; if [ ! -f /tmp/pinggood ];then touch /tmp/pinggood;rasterisk -x “module load chan_motif”; fi; else echo “We have a problem with the dilithium crystals”; rasterisk -x “module unload chan_motif” ;fi

)where 8.8.8.1 is a p[lace you expect to be able to ping)

woops, (it would be nice to be able to edit ones post again)

if [ ping -q -w 5 -c 1 8.8.8.1 > /dev/null;echo $? -eq 0 -a -f /tmp/pinggood ];then echo “everything is cool” ; if [ ! -f /tmp/pinggood ];then touch /tmp/pinggood;rasterisk -x “module load chan_motif”; fi; else echo “We have a problem with the dilithium crystals”; rm -f /tmp/pinggood;rasterisk -x “module unload chan_motif” ;fi

Sorry, small problem with my dilithium crystals, logically this should work:-

if [ ping -q -w 5 -c 1 8.8.8.8 > /dev/null;echo $? -eq 0 ];then echo “everything is cool” ; if [ ! -f /tmp/pinggood ];then touch /tmp/pinggood;rasterisk -x “module load chan_motif”; fi; else echo “We have a problem with the dilithium crystals”; if [ -f /tmp/pinggood ];then rm -rf /tmp/pinggood;rasterisk -x “module unload chan_motif”;fi;fi

(as cron runs as sh and not bash in some OS’s you might need fully qualified paths to your ping, echo (but leave that crap out :wink: and rasterisk )

So let me see if I understand. I would add this line to my /etc/crontab file:

1 * * * * if [ ping -q -w 5 -c 1 8.8.8.8 > /dev/null;echo $? -eq 0 ];then echo “everything is cool” ; if [ ! -f /tmp/pinggood ];then touch /tmp/pinggood;rasterisk -x “module load chan_motif”; fi; else echo “We have a problem with the dilithium crystals”; if [ -f /tmp/pinggood ];then rm -rf /tmp/pinggood;rasterisk -x “module unload chan_motif”;fi;fi

and it will ping Google’s DNS server every minute and if there is a reply it will leave motif alone and if there is no reply it will restart motif? The server runs the version of CentOS that comes with the FreePBX distro. To be quite honest I am not that huge of a linux guru which is why I choose FreePBX for my telephone system. It has a GUI.

Thanks in advance.

You pretty well nailed it, /tmp/pinggood is used as a “flag” so you don’t need to unnecessarily unload/load your module every minute.

No guru necessary here, just be a little comfortable with that strange black and white terminal thingy :wink: The GUI can do a lot, but it won’t change your socks for you :slight_smile:

Thank you very much. Hopefully this will help solve the problem. If not I don’t know what I am going to do. Is there anyway to tell it is actually working?

If it’s working than you can make and receive phone calls, if it’s not then you can’t. But as previously suggested, your real problem is the network and the only real cure is to have your provisioner fix the network, if they won’t then this should work as a work-around.

If you can prove that chan_motif is at fault then perhaps a bug report with Digium is in order.

I have a similar problem where my GV trunks stop working. I’m not sure that my link is going dow, but it could be that when backup or sync jobs are running that the increased latency causes something to time out.

I don’t understand why motif can’t reconnect. I believe that if I have a Gtalk messaging client running on a PC, it will auto-reconnect when a link goes down then up