– Kamailio SIP Server –

Make OpenSER init scipt working with monit

Requires monit - a daemon monitoring tool

Info: http://www.tildeslash.com/monit

cp <openser src>/etc/openser.init /etc/init.d/openser
chmod 755 /etc/init.d/openser
wget http://www.tildeslash.com/monit/dist/monit-4.7.tar.gz
tar -zxvf monit-4.7.tar.gz
cd monit-4.7
./configure
make
make install
vi /usr/local/etc/monitrc

This is about the most basic config you need to get monit with openser.init working.

  1. ##############################################################################
  2. Global section
  3. Start monit in background (run as daemon) and check the services at 2-minute
  4. intervals.

set daemon 120

  1. # Set syslog logging with the 'daemon' facility. If the FACILITY option is
  2. omited, monit will use 'user' facility by default. You can specify the
  3. path to the file for monit native logging.

set logfile syslog facility log_daemon

  1. Monit has an embedded webserver, which can be used to view the
  2. configuration, actual services parameters or manage the services using the
  3. web interface.

set httpd port 2812 and use the address 127.0.0.1

      allow 127.0.0.1
###############################################################################
## Services
############################################################################### 
#
check process openser with pidfile /var/run/openser.pid
   group openser
   start program = "/etc/init.d/openser openserstart"
   stop  program = "/etc/init.d/openser openserstop"
   if 2 restarts within 3 cycles then timeout
#
chmod 700 /usr/local/etc/monitrc
vi /etc/inittab
  1. Run monit in standard run-levels

mo:2345:respawn:/usr/local/bin/monit -Ic /usr/local/etc/monitrc

restart inittab

telinit q

At this point anytime 120 sec if /var/run/openser.pid doesn't exist it will restart openser and if 2 restarts within 3 cycles then it will stop trying.

This is Just scratching the surface of what monit can do.

The info in this document may not be the best but at least seems like a start!!!!