Discussion:
[SR-Users] Update Interval for Rtimer
AliReza Khoshgoftar Monfared
2014-07-11 20:53:22 UTC
Permalink
Hi,

I have a basic yet weird problem with Rtimer module.
I cannot make it execute a route block for me at an interval of my choice
(which is what it is supposed to do, right?)

Here is a simplified example with relevant parts of my config script:

Assume I want to print "hello" every 100 ms:

I have a script like this (I've put all my global variables, in case they
matter and my relevant route blocks...)

Is there anything I am doing wrong here in the usage of rtimer?



*####### Global Parameters #########*
*#!ifdef WITH_DEBUG*
*debug=4*
*log_stderror=yes*
*#!else*
*debug=-2*
*log_stderror=no*
*#!endif*
*memdbg=5*
*memlog=5*
*log_facility=LOG_LOCAL0*
*fork=yes*
*children=4*
*/* comment the next line to enable TCP */*
*disable_tcp=yes*
*/* uncomment the next line to disable the auto discovery of local aliases*
* based on revers DNS on IPs (default on) */*
*auto_aliases=no*
*/* add local domain aliases */*
*# alias="mysipserver.com <http://mysipserver.com>"*
*dns=no # (cmd. line: -r)*
*rev_dns=no # (cmd. line: -R)*
*port=5060*
*/* uncomment and configure the following line if you want Kamailio to *
* bind on a specific interface/port/proto (default bind on all
available) */*
*listen=eth0:5060*
*sip_warning=no*
*####### Modules Section ########*
*#set module path*
*#mpath="/usr/local/lib/kamailio/modules_k/:/usr/local/lib/kamailio/modules/"*
*loadpath "/usr/lib/x86_64-linux-gnu/kamailio/modules"*
*#loadmodule "db_mysql.so"*
*loadmodule "mi_fifo.so"*
*loadmodule "kex.so"*
*loadmodule "tm.so"*
*loadmodule "tmx.so"*
*loadmodule "sl.so"*
*loadmodule "rr.so"*
*loadmodule "pv.so"*
*loadmodule "maxfwd.so"*
*loadmodule "textops.so"*
*loadmodule "siputils.so"*
*loadmodule "xlog.so"*
*loadmodule "xprint.so"*
*loadmodule "sanity.so"*
*loadmodule "ctl.so"*
*loadmodule "mi_rpc.so"*
*loadmodule "acc.so"*
*loadmodule "dispatcher.so"*
*loadmodule "exec.so"*
*loadmodule "rtimer.so"*
*loadmodule "benchmark.so"*
*# ----------------- setting module-specific parameters ---------------*
*# ----- mi_fifo params -----*
*modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")*
*# ----- rr params -----*
*# add value to ;lr param to cope with most of the UAs*
*modparam("rr", "enable_full_lr", 1)*
*# do not append from tag to the RR (no need for this script)*
*modparam("rr", "append_fromtag", 0)*
*# ----- acc params -----*
*modparam("acc", "log_flag", 1)*
*modparam("acc", "failed_transaction_flag", 3)*
*modparam("acc", "log_extra", *
*
"src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd;src_ip=$si")*
*# ----- tm params -----*
*modparam("tm", "fr_timer", 2000)*
*modparam("tm", "fr_inv_timer", 40000)*
*# ----- dispatcher params -----*
*modparam("dispatcher", "list_file",
"/home/ubuntu/Downloads/dispatcher.list")*
*modparam("dispatcher", "flags", 2)*
*modparam("dispatcher", "dst_avp", "$avp(AVP_DST)")*
*modparam("dispatcher", "grp_avp", "$avp(AVP_GRP)")*
*modparam("dispatcher", "cnt_avp", "$avp(AVP_CNT)")*
*# ----- xlog params -----*
*modparam("xlog", "buf_size", 8192)*
*modparam("xlog", "log_facility", "LOG_LOCAL0")*
*# ----- rtimer params -----*
*modparam("rtimer", "timer", "name=ta;interval=1;mode=1;")*
*modparam("rtimer", "exec", "timer=ta;route=8")*
*####### Routing Logic ########*
*# main request routing logic*
*route {*
* ...*
* # calls various routing blocks, but no explicit call to route("8")*


*}*

*route[8] {*
* # to be executed on timer *
* xplog("L_ALERT","hello");*
*}*
Alex Balashov
2014-07-11 20:56:52 UTC
Permalink
Hello AliReza,
Post by AliReza Khoshgoftar Monfared
Hi,
I have a basic yet weird problem with Rtimer module.
I cannot make it execute a route block for me at an interval of my
choice (which is what it is supposed to do, right?)
I have a script like this (I've put all my global variables, in case
they matter and my relevant route blocks...)
Is there anything I am doing wrong here in the usage of rtimer?
Well, what's not working? Is it not printing anything at all? Or is it
printing at a different interval than you expect? If so, what is the
interval?

Note that you've specified an interval of 1s:

modparam("rtimer", "timer", "name=ta;interval=1;mode=1;")

By default, the interval value is in seconds. If you append a 'u', the
value is expressed in microseconds (millionths of a second), which gives
you sub-second timing granularity, per
http://kamailio.org/docs/modules/4.1.x/modules/rtimer.html#idp2566368.

This means that to have an interval of 100 ms, you'd define the timer
thusly:

modparam("rtimer", "timer", "name=ta;interval=100000u;mode=1;")

-- Alex
--
Alex Balashov - Principal
Evariste Systems LLC
Tel: +1-678-954-0670
Web: http://www.evaristesys.com/, http://www.alexbalashov.com/

Please be kind to the English language:

http://www.entrepreneur.com/article/232906
AliReza Khoshgoftar Monfared
2014-07-11 21:02:45 UTC
Permalink
Hi Alex,

It prints only one time. The log file looks like this:

Jul 11 20:43:58 ip-10-238-242-214 kamailio[20354]: ALERT: <script>: hello
I am sure that I run the script for many seconds, say 30 or so at least,
but I do not get more than one single log...
Post by Alex Balashov
Hello AliReza,
Hi,
Post by AliReza Khoshgoftar Monfared
I have a basic yet weird problem with Rtimer module.
I cannot make it execute a route block for me at an interval of my
choice (which is what it is supposed to do, right?)
I have a script like this (I've put all my global variables, in case
they matter and my relevant route blocks...)
Is there anything I am doing wrong here in the usage of rtimer?
Well, what's not working? Is it not printing anything at all? Or is it
printing at a different interval than you expect? If so, what is the
interval?
modparam("rtimer", "timer", "name=ta;interval=1;mode=1;")
By default, the interval value is in seconds. If you append a 'u', the
value is expressed in microseconds (millionths of a second), which gives
you sub-second timing granularity, per http://kamailio.org/docs/
modules/4.1.x/modules/rtimer.html#idp2566368.
This means that to have an interval of 100 ms, you'd define the timer
modparam("rtimer", "timer", "name=ta;interval=100000u;mode=1;")
-- Alex
--
Alex Balashov - Principal
Evariste Systems LLC
Tel: +1-678-954-0670
Web: http://www.evaristesys.com/, http://www.alexbalashov.com/
http://www.entrepreneur.com/article/232906
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Loading...