Tahir Almas
2017-Feb-21 13:09 UTC
[asterisk-users] Which tool to automatically restart Asterisk ?
Why not to use Fail2ban https://www.voip-info.org/wiki/view/Fail2Ban+%28with+iptables%29+And+Asterisk *Tahir Almas* Managing Partner ICT Innovations http://www.ictinnovations.com http://www.ictbroadcast.com Leveraging open source in ICT On Tue, Feb 21, 2017 at 12:28 AM, Tzafrir Cohen <tzafrir.cohen at xorcom.com> wrote:> On Mon, Feb 20, 2017 at 11:36:24AM -0300, Victor Villarreal wrote: > > Hi, Oliver. > > > > Maybe something like this (add this script to your crontab): > > > > ------------------------8<-------------------------- > > > > #!/bin/bash > > # > > # File: asterisk-watchdog.sh > > # Date: 2015.05.26 > > # Build: v1.0 > > # Brief: Secuencia para monitorizar procesos. > > # > > # ${PATH}: Variable de entorno con las rutas a los ejecutables. > > PATH=/bin:/sbin:/usr/bin:/usr/sbin > > > > # ${DAEMON}: Demonio a monitorizar. > > DAEMON="asterisk" > > > > # ${MSG}: Cuerpo del mensaje a enviar por mail. > > MSG="$(date '+%F %T'): ${DAEMON} se ha caido!" > > > > pidof ${DAEMON} > /dev/null 2>&1 > > > > [ $? -ne 0 ] && { echo ${MSG}; service ${DAEMON} start; } > > > > exit 0 > > Both Debian 8 and Centos 7 have systemd. Systemd gives you this type of > monitoring almost for free (see previous reply). > > Using cron is generally not a good idea here: > > 1. No way to stop Asterisk when you need it. > > 2. If Asterisk has failed, it may take up to a minute to restart it. > > -- > Tzafrir Cohen > icq#16849755 jabber:tzafrir.cohen at xorcom.com > +972-50-7952406 mailto:tzafrir.cohen at xorcom.com > http://www.xorcom.com > > -- > _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > Check out the new Asterisk community forum at: https://community.asterisk. > org/ > > New to Asterisk? Start here: > https://wiki.asterisk.org/wiki/display/AST/Getting+Started > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20170221/eab700ee/attachment.html>
Olivier
2017-Feb-23 10:45 UTC
[asterisk-users] Which tool to automatically restart Asterisk ?
2017-02-21 14:09 GMT+01:00 Tahir Almas <tahir at ictinnovations.com>:> Why not to use Fail2ban https://www.voip-info.org/ > wiki/view/Fail2Ban+%28with+iptables%29+And+Asterisk > > How would fail2ban detect that Asterisk needs to be restarted ?> > > *Tahir Almas* > > Managing Partner > ICT Innovations > http://www.ictinnovations.com > http://www.ictbroadcast.com > Leveraging open source in ICT > > > > On Tue, Feb 21, 2017 at 12:28 AM, Tzafrir Cohen <tzafrir.cohen at xorcom.com> > wrote: > >> On Mon, Feb 20, 2017 at 11:36:24AM -0300, Victor Villarreal wrote: >> > Hi, Oliver. >> > >> > Maybe something like this (add this script to your crontab): >> > >> > ------------------------8<-------------------------- >> > >> > #!/bin/bash >> > # >> > # File: asterisk-watchdog.sh >> > # Date: 2015.05.26 >> > # Build: v1.0 >> > # Brief: Secuencia para monitorizar procesos. >> > # >> > # ${PATH}: Variable de entorno con las rutas a los ejecutables. >> > PATH=/bin:/sbin:/usr/bin:/usr/sbin >> > >> > # ${DAEMON}: Demonio a monitorizar. >> > DAEMON="asterisk" >> > >> > # ${MSG}: Cuerpo del mensaje a enviar por mail. >> > MSG="$(date '+%F %T'): ${DAEMON} se ha caido!" >> > >> > pidof ${DAEMON} > /dev/null 2>&1 >> > >> > [ $? -ne 0 ] && { echo ${MSG}; service ${DAEMON} start; } >> > >> > exit 0 >> >> Both Debian 8 and Centos 7 have systemd. Systemd gives you this type of >> monitoring almost for free (see previous reply). >> >> Using cron is generally not a good idea here: >> >> 1. No way to stop Asterisk when you need it. >> >> 2. If Asterisk has failed, it may take up to a minute to restart it. >> >> -- >> Tzafrir Cohen >> icq#16849755 jabber:tzafrir.cohen at xorcom.com >> +972-50-7952406 mailto:tzafrir.cohen at xorcom.com >> http://www.xorcom.com >> >> -- >> _____________________________________________________________________ >> -- Bandwidth and Colocation Provided by http://www.api-digital.com -- >> >> Check out the new Asterisk community forum at: >> https://community.asterisk.org/ >> >> New to Asterisk? Start here: >> https://wiki.asterisk.org/wiki/display/AST/Getting+Started >> >> asterisk-users mailing list >> To UNSUBSCRIBE or update options visit: >> http://lists.digium.com/mailman/listinfo/asterisk-users >> > > > -- > _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > Check out the new Asterisk community forum at: https://community.asterisk. > org/ > > New to Asterisk? Start here: > https://wiki.asterisk.org/wiki/display/AST/Getting+Started > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20170223/8eabe9d9/attachment.html>
Tahir Almas
2017-Feb-27 13:00 UTC
[asterisk-users] Which tool to automatically restart Asterisk ?
Sorry , I forget it for another monitoring tool monit that we have used in our production systems to restart asterisk in case of asterisk crash or halt. I have attached a monit configuration for your reference. it will work almost in all cases This configuration will check Asterisk for following 1. will check for Asterisk process. 2. will check Asterisk via AMI 3. will check Asterisk by sending a SIP request You simply need to install monit and place attached file on your server as /etc/monit.d/asterisk.conf and then restart monit service daemon *Tahir Almas* Managing Partner ICT Innovations http://www.ictbroadcast.com http://www.ictinnovations.com Leveraging open source in ICT On Thu, Feb 23, 2017 at 3:45 PM, Olivier <oza.4h07 at gmail.com> wrote:> > > 2017-02-21 14:09 GMT+01:00 Tahir Almas <tahir at ictinnovations.com>: > >> Why not to use Fail2ban https://www.voip-info.org/wiki >> /view/Fail2Ban+%28with+iptables%29+And+Asterisk >> >> How would fail2ban detect that Asterisk needs to be restarted ? > > >> >> >> *Tahir Almas* >> >> Managing Partner >> ICT Innovations >> http://www.ictinnovations.com >> http://www.ictbroadcast.com >> Leveraging open source in ICT >> >> >> >> On Tue, Feb 21, 2017 at 12:28 AM, Tzafrir Cohen <tzafrir.cohen at xorcom.com >> > wrote: >> >>> On Mon, Feb 20, 2017 at 11:36:24AM -0300, Victor Villarreal wrote: >>> > Hi, Oliver. >>> > >>> > Maybe something like this (add this script to your crontab): >>> > >>> > ------------------------8<-------------------------- >>> > >>> > #!/bin/bash >>> > # >>> > # File: asterisk-watchdog.sh >>> > # Date: 2015.05.26 >>> > # Build: v1.0 >>> > # Brief: Secuencia para monitorizar procesos. >>> > # >>> > # ${PATH}: Variable de entorno con las rutas a los ejecutables. >>> > PATH=/bin:/sbin:/usr/bin:/usr/sbin >>> > >>> > # ${DAEMON}: Demonio a monitorizar. >>> > DAEMON="asterisk" >>> > >>> > # ${MSG}: Cuerpo del mensaje a enviar por mail. >>> > MSG="$(date '+%F %T'): ${DAEMON} se ha caido!" >>> > >>> > pidof ${DAEMON} > /dev/null 2>&1 >>> > >>> > [ $? -ne 0 ] && { echo ${MSG}; service ${DAEMON} start; } >>> > >>> > exit 0 >>> >>> Both Debian 8 and Centos 7 have systemd. Systemd gives you this type of >>> monitoring almost for free (see previous reply). >>> >>> Using cron is generally not a good idea here: >>> >>> 1. No way to stop Asterisk when you need it. >>> >>> 2. If Asterisk has failed, it may take up to a minute to restart it. >>> >>> -- >>> Tzafrir Cohen >>> icq#16849755 jabber:tzafrir.cohen at xorcom.com >>> +972-50-7952406 mailto:tzafrir.cohen at xorcom.com >>> http://www.xorcom.com >>> >>> -- >>> _____________________________________________________________________ >>> -- Bandwidth and Colocation Provided by http://www.api-digital.com -- >>> >>> Check out the new Asterisk community forum at: >>> https://community.asterisk.org/ >>> >>> New to Asterisk? Start here: >>> https://wiki.asterisk.org/wiki/display/AST/Getting+Started >>> >>> asterisk-users mailing list >>> To UNSUBSCRIBE or update options visit: >>> http://lists.digium.com/mailman/listinfo/asterisk-users >>> >> >> >> -- >> _____________________________________________________________________ >> -- Bandwidth and Colocation Provided by http://www.api-digital.com -- >> >> Check out the new Asterisk community forum at: >> https://community.asterisk.org/ >> >> New to Asterisk? Start here: >> https://wiki.asterisk.org/wiki/display/AST/Getting+Started >> >> asterisk-users mailing list >> To UNSUBSCRIBE or update options visit: >> http://lists.digium.com/mailman/listinfo/asterisk-users >> > > > -- > _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > Check out the new Asterisk community forum at: https://community.asterisk. > org/ > > New to Asterisk? Start here: > https://wiki.asterisk.org/wiki/display/AST/Getting+Started > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20170227/ecc428cf/attachment.html> -------------- next part -------------- check process asterisk with pidfile /var/run/asterisk/asterisk.pid group asterisk start program = "/bin/bash -c 'ulimit -n 16386 && /etc/init.d/asterisk start'" stop program = "/etc/init.d/asterisk stop" if does not exist for 2 cycles then restart if failed port 5060 type udp protocol SIP and target "011 at 127.0.0.1" maxforward 10 for 2 cycles then restart if failed host 127.0.0.1 port 5038 with timeout 15 seconds for 2 cycles then restart if 5 restarts within 5 cycles then timeout