[OpenSIPS-Users] Monit error under OpenSIPS 1.6.3 and Opensips-cp 4

Dave Singer dave.singer at wideideas.com
Wed Sep 8 19:14:42 CEST 2010


You may not have monit running as a service. Check the current status of
monit:
  monit status
It will tell you if it is running.
If it is not start it with:
  /etc/init.d/monit start
I primarily use centos and fedora but I think that will work with debian
systems too.
I think that the default config does not have the daemon set to listen for
communication. It needs this for commands like "monit status" and "monit
monitor opensips" and "monit unmonitor opensips"
something like this:
  set httpd port 2812 and
     use address localhost  # only accept connection from localhost
     allow localhost
Also you don't want to use the same call to the init.d script that is used
to start it up regularly otherwise you get a loop going or at least double
notify of (un)monitor actions.
What I do for the opensips portion of the monit config is have it call
/etc/init.d/opensips monit_start.
Then in /etc/init.d/opensips I have it catch that arg and not tell monit to
monitor but call the regular start function. When it gets the regular start
arg it calls the regular start function and then tells monit to start
monitoring it.
Also when the init.d script gets a restart command I don't update monit It
checks the pid file itself and realizes that the pid has changed and sends a
message to that affect rather then two messages, one that it us unmonitoring
and one that it is monitoring.
I've attached the /etc/init.d/opensips that I'm currently using.

Don't forget to make sure that the monit daemon will start on next reboot.

The attached init.d/opensips script uses some of redhats conventions for
displaying success/failure and adjust the working directory according to
your install. But I think overall it should be fairly portable to other
distros.

Note. Many of the options I pass to opensips are usually set in the script.
For the passed options to work they can not be set in opensips.cfg.
You may also notice that for a restart it validates the config before
allowing a restart. It does two levels of checks, the opensips -C to verify
the syntax of the config and actually starts a minimal opensips because
sometimes there are things that will make it not work even when the syntax
checks out.
The test run listens on lo:2056 so beware incase of conflicts. YMMV

Hope that helps.

Dave

On Wed, Sep 8, 2010 at 1:41 AM, Deon Vermeulen <vermeulen.deon at gmail.com>wrote:

> Hi Everyone
>
> I've successfully installed Opensips-cp 4 and got the Statistics monitoring
> to work, but I'm unable to get Monit to work.
>
> I've been all over google and tested recommendations, but with no luck.
>
> This is the procedure I followed to install Monit:
> *
> *
> *Step 1*: Install Monit:
> apt-get install monit
> *
> *
> *Step 2*: Once installed, you'll find the main configuration file.
> vi /etc/monit/monitrc
> set daemon  120
> set logfile syslog facility log_daemon
> set alert root at localhost
> set httpd port 2812 and
> use address yourdomain.com
> allow localhost       # allow localhost to connect to the server and
> allow youripaddress    # allow 192.168.1.2 to connect to the server,
> ###(What IP should this be? The IP of the this Box or where I am connecting
> from?)
>                       # You can give only one per entry
> allow admin:monit        # user name and password for
> authentication.  ###(I guess the Username and Password will be admin:admin
> if my login to Opensips-cp ios admin:admin)
> check process opensips with pidfile /var/run/opensips.pid
>
> ###(For Some Reason this does not work. Had to comment all).
> #Below is actions taken by monit when service got stuck.
> start program = "/etc/init.d/opensips start"
> stop program  = "/etc/init.d/opensips stop"
> # Admin will notify by mail if below of the condition satisfied.
> if cpu is greater than 70% for 2 cycles then alert
> if cpu > 90% for 5 cycles then restart
> *
> *
> *Step 3*: After modifying the configuration file, you should check for the
> syntax to
> make sure that everything is correct. To do this, run:
> # monit -t   (When I run this I get syntax OK)
> *
> *
> *Step 4:* Edit the /etc/default/monit file and change the parameters as
> follows:
> # You must set this variable to for 1 monit to start
> startup=1
> # To change the intervals which monit should run uncomment
> # and change this variable.
> # CHECK_INTERVALS=180
> *
> *
> *
> *
> *Configuring OpenSIPS Control Panel*
> *
> *
> *Step 1*: Configure the database access parameters. Edit the db.inc.phpfile, which is
> valid for all modules. You may change the database parameters for a single
> module
> inside the module configuration section.
> For example:
> cd /var/www/opensips-cp/config
> vi db.inc.php
> //database host
> $config->db_host = "localhost";
> //database port - leave empty for default
> $config->db_port = "";
> //database connection user
> $config->db_user = "root";
> //database connection password
> $config->db_pass = "opensips";
> //database name
> $config->db_name = "opensips";
> if ($config->db_port != "")$config->db_host=$config->db_host":"
> $config->db_port;
> *
> *
> *Step 2*: Configure the FIFO access in the boxes.global.inc.php file:
> cd /var/www/opensips-cp/config/
> vi boxes.global.inc.php
> $box_id=0;
> // mi host:port pair || fifo_file
> $boxes[$box_id]['mi']['conn']="127.0.0.1:8000";  # (I added this line, as
> per recommendation I found searching Google).
> $boxes[$box_id]['mi']['conn']="/tmp/opensips_fifo";
> // monit host:port
> $boxes[$box_id]['monit']['conn']="127.0.0.1:2812";
> $boxes[$box_id]['monit']['user']="admin";
> $boxes[$box_id]['monit']['pass']="monit";
> $boxes[$box_id]['monit']['has_ssl']=0;
> // description (appears in mi , monit )
> $boxes[$box_id]['desc']="primary SIP server";
> $boxes[$box_id]['assoc_id']=1;
> // enable local smonitor charts on this box : 0=disabled 1=enabled
> // (cron)
> $boxes[$box_id]['smonitor']['charts']=1;
>
>
> I added modparam("mi_fifo", "fifo_mode", 0666) to
> /etc/opensips/opensips.cfg
>
>
> *Restart apache*
>
>
>
> This i what I did to get Statistics Monitor working:
> *Setup Smonitor Tables*
> 1. Copy tables.mysql
>
> *cp /var/www/opensips-cp/config/tools/system/smonitor/tables.mysql
> /var/www/opensips-cp/web/tools/system/smonitor/tables.mysql*
> **
> *mysql -p opensips < tables.mysql*
> *
> *
>
> Thanks in advance for the help.
>
> Regards
> Deon
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.opensips.org/pipermail/users/attachments/20100908/b6fa7ae0/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: opensips
Type: application/octet-stream
Size: 4418 bytes
Desc: not available
Url : http://lists.opensips.org/pipermail/users/attachments/20100908/b6fa7ae0/attachment-0001.obj 


More information about the Users mailing list