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/