calling opensipsctl fifo lb_status 2 1 by xmlrpc

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

calling opensipsctl fifo lb_status 2 1 by xmlrpc

bluerain
This post was updated on .
Ok, so I figured that you can use xmlrpc to call fifo function remotely, but the issue is I am no linux expert, so I've been reading things here and there.  

I guess the thing I need to do is to write a xxx.php file on Asterisk and then use the php -h xxx.php to execute it to send a command to opensips server?

If that is the case can someone provide me with a simple php script to just call "lbl_status 2 1" with php script?

I saw a thread (google search), it had something like:

>>>> POST /RPC2 HTTP/1.0
>>>> Host: 127.0.0.1
>>>> Connection: close
>>>> User-Agent: OpenSIPg XML_RPC Client
>>>> Content-Type: text/xml
>>>> Content-Length: 1000
>>>>
>>>> <?xml version="1.0" ?>
>>>> <methodCall>
>>>>    <methodName>get_statistics</methodName>
>>>>    <params>
>>>>        
>>>>            <value><string>dialog:</string></value>
>>>>        
>>>>        
>>>>            <value><string>tm:</string></value>
>>>>        
>>>>   </params>
>>>> </methodCall>

so what is this?  Is this something I can put in a text file (and name it with extension .php)?

And execute it with php -f?

I simply want to know the easiest way that I can send a opensipsctl fifo lb_status command from asterisk server (running CentOS) to OpenSIP (running on Debian)

I would greatly appreciate any help I can get.

thank you!
Reply | Threaded
Open this post in threaded view
|

Re: calling opensipsctl fifo lb_status 2 1 by xmlrpc

bluerain
Nevermind, I finally get it.  So is NOT PHP, I know I may sound stupid, but to linux rookie, is very hard.

So just for future reference, or anybody would like to know:

1. Install make sure you have python install in your OS
2. Make a file with extension of .py (e.g. the following):

#!/usr/bin/python
import xmlrpclib
opensips = xmlrpclib.ServerProxy('http://192.168.1.1:8000/RPC2')
print opensips.lb_status(1,0);

and then on the CLI of the OS which the compute you would like to send the command to opensips, just type "python test.py"

lb_status(1,0) will turn off node #1 where
lb_status(1,1) will turn on node #1

This maybe simple for linux guru, but is hard to figure out for rookie...
hope this is of use to someone!