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.8.2.tar.gz
tar -zxvf monit-4.8.2.tar.gz
cd monit-4.8.2
./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.

###############################################################################
## Global section
###############################################################################
##
## Start monit in background (run as daemon) and check the services at 2-minute
## intervals. 
#
set daemon  120
## Set syslog logging with the 'daemon' facility. If the FACILITY option is
## omited, monit will use 'user' facility by default. You can specify the
## path to the file for monit native logging. 
#
set logfile syslog facility log_daemon
#
## Monit has an embedded webserver, which can be used to view the
## configuration, actual services parameters or manage the services using the
## 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
#

Change permissions on monitrc

chmod 700 /usr/local/etc/monitrc

Monit can run and be controlled from init. If monit should crash, init will re-spawn a new monit process. To setup monit to run from init, you can use the 'set init' statement in monit's control file

vi /etc/inittab

Add:

# 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!!!!

Installation Stuff