Hello,
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? Is there perhaps another way to force reload the htable inside the script?
Thanks,
Grant
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
Thanks Alex, for the detailed explanation! :)
-----Original Message----- From: sr-users [mailto:sr-users-bounces@lists.sip-router.org] On Behalf Of Alex Balashov Sent: Friday, March 27, 2015 2:50 PM To: sr-users@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@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
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...
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@lists.sip-router.org] On Behalf Of Alex Balashov Sent: Friday, March 27, 2015 2:50 PM To: sr-users@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@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@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
On 03/27/2015 10:05 AM, Daniel-Constantin Mierla wrote:
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...
Practically, you have to build the corresponding json document for the command and give it as parameter.
Ha! Voila!
Terribly sorry that I missed this, Grant.
No problem Alex!
Thanks Daniel :). I'm glad I'm using 4.2.3 :D
-----Original Message----- From: sr-users [mailto:sr-users-bounces@lists.sip-router.org] On Behalf Of Alex Balashov Sent: Friday, March 27, 2015 3:08 PM To: sr-users@lists.sip-router.org Subject: Re: [SR-Users] Reload htable
On 03/27/2015 10:05 AM, Daniel-Constantin Mierla wrote:
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#jso nrpc-s.f.jsonrpc_exec
Practically, you have to build the corresponding json document for the command and give it as parameter.
Ha! Voila!
Terribly sorry that I missed this, Grant.
-- 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@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
On 27 Mar 2015, at 14:50, Alex Balashov abalashov@evaristesys.com wrote:
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.
http://kamailio.org/docs/modules/4.2.x/modules/jsonrpc-s.html#jsonrpc-s.f.js...
In 4.2 the jsonrpc-s module introduced a way to execute RPC commands from within the routing script. Awsome!
Example 1.3. jsonrpc_exec usage
... jsonrpc_exec({"jsonrpc": "2.0", "method": "dispatcher.reload", "id": 1}'); ...
/O