Hello list. I have a question about reliability in SER. Suppose that for certain reason, the process "ser" fails, and therefore the SIP Server is down. Is there a way to keep trace of the "ser" process status?? and if the process is not running start a script to restart the process. I know that maybe the "crond" command could be useful for this purpose. Does someone have any clue about this? Or maybe SER has his own "crond" module or something.? I really need and advice about this issue. Thanks in advance
Regards, Ricardo Martinez Ogalde.-
Hi Ricardo,
You can use "monit" to keep trace of you SER and to restart it if it's down. Monit main application is to keep trace of the web servers, but you can configure it for ser also. You can read more about monit at "http://www.tildeslash.com/monit/".
Best regards, Marian
Ricardo Martinez wrote:
Hello list. I have a question about reliability in SER. Suppose that for certain reason, the process "ser" fails, and therefore the SIP Server is down. Is there a way to keep trace of the "ser" process status?? and if the process is not running start a script to restart the process. I know that maybe the "crond" command could be useful for this purpose. Does someone have any clue about this? Or maybe SER has his own "crond" module or something.? I really need and advice about this issue. Thanks in advance
Regards, Ricardo Martinez Ogalde.-
Serusers mailing list serusers@lists.iptel.org http://lists.iptel.org/mailman/listinfo/serusers
/usr/local/ser/sbin/ser -P /var/run/ser.pid and check the content of the pidfile (process-id)
But don't rely on the ser.pid. Sometimes it stays alive....
Tiny shellscript:
liveForever.sh --------------------------------------------------------- #!/bin/bash while [ 1 ] do if ! $(ps ax | grep -q '[s]er ') then ...clean up.... ...restart ser.... fi
sleep 5 done --------------------------------------------------------- and put this line in your inittab: ww:345:respawn:/path/to/your/liveForever.sh
Ricardo Martinez schrieb:
Hello list. I have a question about reliability in SER. Suppose that for certain reason, the process "ser" fails, and therefore the SIP Server is down. Is there a way to keep trace of the "ser" process status?? and if the process is not running start a script to restart the process. I know that maybe the "crond" command could be useful for this purpose. Does someone have any clue about this? Or maybe SER has his own "crond" module or something.? I really need and advice about this issue. Thanks in advance
Regards, Ricardo Martinez Ogalde.-
Serusers mailing list serusers@lists.iptel.org http://lists.iptel.org/mailman/listinfo/serusers
Try this from cron:
#!/usr/bin/perl
use Mail::Send;
use strict;
my $VERBOSE = 0; if(@ARGV && $ARGV[0] eq "-v") { $VERBOSE = 1; shift; }
my $OK = 0; my $DEAD = -1; my $RESTARTED = 1; my $SER_PID = (@ARGV && $ARGV[0]) || "/var/run/ser.pid";
my $result = ser();
if($result != $OK) { my $m = new Mail::Send; my $subject = $ENV{HOSTNAME} . ": "; $subject .= $result == $DEAD ? "FATAL SER ERROR " : "WARNING - SER RESTARTED"; my $body = $result == $DEAD ? "ser did not start after /etc/rc.d/ser restart" : "ser was not running, but was successfully restarted with /etc/rc.d/ser/restart";
$m->subject($subject); $m->to('root'); my $fh = $m->open; print $fh $body; $fh->close; }
sub ser { my $status = $OK; if(! ser_running()) { $status = $DEAD; print "$0: ser not running ($SER_PID)\n" if($VERBOSE); system("(/etc/rc.d/ser restart 2>&1) >/dev/null"); sleep 10; if(ser_running()) { print "$0: ser now running after restart\n" if($VERBOSE); $status = $RESTARTED; } } else { print "$0: ser running ok - nothing to do\n" if($VERBOSE); } return $status; }
sub ser_running { if(! -e $SER_PID || ! -f $SER_PID) { return 0; } else { open( SER , "< $SER_PID" ) || die "$0: failure opening: $SER_PID ($!)\n"; my $pid = <SER>; chomp $pid; if(kill 0, $pid) { return 1; } else { return 0; } } }