[SR-Users] Reload htable

Daniel-Constantin Mierla miconda at gmail.com
Fri Mar 27 15:05:39 CET 2015


Hello,

actually it is possible to execute rpc commands (e.g., htable.reload)
from kamailio.cfg, starting with version 4.2 -- you have to use
jsonrpc-s module and jsonrpc_exec() function:

http://www.kamailio.org/docs/modules/stable/modules/jsonrpc-s.html#jsonrpc-s.f.jsonrpc_exec

Practically, you have to build the corresponding json document for the
command and give it as parameter.

Cheers,
Daniel

On 27/03/15 14:59, Grant Bagdasarian wrote:
> Thanks Alex, for the detailed explanation! :)
>
> -----Original Message-----
> From: sr-users [mailto:sr-users-bounces at lists.sip-router.org] On Behalf Of Alex Balashov
> Sent: Friday, March 27, 2015 2:50 PM
> To: sr-users at lists.sip-router.org
> Subject: Re: [SR-Users] Reload htable
>
> Grant,
>
> On 03/27/2015 09:44 AM, Grant Bagdasarian wrote:
>
>> I need to reload a htable from the database when a certain condition 
>> is met inside my kamailio script.
>>
>> I found the htable.reload htable RPC command, but is it possible to 
>> run this from within the script?
> This command is not exposed within the route script. This is a fairly common situation with modules; some "meta" functionality like this that is available externally (via MI, RPC, etc.) is not available within the route script.
>
> I think the best you can do is to set up an XHTTP_RPC interface:
>
> http://kamailio.org/docs/modules/4.2.x/modules/xhttp.html
> http://kamailio.org/docs/modules/4.2.x/modules/xhttp_rpc.html
>
> and then use utils:http_query() to send a request to the RPC server itself.
>
> That is probably the least blocking method involved. Another option is to use one of the exec* commands to call an external script that does this, of course:
>
> http://kamailio.org/docs/modules/4.2.x/modules/exec.html
>
> But in general, I think there should be a way to call MI/RPC commands from within route script generally. When there is not, we are always stuck in the predicament of needing to wrap up certain MI/RPC commands into module functions on demand. For example, I needed to examine the size of an 'mqueue' from within route script (this was only available as an MI/RPC command), so I committed this patch some time ago:
>
> http://kamailio.org/docs/modules/4.2.x/modules/mqueue.html#mqueue.f.mq_size
>
> This pattern will continue and add more bloat to modules, I expect. It would be sensible to try to genericise the functionality somehow, so that a wide category of informational and management commands can be transparently invoked both from route script and externally without having to do extra work.
>
> -- Alex
>
> --
> Alex Balashov | Principal | Evariste Systems LLC
> 303 Perimeter Center North, Suite 300
> Atlanta, GA 30346
> United States
>
> Tel: +1-800-250-5920 (toll-free) / +1-678-954-0671 (direct)
> Web: http://www.evaristesys.com/, http://www.csrpswitch.com/
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users at lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio World Conference, May 27-29, 2015
Berlin, Germany - http://www.kamailioworld.com




More information about the sr-users mailing list