| 1 |
RTimer Module |
| 2 |
|
| 3 |
Daniel-Constantin Mierla |
| 4 |
|
| 5 |
asipto.com |
| 6 |
<[email protected]> |
| 7 |
|
| 8 |
Edited by |
| 9 |
|
| 10 |
Daniel-Constantin Mierla |
| 11 |
|
| 12 |
<[email protected]> |
| 13 |
|
| 14 |
Copyright © 2009 http://www.asipto.com |
| 15 |
__________________________________________________________________ |
| 16 |
|
| 17 |
Table of Contents |
| 18 |
|
| 19 |
1. Admin Guide |
| 20 |
|
| 21 |
1. Overview |
| 22 |
2. Dependencies |
| 23 |
|
| 24 |
2.1. Kamailio Modules |
| 25 |
2.2. External Libraries or Applications |
| 26 |
|
| 27 |
3. Parameters |
| 28 |
|
| 29 |
3.1. default_interval (int) |
| 30 |
3.2. timer (str) |
| 31 |
3.3. exec (str) |
| 32 |
|
| 33 |
List of Examples |
| 34 |
|
| 35 |
1.1. Set default_interval parameter |
| 36 |
1.2. Set timer parameter |
| 37 |
1.3. Set exec parameter |
| 38 |
1.4. Use exec parameter with a Kemi engine |
| 39 |
|
| 40 |
Chapter 1. Admin Guide |
| 41 |
|
| 42 |
Table of Contents |
| 43 |
|
| 44 |
1. Overview |
| 45 |
2. Dependencies |
| 46 |
|
| 47 |
2.1. Kamailio Modules |
| 48 |
2.2. External Libraries or Applications |
| 49 |
|
| 50 |
3. Parameters |
| 51 |
|
| 52 |
3.1. default_interval (int) |
| 53 |
3.2. timer (str) |
| 54 |
3.3. exec (str) |
| 55 |
|
| 56 |
1. Overview |
| 57 |
|
| 58 |
The module executes route blocks on a timer base. It can create new |
| 59 |
timer processes and execute many route blocks on same timer. |
| 60 |
|
| 61 |
A static faked SIP message is given as parameter to called functions, |
| 62 |
so all functions available for REQUEST_ROUTE can be used. |
| 63 |
|
| 64 |
2. Dependencies |
| 65 |
|
| 66 |
2.1. Kamailio Modules |
| 67 |
2.2. External Libraries or Applications |
| 68 |
|
| 69 |
2.1. Kamailio Modules |
| 70 |
|
| 71 |
The following modules must be loaded before this module: |
| 72 |
* No dependencies on other Kamailio modules. |
| 73 |
|
| 74 |
2.2. External Libraries or Applications |
| 75 |
|
| 76 |
The following libraries or applications must be installed before |
| 77 |
running Kamailio with this module loaded: |
| 78 |
* None. |
| 79 |
|
| 80 |
3. Parameters |
| 81 |
|
| 82 |
3.1. default_interval (int) |
| 83 |
3.2. timer (str) |
| 84 |
3.3. exec (str) |
| 85 |
|
| 86 |
3.1. default_interval (int) |
| 87 |
|
| 88 |
The definition of the default interval of timers (if not present on the |
| 89 |
"timer" parameter) |
| 90 |
|
| 91 |
The parameter can be set multiple times to get different intervals in |
| 92 |
same configuration file. |
| 93 |
|
| 94 |
Example 1.1. Set default_interval parameter |
| 95 |
... |
| 96 |
# default time interval set to 300 seconds |
| 97 |
modparam("rtimer", "default_interval", 300) |
| 98 |
... |
| 99 |
|
| 100 |
3.2. timer (str) |
| 101 |
|
| 102 |
The definition of a timer. The value of the parameter must have the |
| 103 |
following format: |
| 104 |
* "name=_string_;mode=_number_;interval=_number_" |
| 105 |
|
| 106 |
The parameter can be set multiple times to get more timers in same |
| 107 |
configuration file. |
| 108 |
* name - name of the timer. |
| 109 |
* mode - if set to 0, the timer will use the main (shared) timer. Any |
| 110 |
number > 0 will create the specified amount of new timer processes |
| 111 |
(which will only be handling this timer). |
| 112 |
* interval - timer interval in seconds or micro-seconds (the value |
| 113 |
must be ended in 'u'). For micro-seconds intervals, mode is set |
| 114 |
always to 1. |
| 115 |
|
| 116 |
Default value is NULL. |
| 117 |
|
| 118 |
Example 1.2. Set timer parameter |
| 119 |
... |
| 120 |
# time interval set to 10 seconds |
| 121 |
modparam("rtimer", "timer", "name=ta;interval=10;mode=1;") |
| 122 |
# time interval set to 100 milliseconds |
| 123 |
modparam("rtimer", "timer", "name=ta;interval=100000u;mode=1;") |
| 124 |
... |
| 125 |
|
| 126 |
3.3. exec (str) |
| 127 |
|
| 128 |
Specify route to be executed on timer. The value of the parameter must |
| 129 |
have the following format: |
| 130 |
* "timer=_string_;route=_number_" |
| 131 |
|
| 132 |
The parameter can be set multiple times to get more routes executed on |
| 133 |
same timer. |
| 134 |
* timer - name of the timer. |
| 135 |
* route - the name of the route block to be executed, or the name of |
| 136 |
the function from kemi script. The kemi function receives a string |
| 137 |
parameter with the value being the name of the module. |
| 138 |
|
| 139 |
Default value is NULL. |
| 140 |
|
| 141 |
Example 1.3. Set exec parameter |
| 142 |
... |
| 143 |
modparam("rtimer", "timer", "name=ta;interval=10;mode=1;") |
| 144 |
modparam("rtimer", "exec", "timer=ta;route=ONTIMER") |
| 145 |
|
| 146 |
route[ONTIMER] { |
| 147 |
xlog("timer routine: time is $TF\n"); |
| 148 |
# delete from my sql cache table entries older than 2H |
| 149 |
sql_query("delete from kamailio_cache where last_updated<$TS-3600"); |
| 150 |
} |
| 151 |
... |
| 152 |
|
| 153 |
Example 1.4. Use exec parameter with a Kemi engine |
| 154 |
... |
| 155 |
modparam("rtimer", "timer", "name=ta;interval=10;mode=1;") |
| 156 |
modparam("rtimer", "exec", "timer=ta;route=ksr_rtimer") |
| 157 |
... |
| 158 |
-- rtimer event callback function implemented in Lua |
| 159 |
function ksr_rtimer(evname) |
| 160 |
KSR.info("===== rtimer module triggered event\n"); |
| 161 |
return 1; |
| 162 |
end |
| 163 |
... |