Hi Nedi It would be better to find out the exact conditions when it fails rather than the shotgun approach which could be risky and introduce other issues. I would use Monit which checks every minute and is very flexible. E.g.
Check program Check-Script path <script path> if status = 1 for 3 cycles then exec "/usr/sbin/asterisk -x 'module reload chan_sip.so'" The script could be something like: #!/bin/sh -e SHOW_TRUNKS="$(asterisk -x 'sip show peers' | grep $1)" if [[ $SHOW_TRUNKS != *"Unspecified"* ]] && [[ $SHOW_TRUNKS = *"UNKNOWN"* ]]; then echo "Trunk needs a reload" exit 1 else echo "Trunk is normal" exit 0 fi You could also do a ping check in the script. Regards Michael Knill From: nedi <n...@gmx.ch> Reply-To: AstLinux List <astlinux-users@lists.sourceforge.net> Date: Friday, 14 September 2018 at 7:31 am To: AstLinux List <astlinux-users@lists.sourceforge.net> Subject: [Astlinux-users] Astlinux network check and restart if internet down. Hi, i have trouble with one bx and message rejected after internet going down for some time. I found this script, but I’m not sure if I can use this on Astlinux. Can anyone help me to adapt this to Astlinux I would like to check internet and if internet connection broke and coming again I would like to restart asterisk if no registered. I think I need an script in combination with a cron job that check if registration fail. If registration fail then make sip reload. And if Internet going down for some time and up after some time, I would like check that and if internet UP an the registration fail or rejected. I would like reboot PBX or only Asterisk… could be something like thiis what I found: asterisk -rx " sip show registry" | grep -w Unregistered && asterisk -rx " sip reload" I found this to on the net. Can someone help me to combine those two cron. asterisk restart if the net is down and once a day just before 7am: crontab -e: 55 6 * * * /usr/sbin/asterisk -r -x "restart gracefully" >/dev/null 2>&1 5,10,15,20,25,30,35,40,45,50,55 * * * * /root/scripts/check_net /root/check_net #!/usr/bin/perl $net=`/bin/ping -c 02 google.com<http://google.com> 2>&1 | /bin/grep -c 'unknown host'`; if ($net==1) { print `/bin/date`; print `/usr/sbin/asterisk -r -x "restart gracefully"`; } Regards Nedi
_______________________________________________ Astlinux-users mailing list Astlinux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/astlinux-users Donations to support AstLinux are graciously accepted via PayPal to pay...@krisk.org.