| 1 |
Acc Module |
| 2 |
|
| 3 |
Jiri Kuthan |
| 4 |
|
| 5 |
iptel.org |
| 6 |
<[email protected]> |
| 7 |
|
| 8 |
Bogdan-Andrei Iancu |
| 9 |
|
| 10 |
Voice Sistem SRL |
| 11 |
<[email protected]> |
| 12 |
|
| 13 |
Ramona-Elena Modroiu |
| 14 |
|
| 15 |
rosdev.ro |
| 16 |
<[email protected]> |
| 17 |
|
| 18 |
Edited by |
| 19 |
|
| 20 |
Bogdan-Andrei Iancu |
| 21 |
|
| 22 |
Voice Sistem SRL |
| 23 |
<[email protected]> |
| 24 |
|
| 25 |
Sven Knoblich |
| 26 |
|
| 27 |
1&1 Internet AG |
| 28 |
<[email protected]> |
| 29 |
|
| 30 |
Tyler Moore |
| 31 |
|
| 32 |
dOpenSource |
| 33 |
<[email protected]> |
| 34 |
|
| 35 |
Copyright © 2002, 2003 FhG FOKUS |
| 36 |
|
| 37 |
Copyright © 2004, 2006 Voice Sistem SRL |
| 38 |
|
| 39 |
Copyright © 2011 1&1 Internet AG |
| 40 |
|
| 41 |
Copyright © 2025 Tyler Moore, dOpenSource |
| 42 |
__________________________________________________________________ |
| 43 |
|
| 44 |
Table of Contents |
| 45 |
|
| 46 |
1. Admin Guide |
| 47 |
|
| 48 |
1. Overview |
| 49 |
|
| 50 |
1.1. General Example |
| 51 |
|
| 52 |
2. Extra accounting |
| 53 |
|
| 54 |
2.1. Overview |
| 55 |
2.2. Definitions and syntax |
| 56 |
2.3. How it works |
| 57 |
|
| 58 |
3. Multi Call-Legs accounting |
| 59 |
|
| 60 |
3.1. Overview |
| 61 |
3.2. Configuration |
| 62 |
3.3. Logged data |
| 63 |
|
| 64 |
4. Call Data Record generation |
| 65 |
|
| 66 |
4.1. Overview |
| 67 |
4.2. CDR Extra |
| 68 |
|
| 69 |
4.2.1. Definitions and syntax |
| 70 |
|
| 71 |
4.3. CDR with Multi Call-Legs |
| 72 |
|
| 73 |
4.3.1. Overview |
| 74 |
4.3.2. Configuration |
| 75 |
|
| 76 |
4.3.2.1. Example for a spiraled Proxy |
| 77 |
|
| 78 |
4.3.3. Logged data |
| 79 |
|
| 80 |
5. Dependencies |
| 81 |
|
| 82 |
5.1. Kamailio Modules |
| 83 |
5.2. External Libraries or Applications |
| 84 |
|
| 85 |
6. Parameters |
| 86 |
|
| 87 |
6.1. early_media (integer) |
| 88 |
6.2. failed_transaction_flag (integer) |
| 89 |
6.3. failed_filter (string) |
| 90 |
6.4. report_ack (integer) |
| 91 |
6.5. report_cancels (integer) |
| 92 |
6.6. detect_direction (integer) |
| 93 |
6.7. acc_prepare_flag (integer) |
| 94 |
6.8. acc_prepare_always (integer) |
| 95 |
6.9. acc_extra_nullable (integer) |
| 96 |
6.10. multi_leg_info (string) |
| 97 |
6.11. log_flag (integer) |
| 98 |
6.12. log_missed_flag (integer) |
| 99 |
6.13. log_level (integer) |
| 100 |
6.14. log_facility (string) |
| 101 |
6.15. log_extra (string) |
| 102 |
6.16. db_flag (integer) |
| 103 |
6.17. db_missed_flag (integer) |
| 104 |
6.18. db_table_acc (string) |
| 105 |
6.19. db_table_missed_calls (string) |
| 106 |
6.20. db_url (string) |
| 107 |
6.21. db_version_check (integer) |
| 108 |
6.22. acc_method_column (string) |
| 109 |
6.23. acc_from_tag_column (string) |
| 110 |
6.24. acc_to_tag_column (string) |
| 111 |
6.25. acc_callid_column (string) |
| 112 |
6.26. acc_sip_code_column (string) |
| 113 |
6.27. acc_sip_reason_column (string) |
| 114 |
6.28. acc_time_column (string) |
| 115 |
6.29. db_extra (string) |
| 116 |
6.30. db_insert_mode (integer) |
| 117 |
6.31. cdr_enable (integer) |
| 118 |
6.32. cdr_skip (string) |
| 119 |
6.33. cdr_expired_dlg_enable (integer) |
| 120 |
6.34. cdr_start_on_confirmed (integer) |
| 121 |
6.35. cdr_facility (integer) |
| 122 |
6.36. cdr_extra (string) |
| 123 |
6.37. cdr_extra_nullable (integer) |
| 124 |
6.38. cdr_start_id (string) |
| 125 |
6.39. cdr_end_id (string) |
| 126 |
6.40. cdr_duration_id (string) |
| 127 |
6.41. cdr_duration_mode (integer) |
| 128 |
6.42. cdr_log_enable (int) |
| 129 |
6.43. cdrs_table (str) |
| 130 |
6.44. time_mode (int) |
| 131 |
6.45. time_attr (str) |
| 132 |
6.46. time_exten (str) |
| 133 |
6.47. time_format (str) |
| 134 |
6.48. reason_from_hf (int) |
| 135 |
6.49. clone_msg (int) |
| 136 |
6.50. cdr_on_failed (int) |
| 137 |
6.51. acc_extra_size (int) |
| 138 |
6.52. cdr_extra_size (int) |
| 139 |
|
| 140 |
7. Functions |
| 141 |
|
| 142 |
7.1. acc_log_request(comment) |
| 143 |
7.2. acc_db_request(comment, table) |
| 144 |
7.3. acc_request(comment, table) |
| 145 |
|
| 146 |
2. Frequently Asked Questions |
| 147 |
|
| 148 |
List of Examples |
| 149 |
|
| 150 |
1.1. early_media example |
| 151 |
1.2. failed_transaction_flag example |
| 152 |
1.3. failed_filter example |
| 153 |
1.4. report_ack example |
| 154 |
1.5. report_cancels example |
| 155 |
1.6. detect_direction example |
| 156 |
1.7. acc_prepare_flag example |
| 157 |
1.8. acc_prepare_flag example |
| 158 |
1.9. acc_extra_nullable example |
| 159 |
1.10. multi_leg_info example |
| 160 |
1.11. log_flag example |
| 161 |
1.12. log_missed_flag example |
| 162 |
1.13. log_level example |
| 163 |
1.14. log_facility example |
| 164 |
1.15. log_extra example |
| 165 |
1.16. db_flag example |
| 166 |
1.17. db_missed_flag example |
| 167 |
1.18. db_table_acc example |
| 168 |
1.19. db_table_missed_calls example |
| 169 |
1.20. db_url example |
| 170 |
1.21. db_version_check example |
| 171 |
1.22. acc_method_column example |
| 172 |
1.23. acc_from_tag_column example |
| 173 |
1.24. acc_to_tag_column example |
| 174 |
1.25. acc_callid_column example |
| 175 |
1.26. acc_sip_code_column example |
| 176 |
1.27. acc_sip_reason_column example |
| 177 |
1.28. acc_time_column example |
| 178 |
1.29. db_extra example |
| 179 |
1.30. db_insert_mode example |
| 180 |
1.31. cdr_enable example |
| 181 |
1.32. cdr_skip example |
| 182 |
1.33. cdr_expired_dlg_enable example |
| 183 |
1.34. cdr_start_on_confirmed example |
| 184 |
1.35. cdr_facility example |
| 185 |
1.36. cdr_extra example |
| 186 |
1.37. cdr_extra_nullable example |
| 187 |
1.38. cdr_start_id example |
| 188 |
1.39. cdr_end_id example |
| 189 |
1.40. cdr_duration_id example |
| 190 |
1.41. cdr_duration_mode example |
| 191 |
1.42. cdr_log_enable example |
| 192 |
1.43. cdrs_table example |
| 193 |
1.44. time_mode example |
| 194 |
1.45. time_attr example |
| 195 |
1.46. time_exten example |
| 196 |
1.47. time_format example |
| 197 |
1.48. reason_from_hf |
| 198 |
1.49. clone_msg |
| 199 |
1.50. cdr_on_failed |
| 200 |
1.51. acc_extra_size |
| 201 |
1.52. cdr_extra_size |
| 202 |
1.53. acc_log_request usage |
| 203 |
1.54. acc_db_request usage |
| 204 |
1.55. acc_db_request usage |
| 205 |
|
| 206 |
Chapter 1. Admin Guide |
| 207 |
|
| 208 |
Table of Contents |
| 209 |
|
| 210 |
1. Overview |
| 211 |
|
| 212 |
1.1. General Example |
| 213 |
|
| 214 |
2. Extra accounting |
| 215 |
|
| 216 |
2.1. Overview |
| 217 |
2.2. Definitions and syntax |
| 218 |
2.3. How it works |
| 219 |
|
| 220 |
3. Multi Call-Legs accounting |
| 221 |
|
| 222 |
3.1. Overview |
| 223 |
3.2. Configuration |
| 224 |
3.3. Logged data |
| 225 |
|
| 226 |
4. Call Data Record generation |
| 227 |
|
| 228 |
4.1. Overview |
| 229 |
4.2. CDR Extra |
| 230 |
|
| 231 |
4.2.1. Definitions and syntax |
| 232 |
|
| 233 |
4.3. CDR with Multi Call-Legs |
| 234 |
|
| 235 |
4.3.1. Overview |
| 236 |
4.3.2. Configuration |
| 237 |
|
| 238 |
4.3.2.1. Example for a spiraled Proxy |
| 239 |
|
| 240 |
4.3.3. Logged data |
| 241 |
|
| 242 |
5. Dependencies |
| 243 |
|
| 244 |
5.1. Kamailio Modules |
| 245 |
5.2. External Libraries or Applications |
| 246 |
|
| 247 |
6. Parameters |
| 248 |
|
| 249 |
6.1. early_media (integer) |
| 250 |
6.2. failed_transaction_flag (integer) |
| 251 |
6.3. failed_filter (string) |
| 252 |
6.4. report_ack (integer) |
| 253 |
6.5. report_cancels (integer) |
| 254 |
6.6. detect_direction (integer) |
| 255 |
6.7. acc_prepare_flag (integer) |
| 256 |
6.8. acc_prepare_always (integer) |
| 257 |
6.9. acc_extra_nullable (integer) |
| 258 |
6.10. multi_leg_info (string) |
| 259 |
6.11. log_flag (integer) |
| 260 |
6.12. log_missed_flag (integer) |
| 261 |
6.13. log_level (integer) |
| 262 |
6.14. log_facility (string) |
| 263 |
6.15. log_extra (string) |
| 264 |
6.16. db_flag (integer) |
| 265 |
6.17. db_missed_flag (integer) |
| 266 |
6.18. db_table_acc (string) |
| 267 |
6.19. db_table_missed_calls (string) |
| 268 |
6.20. db_url (string) |
| 269 |
6.21. db_version_check (integer) |
| 270 |
6.22. acc_method_column (string) |
| 271 |
6.23. acc_from_tag_column (string) |
| 272 |
6.24. acc_to_tag_column (string) |
| 273 |
6.25. acc_callid_column (string) |
| 274 |
6.26. acc_sip_code_column (string) |
| 275 |
6.27. acc_sip_reason_column (string) |
| 276 |
6.28. acc_time_column (string) |
| 277 |
6.29. db_extra (string) |
| 278 |
6.30. db_insert_mode (integer) |
| 279 |
6.31. cdr_enable (integer) |
| 280 |
6.32. cdr_skip (string) |
| 281 |
6.33. cdr_expired_dlg_enable (integer) |
| 282 |
6.34. cdr_start_on_confirmed (integer) |
| 283 |
6.35. cdr_facility (integer) |
| 284 |
6.36. cdr_extra (string) |
| 285 |
6.37. cdr_extra_nullable (integer) |
| 286 |
6.38. cdr_start_id (string) |
| 287 |
6.39. cdr_end_id (string) |
| 288 |
6.40. cdr_duration_id (string) |
| 289 |
6.41. cdr_duration_mode (integer) |
| 290 |
6.42. cdr_log_enable (int) |
| 291 |
6.43. cdrs_table (str) |
| 292 |
6.44. time_mode (int) |
| 293 |
6.45. time_attr (str) |
| 294 |
6.46. time_exten (str) |
| 295 |
6.47. time_format (str) |
| 296 |
6.48. reason_from_hf (int) |
| 297 |
6.49. clone_msg (int) |
| 298 |
6.50. cdr_on_failed (int) |
| 299 |
6.51. acc_extra_size (int) |
| 300 |
6.52. cdr_extra_size (int) |
| 301 |
|
| 302 |
7. Functions |
| 303 |
|
| 304 |
7.1. acc_log_request(comment) |
| 305 |
7.2. acc_db_request(comment, table) |
| 306 |
7.3. acc_request(comment, table) |
| 307 |
|
| 308 |
1. Overview |
| 309 |
|
| 310 |
1.1. General Example |
| 311 |
|
| 312 |
ACC module is used to account transactions information to different |
| 313 |
backends like syslog and SQL. With the separate module “acc_radius” |
| 314 |
support for radius is enabled. |
| 315 |
|
| 316 |
There is some very early support of the Diameter protocol in the |
| 317 |
“acc_diameter” module, but is not up to date with the current Diameter |
| 318 |
protocols. If you need Diameter support, please use the ims_charging |
| 319 |
module. |
| 320 |
|
| 321 |
To account a transaction and to choose which set of backends to be |
| 322 |
used, the script writer just has to set some flags (see the module |
| 323 |
parameters section for flag definitions Section 6, “Parameters”). If |
| 324 |
the accounting flag for a specific backend is set, the acc module will |
| 325 |
then report on completed transaction. A typical usage of the module |
| 326 |
takes no acc-specific script command -- the functionality binds |
| 327 |
invisibly through transaction processing. Script writers just need to |
| 328 |
mark the transaction for accounting with proper setflag. Even so, the |
| 329 |
module allows the script writer to force accounting in special cases |
| 330 |
via some script functions. |
| 331 |
|
| 332 |
The accounting module will log by default a fixed set of attributes for |
| 333 |
the transaction - if you customize your accounting by adding more |
| 334 |
information to be logged, please see the next chapter about extra |
| 335 |
accounting - Section 2, “Extra accounting”. |
| 336 |
|
| 337 |
The fixed minimal accounting information is: |
| 338 |
* Request Method name |
| 339 |
* From header TAG parameter |
| 340 |
* To header TAG parameter |
| 341 |
* Call-Id |
| 342 |
* 3-digit Status code from final reply |
| 343 |
* Reason phrase from final reply |
| 344 |
* Time stamp when transaction was completed |
| 345 |
|
| 346 |
If a value is not present in request, the empty string is accounted |
| 347 |
instead. |
| 348 |
|
| 349 |
Note that: |
| 350 |
* A single INVITE may produce multiple accounting reports -- that's |
| 351 |
due to SIP forking feature. |
| 352 |
* All flags related to accounting need to be set in request |
| 353 |
processing route - only the "missed-call" flag may be toggled from |
| 354 |
other types of routes. |
| 355 |
* If a UA fails in middle of conversation, a proxy will never find |
| 356 |
out about it. In general, a better practice is to account from an |
| 357 |
end-device (such as PSTN gateway), which best knows about call |
| 358 |
status (including media status and PSTN status in case of the |
| 359 |
gateway). However, CDR-based logging has the option to log existing |
| 360 |
information from expired dialogs (the dlg_vars in cdr_extra) Please |
| 361 |
see cdr_expired_dlg_enable parameter - Section 6.33, |
| 362 |
“cdr_expired_dlg_enable (integer)”. |
| 363 |
|
| 364 |
The SQL backend support is compiled in the module. |
| 365 |
|
| 366 |
1.1. General Example |
| 367 |
|
| 368 |
loadmodule "modules/acc/acc.so" |
| 369 |
modparam("acc", "log_level", 1) |
| 370 |
modparam("acc", "log_flag", 1) |
| 371 |
|
| 372 |
if (uri=~"sip:+40") /* calls to Romania */ { |
| 373 |
if (!proxy_authorize("sip_domain.net" /* realm */, |
| 374 |
"subscriber" /* table name */)) { |
| 375 |
proxy_challenge("sip_domain.net" /* realm */, "0" /* no qop */ ); |
| 376 |
exit; |
| 377 |
} |
| 378 |
|
| 379 |
if (method=="INVITE" && !check_from()) { |
| 380 |
log("from!=digest\n"); |
| 381 |
sl_send_reply("403","Forbidden"); |
| 382 |
} |
| 383 |
|
| 384 |
setflag(1); /* set for accounting (the same value as in log_flag!) |
| 385 |
t_relay(); /* enter stateful mode now */ |
| 386 |
}; |
| 387 |
|
| 388 |
2. Extra accounting |
| 389 |
|
| 390 |
2.1. Overview |
| 391 |
2.2. Definitions and syntax |
| 392 |
2.3. How it works |
| 393 |
|
| 394 |
2.1. Overview |
| 395 |
|
| 396 |
Along the static default information, ACC modules allows dynamical |
| 397 |
selection of extra information to be logged. This allows you to log any |
| 398 |
pseudo-variable (AVPs, parts of the request, etc). |
| 399 |
|
| 400 |
2.2. Definitions and syntax |
| 401 |
|
| 402 |
Selection of extra information is done via xxx_extra parameters by |
| 403 |
specifying the names of additional information you want to log. This |
| 404 |
information is defined via pseudo-variables and may include headers, |
| 405 |
AVPs values or other message or system values. The syntax of the |
| 406 |
parameter is: |
| 407 |
* xxx_extra = extra_definition (';'extra_definition)* |
| 408 |
* extra_definition = log_name '=' pseudo_variable |
| 409 |
|
| 410 |
The full list of supported pseudo-variables in Kamailio is available |
| 411 |
at: https://www.kamailio.org/wikidocs/cookbooks/devel/pseudovariables |
| 412 |
|
| 413 |
Note: For all the ACK processed by tm, the registered callbacks (like |
| 414 |
acc module) will be called with the corresponding INVITE transaction |
| 415 |
contexts as long as this is still available. This means that the ACK |
| 416 |
callbacks will see the AVPs setup for the INVITE transaction and not |
| 417 |
the AVPs setup before t_relay(). |
| 418 |
|
| 419 |
Via log_name you define how/where the data will be logged. Its meaning |
| 420 |
depends of the accounting support which is used: |
| 421 |
* LOG accounting - log_name will be just printed along with the data |
| 422 |
in log_name=data format; |
| 423 |
* DB accounting - log_name will be the name of the DB column where |
| 424 |
the data will be stored.IMPORTANT: add in db acc table the columns |
| 425 |
corresponding to each extra data; |
| 426 |
* RADIUS accounting - log_name will be the AVP name used for packing |
| 427 |
the data into RADIUS message. The log_name will be translated to |
| 428 |
AVP number via the dictionary. IMPORTANT: add in RADIUS dictionary |
| 429 |
the log_name attribute. |
| 430 |
* DIAMETER accounting - log_name will be the AVP code used for |
| 431 |
packing the data into DIAMETER message. The AVP code is given |
| 432 |
directly as integer, since DIAMETER has no dictionary support yet. |
| 433 |
IMPORTANT: log_name must be a number. |
| 434 |
|
| 435 |
2.3. How it works |
| 436 |
|
| 437 |
Some pseudo variables may return more than one value (like headers or |
| 438 |
AVPs). In this case, the returned values are embedded in a single |
| 439 |
string in a comma-separated format. |
| 440 |
|
| 441 |
3. Multi Call-Legs accounting |
| 442 |
|
| 443 |
3.1. Overview |
| 444 |
3.2. Configuration |
| 445 |
3.3. Logged data |
| 446 |
|
| 447 |
3.1. Overview |
| 448 |
|
| 449 |
A SIP call can have multiple legs due forwarding actions. For example |
| 450 |
user A calls user B which forwards the call to user C. There is only |
| 451 |
one SIP call but with 2 legs (A to B and B to C). Accounting the legs |
| 452 |
of a call is required for proper billing of the calls (if C is a PSTN |
| 453 |
number and the call is billed, user B must pay for the call - as last |
| 454 |
party modifying the call destination-, and not A - as initiator of the |
| 455 |
call. Call forwarding on server is only one example which shows the |
| 456 |
necessity of having an accounting engine with multiple legs support. |
| 457 |
|
| 458 |
3.2. Configuration |
| 459 |
|
| 460 |
First how it works: The idea is to have a set of AVPs and for each call |
| 461 |
leg to store a set of values in the AVPs. The meaning of the AVP |
| 462 |
content is strictly decided by the script writer - it can be the origin |
| 463 |
and source of the leg, its status or any other related information. If |
| 464 |
you have a set of 4 AVPS (AVP1, AVP2, AVP3, AVP4), then for the "A call |
| 465 |
B and B forwards to C" example, you need to set a different set of |
| 466 |
values for the AVPs for each leg ([A,B] and [B,C]) . The script writer |
| 467 |
must take care and properly insert all these AVP from the script (in |
| 468 |
proper order and with the correct type). |
| 469 |
|
| 470 |
When the accounting information for the call will be written/sent, all |
| 471 |
the call-leg pairs will be added (based on the found AVP sets). |
| 472 |
|
| 473 |
By default, the multiple call-leg support is disabled - it can be |
| 474 |
enabled just by setting the per-leg set of AVPs via the multi_leg_info |
| 475 |
module parameter. |
| 476 |
|
| 477 |
3.3. Logged data |
| 478 |
|
| 479 |
For each call, all the values of the AVP set (which defines a call-leg) |
| 480 |
will be logged. How the information will be actually logged, depends of |
| 481 |
the data backend: |
| 482 |
* syslog -- all leg-sets will be added to one record string as |
| 483 |
AVP1=xxx, AVP2=xxxx ,... sets. |
| 484 |
* database -- each pair will be separately logged (due DB data |
| 485 |
structure constraints); several records will be written, the |
| 486 |
difference between them being only the fields corresponding to the |
| 487 |
call-leg info. |
| 488 |
|
| 489 |
Note |
| 490 |
You will need to add in your DB (all acc related tables) the |
| 491 |
columns for call-leg info (a column for each AVP of the set). |
| 492 |
* Radius -- all sets will be added to the same Radius accounting |
| 493 |
message as RADIUS AVPs - for each call-leg a set of RADIUS AVPs |
| 494 |
will be added (corresponding to the per-leg AVP set). Note that |
| 495 |
Radius support is in a separate module - acc_radius. |
| 496 |
|
| 497 |
Note |
| 498 |
You will need to add in your dictionary the RADIUS AVPs used in |
| 499 |
call-leg AVP set definition. |
| 500 |
|
| 501 |
4. Call Data Record generation |
| 502 |
|
| 503 |
4.1. Overview |
| 504 |
4.2. CDR Extra |
| 505 |
|
| 506 |
4.2.1. Definitions and syntax |
| 507 |
|
| 508 |
4.3. CDR with Multi Call-Legs |
| 509 |
|
| 510 |
4.3.1. Overview |
| 511 |
4.3.2. Configuration |
| 512 |
|
| 513 |
4.3.2.1. Example for a spiraled Proxy |
| 514 |
|
| 515 |
4.3.3. Logged data |
| 516 |
|
| 517 |
4.1. Overview |
| 518 |
|
| 519 |
In addition to transaction-based logging, it is possible to generate |
| 520 |
and log Call Data Records (CDRs) directly from Kamailio. Apart from a |
| 521 |
basic set of CDR fields which are always included (covering start time, |
| 522 |
end time, and duration), the approach allows flexible specification of |
| 523 |
additional fields that should be taken into account using the |
| 524 |
configuration script. This is very similar to how transaction-based |
| 525 |
logging may be customized with the exception that CDRs rely on dialogs |
| 526 |
instead of transactions to store relevant information during a call. |
| 527 |
|
| 528 |
In order to set up CDR generation, you must enable the CDR switch and |
| 529 |
load the dialog module. You probably also want to specify a set of |
| 530 |
pseudo-variables that define more relevant CDR fields. Pseudo-variables |
| 531 |
may be assigned arbitrarily during script execution, and the module |
| 532 |
will make sure that the variable content will be transformed into a CDR |
| 533 |
by the end of the dialog. |
| 534 |
|
| 535 |
To use CDR logging in a correct manner, you should only use the |
| 536 |
dialog-based pseudo-variables (dlg_var) from the dialog module. This |
| 537 |
allows you to save values right from the beginning through all requests |
| 538 |
and replies until termination of the call. While not recommended, it is |
| 539 |
still possible to use other pseudo-variables as well. Except for |
| 540 |
pseudo-variables valid in the call-final transaction, however, |
| 541 |
information given will not be stored in the CDR as they cannot be |
| 542 |
accessed by the end of the call when the CDR is logged. |
| 543 |
|
| 544 |
The dialog module needs to be engaged on the dialogs that should be |
| 545 |
accounted, that they will be tracked by the server. This is usally done |
| 546 |
by calling the function dlg_manage(). Refer to the documentation of the |
| 547 |
dialog module for more information. |
| 548 |
|
| 549 |
Sometimes, dialogs expire because the UA has a problem and a final |
| 550 |
message is never transmitted. You can toggle on/off the generation of |
| 551 |
CDR-based logging in such cases with only the dlg_vars showing by using |
| 552 |
the cdr_expired_dlg_enable parameter - Section 6.33, |
| 553 |
“cdr_expired_dlg_enable (integer)”. Default behavior is not logging. |
| 554 |
|
| 555 |
4.2. CDR Extra |
| 556 |
|
| 557 |
This section is similar to the “LOG accounting” part of Section 2, |
| 558 |
“Extra accounting”. |
| 559 |
|
| 560 |
4.2.1. Definitions and syntax |
| 561 |
|
| 562 |
Selection of extra information is done similar to the transaction extra |
| 563 |
Section 2.2, “Definitions and syntax”. |
| 564 |
* cdr_extra = cdr_extra_definition (';'cdr_extra_definition)* |
| 565 |
* cdr_extra_definition = cdr_log_name '=' pseudo_variable |
| 566 |
|
| 567 |
See also Section 6.36, “cdr_extra (string)”. |
| 568 |
|
| 569 |
The list with all pseudo-variables in Kamailio can be found at: |
| 570 |
https://www.kamailio.org/wikidocs/. |
| 571 |
|
| 572 |
4.3. CDR with Multi Call-Legs |
| 573 |
|
| 574 |
4.3.1. Overview |
| 575 |
|
| 576 |
As mentioned in Section 3, “Multi Call-Legs accounting”, a leg |
| 577 |
represents a parallel or forwarded call. In contrast to the normal |
| 578 |
accounting the cdr logging uses dialogs instead of transaction to log |
| 579 |
data. This may reduce the amount of information but it also make it |
| 580 |
possible to combine all important data in one cdr at once. A second |
| 581 |
mechanism to process multiple data-sets into one cdr is not further |
| 582 |
necessary. |
| 583 |
|
| 584 |
4.3.2. Configuration |
| 585 |
|
| 586 |
When you route messages multiple times through your proxy (e.g. to |
| 587 |
handle “call-forwardings”) you have to use detect_spirals from the |
| 588 |
dialog modules. Otherwise the proxy can't identify and reuse existing |
| 589 |
dialogs. |
| 590 |
|
| 591 |
To get the correct call-forwarding-chain you have to store each cf* |
| 592 |
with the corresponding caller and callee in a dialog based |
| 593 |
pseudo-variable (dlg_var) (e.g. chain=B;cfa;C|C;cfnr;D). Additionally |
| 594 |
it is necessary to store the caller and callee for each leg. All this |
| 595 |
helps to identify the involved phone partners and forwarding chain. |
| 596 |
When you route such calls multiple times to the same Proxy, you could |
| 597 |
store the caller and callee within a transaction based avp and write it |
| 598 |
into the dialog based dlg_var pv during a 200 INVITE. |
| 599 |
|
| 600 |
4.3.2.1. Example for a spiraled Proxy |
| 601 |
|
| 602 |
... |
| 603 |
# A calls B (transaction 1) |
| 604 |
$avp(caller)='A' |
| 605 |
$avp(callee)='B'; |
| 606 |
$dlg_var(chain)=''; |
| 607 |
|
| 608 |
# B cfa C (transaction 2) |
| 609 |
$avp(caller)='B' |
| 610 |
$avp(callee)='C'; |
| 611 |
$dlg_var(chain)='B;cfu;C'; |
| 612 |
|
| 613 |
# C cfnr D (transaction 3) |
| 614 |
$avp(caller)='C' |
| 615 |
$avp(callee)='D'; |
| 616 |
$dlg_var(chain)=$dlg_var(chain) + "|" + "C;cfnr;D"; |
| 617 |
|
| 618 |
# C confirms call (200 reply of transaction 2) |
| 619 |
$dlg_var(caller) = $avp(caller); #caller='B' |
| 620 |
$dlg_var(callee) = $avp(callee); #callee='C' |
| 621 |
... |
| 622 |
|
| 623 |
4.3.3. Logged data |
| 624 |
|
| 625 |
For each call, all dialog corresponding variables will be logged. After |
| 626 |
a call is finished, the generated call data record information will be |
| 627 |
logged as string (VAR1=xxx,VAR2=xxxx,...) to the syslog. |
| 628 |
|
| 629 |
5. Dependencies |
| 630 |
|
| 631 |
5.1. Kamailio Modules |
| 632 |
5.2. External Libraries or Applications |
| 633 |
|
| 634 |
5.1. Kamailio Modules |
| 635 |
|
| 636 |
The module depends on the following modules (in other words the listed |
| 637 |
modules must be loaded before this module): |
| 638 |
* tm -- Transaction Manager |
| 639 |
* a database module -- If SQL support is used. |
| 640 |
* rr -- Record Route, if “detect_direction” module parameter is |
| 641 |
enabled. |
| 642 |
* dialog -- Dialog, if “cdr_enable” module parameter is enabled. |
| 643 |
|
| 644 |
5.2. External Libraries or Applications |
| 645 |
|
| 646 |
The following libraries or applications must be installed before |
| 647 |
running Kamailio with this module loaded: |
| 648 |
* None |
| 649 |
|
| 650 |
6. Parameters |
| 651 |
|
| 652 |
6.1. early_media (integer) |
| 653 |
6.2. failed_transaction_flag (integer) |
| 654 |
6.3. failed_filter (string) |
| 655 |
6.4. report_ack (integer) |
| 656 |
6.5. report_cancels (integer) |
| 657 |
6.6. detect_direction (integer) |
| 658 |
6.7. acc_prepare_flag (integer) |
| 659 |
6.8. acc_prepare_always (integer) |
| 660 |
6.9. acc_extra_nullable (integer) |
| 661 |
6.10. multi_leg_info (string) |
| 662 |
6.11. log_flag (integer) |
| 663 |
6.12. log_missed_flag (integer) |
| 664 |
6.13. log_level (integer) |
| 665 |
6.14. log_facility (string) |
| 666 |
6.15. log_extra (string) |
| 667 |
6.16. db_flag (integer) |
| 668 |
6.17. db_missed_flag (integer) |
| 669 |
6.18. db_table_acc (string) |
| 670 |
6.19. db_table_missed_calls (string) |
| 671 |
6.20. db_url (string) |
| 672 |
6.21. db_version_check (integer) |
| 673 |
6.22. acc_method_column (string) |
| 674 |
6.23. acc_from_tag_column (string) |
| 675 |
6.24. acc_to_tag_column (string) |
| 676 |
6.25. acc_callid_column (string) |
| 677 |
6.26. acc_sip_code_column (string) |
| 678 |
6.27. acc_sip_reason_column (string) |
| 679 |
6.28. acc_time_column (string) |
| 680 |
6.29. db_extra (string) |
| 681 |
6.30. db_insert_mode (integer) |
| 682 |
6.31. cdr_enable (integer) |
| 683 |
6.32. cdr_skip (string) |
| 684 |
6.33. cdr_expired_dlg_enable (integer) |
| 685 |
6.34. cdr_start_on_confirmed (integer) |
| 686 |
6.35. cdr_facility (integer) |
| 687 |
6.36. cdr_extra (string) |
| 688 |
6.37. cdr_extra_nullable (integer) |
| 689 |
6.38. cdr_start_id (string) |
| 690 |
6.39. cdr_end_id (string) |
| 691 |
6.40. cdr_duration_id (string) |
| 692 |
6.41. cdr_duration_mode (integer) |
| 693 |
6.42. cdr_log_enable (int) |
| 694 |
6.43. cdrs_table (str) |
| 695 |
6.44. time_mode (int) |
| 696 |
6.45. time_attr (str) |
| 697 |
6.46. time_exten (str) |
| 698 |
6.47. time_format (str) |
| 699 |
6.48. reason_from_hf (int) |
| 700 |
6.49. clone_msg (int) |
| 701 |
6.50. cdr_on_failed (int) |
| 702 |
6.51. acc_extra_size (int) |
| 703 |
6.52. cdr_extra_size (int) |
| 704 |
|
| 705 |
6.1. early_media (integer) |
| 706 |
|
| 707 |
Should be early media (any provisional reply with body) accounted too ? |
| 708 |
|
| 709 |
Default value is 0 (no). |
| 710 |
|
| 711 |
Example 1.1. early_media example |
| 712 |
... |
| 713 |
modparam("acc", "early_media", 1) |
| 714 |
... |
| 715 |
|
| 716 |
6.2. failed_transaction_flag (integer) |
| 717 |
|
| 718 |
Per transaction flag which says if the transaction should be accounted |
| 719 |
also in case of failure (SIP status code >= 300). This flag triggers |
| 720 |
accounting when the whole transaction fails (on the server side). |
| 721 |
|
| 722 |
Default value is not-set (no flag). |
| 723 |
|
| 724 |
Example 1.2. failed_transaction_flag example |
| 725 |
... |
| 726 |
modparam("acc", "failed_transaction_flag", 4) |
| 727 |
... |
| 728 |
|
| 729 |
6.3. failed_filter (string) |
| 730 |
|
| 731 |
A string of failure response codes from 300 to 999 separated by commas. |
| 732 |
Failed transaction will not be accounted if its response code is in the |
| 733 |
list even when failed_transaction_flag is set. |
| 734 |
|
| 735 |
Default value is not-set (failure filtering is off). |
| 736 |
|
| 737 |
Example 1.3. failed_filter example |
| 738 |
... |
| 739 |
modparam("acc", "failed_filter", "404,407") |
| 740 |
... |
| 741 |
|
| 742 |
6.4. report_ack (integer) |
| 743 |
|
| 744 |
Shall acc attempt to account e2e ACKs too ? Note that this is really |
| 745 |
only an attempt, as e2e ACKs may take a different path (unless RR |
| 746 |
enabled) and mismatch original INVITE (e2e ACKs are a separate |
| 747 |
transaction). The flag for accounting has to be set for each ACK as |
| 748 |
well. |
| 749 |
|
| 750 |
Default value is 0 (no). |
| 751 |
|
| 752 |
Example 1.4. report_ack example |
| 753 |
... |
| 754 |
modparam("acc", "report_ack", 1) |
| 755 |
... |
| 756 |
|
| 757 |
6.5. report_cancels (integer) |
| 758 |
|
| 759 |
By default, CANCEL reporting is disabled -- most accounting |
| 760 |
applications wants to see INVITE's cancellation status. Turn on if you |
| 761 |
explicitly want to account CANCEL transactions. |
| 762 |
|
| 763 |
Default value is 0 (no). |
| 764 |
|
| 765 |
Example 1.5. report_cancels example |
| 766 |
... |
| 767 |
modparam("acc", "report_cancels", 1) |
| 768 |
... |
| 769 |
|
| 770 |
6.6. detect_direction (integer) |
| 771 |
|
| 772 |
Controls the direction detection for sequential requests. If enabled |
| 773 |
(non zero value), for sequential requests with upstream direction (from |
| 774 |
callee to caller), the FROM and TO will be swapped (the direction will |
| 775 |
be preserved as in the original request). |
| 776 |
|
| 777 |
It affects all values related to TO and FROM headers (body, URI, |
| 778 |
username, domain, TAG). |
| 779 |
|
| 780 |
Default value is 0 (disabled). |
| 781 |
|
| 782 |
Example 1.6. detect_direction example |
| 783 |
... |
| 784 |
modparam("acc", "detect_direction", 1) |
| 785 |
... |
| 786 |
|
| 787 |
6.7. acc_prepare_flag (integer) |
| 788 |
|
| 789 |
Per transaction flag which says if the transaction may be accounted |
| 790 |
later, with flags set in TM module specific routes (e.g., like |
| 791 |
failure_route). If this flag is not set and acc or missed_call flag are |
| 792 |
not set either in request route block, there is no way to mark the |
| 793 |
request for transaction later unless you set acc_prepare_always. If |
| 794 |
either acc or missed_call flags are set in request route block, there |
| 795 |
is no need to set this flag. |
| 796 |
|
| 797 |
Default value is not-set (no flag). |
| 798 |
|
| 799 |
Example 1.7. acc_prepare_flag example |
| 800 |
... |
| 801 |
modparam("acc", "acc_prepare_flag", 5) |
| 802 |
... |
| 803 |
|
| 804 |
6.8. acc_prepare_always (integer) |
| 805 |
|
| 806 |
Prepare all request even if acc_prepare_flag is not set to mark the |
| 807 |
request for transaction later. |
| 808 |
|
| 809 |
Default value is not-set (previous behaviour). |
| 810 |
|
| 811 |
Example 1.8. acc_prepare_flag example |
| 812 |
... |
| 813 |
modparam("acc", "acc_prepare_always", 1) |
| 814 |
... |
| 815 |
|
| 816 |
6.9. acc_extra_nullable (integer) |
| 817 |
|
| 818 |
If set to 1, the database acc extra fields are set to NULL if the |
| 819 |
corresponding script variable is not defined or has $null value. If set |
| 820 |
to 0, the value is saved as empty string (the existing behavior). |
| 821 |
|
| 822 |
Database columns may need to be altered to DROP NOT NULL constraints |
| 823 |
and DROP DEFAULT values in order to accept NULL values. |
| 824 |
|
| 825 |
Default value is 0. |
| 826 |
|
| 827 |
Example 1.9. acc_extra_nullable example |
| 828 |
... |
| 829 |
modparam("acc", "acc_extra_nullable", 1) |
| 830 |
... |
| 831 |
|
| 832 |
6.10. multi_leg_info (string) |
| 833 |
|
| 834 |
Defines the AVP set to be used in per-call-leg accounting. See |
| 835 |
Section 3, “Multi Call-Legs accounting” for a detailed description of |
| 836 |
the Multi Call-Legs accounting. |
| 837 |
|
| 838 |
If empty, the multi-leg accounting support will be disabled. |
| 839 |
|
| 840 |
Default value is 0 (disabled). |
| 841 |
|
| 842 |
Example 1.10. multi_leg_info example |
| 843 |
... |
| 844 |
# for syslog-based accounting, use any text you want to be printed |
| 845 |
modparam("acc", "multi_leg_info", |
| 846 |
"text1=$avp(src);text2=$avp(dst)") |
| 847 |
# for mysql-based accounting, use the names of the columns |
| 848 |
modparam("acc", "multi_leg_info", |
| 849 |
"leg_src=$avp(src);leg_dst=$avp(dst)") |
| 850 |
# for DIAMETER-based accounting, use the DIAMETER AVP ID (as integer) |
| 851 |
modparam("acc", "multi_leg_info", |
| 852 |
"2345=$avp(src);2346=$avp(dst)") |
| 853 |
... |
| 854 |
|
| 855 |
6.11. log_flag (integer) |
| 856 |
|
| 857 |
Request flag which needs to be set to account a transaction via syslog. |
| 858 |
|
| 859 |
Default value is not-set (no flag). |
| 860 |
|
| 861 |
Example 1.11. log_flag example |
| 862 |
... |
| 863 |
modparam("acc", "log_flag", 2) |
| 864 |
... |
| 865 |
|
| 866 |
6.12. log_missed_flag (integer) |
| 867 |
|
| 868 |
Request flag which needs to be set to account missed calls via syslog. |
| 869 |
This can be used to e.g. account failures during the call setup phase |
| 870 |
from the callee (client) side, for example if you do forking to several |
| 871 |
destinations. |
| 872 |
|
| 873 |
Keep in mind that this flag is reset after branch completion. Therefore |
| 874 |
it is necessary to set it again e.g. in a failure_route if you do |
| 875 |
serial forking and want to log all attempts. |
| 876 |
|
| 877 |
Default value is not-set (no flag). |
| 878 |
|
| 879 |
Example 1.12. log_missed_flag example |
| 880 |
... |
| 881 |
modparam("acc", "log_missed_flag", 3) |
| 882 |
... |
| 883 |
|
| 884 |
6.13. log_level (integer) |
| 885 |
|
| 886 |
Log level at which accounting messages are issued to syslog. |
| 887 |
|
| 888 |
Default value is 1 (L_NOTICE). |
| 889 |
|
| 890 |
Example 1.13. log_level example |
| 891 |
... |
| 892 |
modparam("acc", "log_level", 2) # Set log_level to 2 (L_INFO) |
| 893 |
... |
| 894 |
|
| 895 |
6.14. log_facility (string) |
| 896 |
|
| 897 |
Log facility to which accounting messages are issued to syslog. This |
| 898 |
allows to easily separate the accounting specific logging from the |
| 899 |
other log messages. |
| 900 |
|
| 901 |
Default value is LOG_DAEMON. |
| 902 |
|
| 903 |
Example 1.14. log_facility example |
| 904 |
... |
| 905 |
modparam("acc", "log_facility", "LOG_DAEMON") |
| 906 |
... |
| 907 |
|
| 908 |
6.15. log_extra (string) |
| 909 |
|
| 910 |
Extra values to be logged. See section Section 2, “Extra accounting” |
| 911 |
for more details. |
| 912 |
|
| 913 |
Default value is NULL. |
| 914 |
|
| 915 |
Example 1.15. log_extra example |
| 916 |
... |
| 917 |
modparam("acc", "log_extra", "ua=$hdr(User-Agent);uuid=$avp(i:123)") |
| 918 |
... |
| 919 |
|
| 920 |
6.16. db_flag (integer) |
| 921 |
|
| 922 |
Request flag which needs to be set to account a transaction -- database |
| 923 |
specific. |
| 924 |
|
| 925 |
Default value is not-set (no flag). |
| 926 |
|
| 927 |
Example 1.16. db_flag example |
| 928 |
... |
| 929 |
modparam("acc", "db_flag", 2) |
| 930 |
... |
| 931 |
|
| 932 |
6.17. db_missed_flag (integer) |
| 933 |
|
| 934 |
Request flag which needs to be set to account missed calls via |
| 935 |
database. This can be used to e.g. account failures during the call |
| 936 |
setup phase from the callee (client) side, for example if you do |
| 937 |
forking to several destinations. |
| 938 |
|
| 939 |
Keep in mind that this flag is reset after branch completion. Therefore |
| 940 |
it is necessary to set it again e.g. in a failure_route if you do |
| 941 |
serial forking and want to log all attempts. |
| 942 |
|
| 943 |
Default value is not-set (no flag). |
| 944 |
|
| 945 |
Example 1.17. db_missed_flag example |
| 946 |
... |
| 947 |
modparam("acc", "db_missed_flag", 3) |
| 948 |
... |
| 949 |
|
| 950 |
6.18. db_table_acc (string) |
| 951 |
|
| 952 |
Table name of accounting successful calls -- database specific. It can |
| 953 |
contain config variables that will be evaluated at runtime. |
| 954 |
|
| 955 |
Default value is “acc” |
| 956 |
|
| 957 |
Example 1.18. db_table_acc example |
| 958 |
... |
| 959 |
modparam("acc", "db_table_acc", "myacc_table") |
| 960 |
modparam("acc", "db_table_acc", "acc_$time(year)_$time(mon)") |
| 961 |
... |
| 962 |
|
| 963 |
6.19. db_table_missed_calls (string) |
| 964 |
|
| 965 |
Table name for accounting missed calls -- database specific. It can |
| 966 |
contain config variables that will be evaluated at runtime. |
| 967 |
|
| 968 |
Default value is “missed_calls” |
| 969 |
|
| 970 |
Example 1.19. db_table_missed_calls example |
| 971 |
... |
| 972 |
modparam("acc", "db_table_missed_calls", "myMC_table") |
| 973 |
... |
| 974 |
|
| 975 |
6.20. db_url (string) |
| 976 |
|
| 977 |
SQL address -- database specific. If it is set to NULL or empty string, |
| 978 |
the SQL support is disabled. |
| 979 |
|
| 980 |
Default value is “NULL” (SQL disabled). |
| 981 |
|
| 982 |
Example 1.20. db_url example |
| 983 |
... |
| 984 |
modparam("acc", "db_url", "mysql://user:password@localhost/kamailio") |
| 985 |
... |
| 986 |
|
| 987 |
6.21. db_version_check (integer) |
| 988 |
|
| 989 |
Whether to validate database schema versions when the module |
| 990 |
initializes or not. |
| 991 |
|
| 992 |
Default value is 1 (perform version checks). |
| 993 |
|
| 994 |
Example 1.21. db_version_check example |
| 995 |
... |
| 996 |
modparam("acc", "db_version_check", 0) |
| 997 |
... |
| 998 |
|
| 999 |
6.22. acc_method_column (string) |
| 1000 |
|
| 1001 |
Column name in accounting table to store the request's method name as |
| 1002 |
string. |
| 1003 |
|
| 1004 |
Default value is “method”. |
| 1005 |
|
| 1006 |
Example 1.22. acc_method_column example |
| 1007 |
... |
| 1008 |
modparam("acc", "acc_method_column", "method") |
| 1009 |
... |
| 1010 |
|
| 1011 |
6.23. acc_from_tag_column (string) |
| 1012 |
|
| 1013 |
Column name in accounting table to store the From header TAG parameter. |
| 1014 |
|
| 1015 |
Default value is “from_tag”. |
| 1016 |
|
| 1017 |
Example 1.23. acc_from_tag_column example |
| 1018 |
... |
| 1019 |
modparam("acc", "acc_from_tag_column", "from_tag") |
| 1020 |
... |
| 1021 |
|
| 1022 |
6.24. acc_to_tag_column (string) |
| 1023 |
|
| 1024 |
Column name in accounting table to store the To header TAG parameter. |
| 1025 |
|
| 1026 |
Default value is “to_tag”. |
| 1027 |
|
| 1028 |
Example 1.24. acc_to_tag_column example |
| 1029 |
... |
| 1030 |
modparam("acc", "acc_to_tag_column", "to_tag") |
| 1031 |
... |
| 1032 |
|
| 1033 |
6.25. acc_callid_column (string) |
| 1034 |
|
| 1035 |
Column name in accounting table to store the request's Callid value. |
| 1036 |
|
| 1037 |
Default value is “callid”. |
| 1038 |
|
| 1039 |
Example 1.25. acc_callid_column example |
| 1040 |
... |
| 1041 |
modparam("acc", "acc_callid_column", "callid") |
| 1042 |
... |
| 1043 |
|
| 1044 |
6.26. acc_sip_code_column (string) |
| 1045 |
|
| 1046 |
Column name in accounting table to store the final reply's numeric code |
| 1047 |
value in string format. |
| 1048 |
|
| 1049 |
Default value is “sip_code”. |
| 1050 |
|
| 1051 |
Example 1.26. acc_sip_code_column example |
| 1052 |
... |
| 1053 |
modparam("acc", "acc_sip_code_column", "sip_code") |
| 1054 |
... |
| 1055 |
|
| 1056 |
6.27. acc_sip_reason_column (string) |
| 1057 |
|
| 1058 |
Column name in accounting table to store the final reply's reason |
| 1059 |
phrase value. |
| 1060 |
|
| 1061 |
Default value is “sip_reason”. |
| 1062 |
|
| 1063 |
Example 1.27. acc_sip_reason_column example |
| 1064 |
... |
| 1065 |
modparam("acc", "acc_sip_reason_column", "sip_reason") |
| 1066 |
... |
| 1067 |
|
| 1068 |
6.28. acc_time_column (string) |
| 1069 |
|
| 1070 |
Column name in accounting table to store the time stamp of the |
| 1071 |
transaction completion in date-time format. |
| 1072 |
|
| 1073 |
Default value is “time”. |
| 1074 |
|
| 1075 |
Example 1.28. acc_time_column example |
| 1076 |
... |
| 1077 |
modparam("acc", "acc_time_column", "time") |
| 1078 |
... |
| 1079 |
|
| 1080 |
6.29. db_extra (string) |
| 1081 |
|
| 1082 |
Extra values to be logged into database - DB specific. See section |
| 1083 |
Section 2, “Extra accounting” for more details. |
| 1084 |
|
| 1085 |
Default value is NULL. |
| 1086 |
|
| 1087 |
Example 1.29. db_extra example |
| 1088 |
... |
| 1089 |
modparam("acc", "db_extra", "ct=$hdr(Content-type); email=$avp(s:email)") |
| 1090 |
... |
| 1091 |
|
| 1092 |
6.30. db_insert_mode (integer) |
| 1093 |
|
| 1094 |
If set to 1, use INSERT DELAYED to add records to accounting tables |
| 1095 |
when the DB driver has support for it. If no INSERT DELAYED support is |
| 1096 |
offered by DB driver, then standard INSERT is used. Beware that MySQL |
| 1097 |
InnoDB engine doesn't support INSERT DELAYED, thus be sure the acc |
| 1098 |
tables are defined with different type (e.g., MyISAM). |
| 1099 |
|
| 1100 |
If set to 2, async insert is used if the db driver module has support |
| 1101 |
for it and if async_workers core parameter value is greater than 0. If |
| 1102 |
not, then standard INSERT is used. |
| 1103 |
|
| 1104 |
Default value is 0 (no INSERT DELAYED nor async insert). |
| 1105 |
|
| 1106 |
Example 1.30. db_insert_mode example |
| 1107 |
... |
| 1108 |
modparam("acc", "db_insert_mode", 1) |
| 1109 |
... |
| 1110 |
|
| 1111 |
6.31. cdr_enable (integer) |
| 1112 |
|
| 1113 |
Enable CDR reporting - one record per call reported to "acc_cdrs" |
| 1114 |
table, relying on dialog module. |
| 1115 |
|
| 1116 |
The value can be: |
| 1117 |
* 0 - off (default). |
| 1118 |
* 1 - on. |
| 1119 |
|
| 1120 |
Example 1.31. cdr_enable example |
| 1121 |
... |
| 1122 |
modparam("acc", "cdr_enable", 1) |
| 1123 |
... |
| 1124 |
|
| 1125 |
6.32. cdr_skip (string) |
| 1126 |
|
| 1127 |
Skip cdr generation for dialogs with this dlg_var set. |
| 1128 |
|
| 1129 |
Default value is NULL. |
| 1130 |
|
| 1131 |
Example 1.32. cdr_skip example |
| 1132 |
... |
| 1133 |
modparam("acc", "cdr_skip", "nocdr") |
| 1134 |
... |
| 1135 |
|
| 1136 |
6.33. cdr_expired_dlg_enable (integer) |
| 1137 |
|
| 1138 |
Should CDR-based logging be enabled in case of expired dialogs? |
| 1139 |
* 0 - off (default). |
| 1140 |
* 1 - on. |
| 1141 |
|
| 1142 |
Example 1.33. cdr_expired_dlg_enable example |
| 1143 |
... |
| 1144 |
modparam("acc", "cdr_expired_dlg_enable", 1) |
| 1145 |
... |
| 1146 |
|
| 1147 |
6.34. cdr_start_on_confirmed (integer) |
| 1148 |
|
| 1149 |
Should the start time be taken from the time when the dialog is |
| 1150 |
created, or when the dialog is confirmed? |
| 1151 |
* 0 - use time of dialog creation (default). |
| 1152 |
* 1 - use time of dialog confirmation. |
| 1153 |
|
| 1154 |
Example 1.34. cdr_start_on_confirmed example |
| 1155 |
... |
| 1156 |
modparam("acc", "cdr_start_on_confirmed", 1) |
| 1157 |
... |
| 1158 |
|
| 1159 |
6.35. cdr_facility (integer) |
| 1160 |
|
| 1161 |
Log facility to which CDR messages are issued to syslog. This allows to |
| 1162 |
easily separate CDR-specific logging from the other log messages. |
| 1163 |
|
| 1164 |
Default value is LOG_DAEMON. |
| 1165 |
|
| 1166 |
Example 1.35. cdr_facility example |
| 1167 |
... |
| 1168 |
modparam("acc", "cdr_facility", "LOG_DAEMON") |
| 1169 |
... |
| 1170 |
|
| 1171 |
6.36. cdr_extra (string) |
| 1172 |
|
| 1173 |
Set of pseudo-variables defining custom CDR fields. See Section 4.2, |
| 1174 |
“CDR Extra” for more details. |
| 1175 |
|
| 1176 |
Default value is NULL. |
| 1177 |
|
| 1178 |
Example 1.36. cdr_extra example |
| 1179 |
... |
| 1180 |
modparam("acc", "cdr_extra", "c1=$dlg_var(caller);c2=$dlg_var(callee)") |
| 1181 |
... |
| 1182 |
|
| 1183 |
6.37. cdr_extra_nullable (integer) |
| 1184 |
|
| 1185 |
Should custom CDR fields be saved as NULL? |
| 1186 |
|
| 1187 |
If set to 0, custom CDR fields not defined in config operation (or set |
| 1188 |
to $null) will be saved as empty string. If set to 1, custom CDR fields |
| 1189 |
not defined in config operation (or set to $null) will be saved as |
| 1190 |
NULL. |
| 1191 |
|
| 1192 |
Database columns may need to be altered to DROP NOT NULL constraints |
| 1193 |
and DROP DEFAULT values in order to accept NULL values. |
| 1194 |
|
| 1195 |
Default value is 0. |
| 1196 |
|
| 1197 |
Example 1.37. cdr_extra_nullable example |
| 1198 |
... |
| 1199 |
modparam("acc", "cdr_extra_nullable", 1) |
| 1200 |
... |
| 1201 |
|
| 1202 |
6.38. cdr_start_id (string) |
| 1203 |
|
| 1204 |
Modifying the id which is used to store the start time. |
| 1205 |
|
| 1206 |
Default value is 'start_time' |
| 1207 |
|
| 1208 |
Example 1.38. cdr_start_id example |
| 1209 |
... |
| 1210 |
modparam("acc", "cdr_start_id", "start") |
| 1211 |
... |
| 1212 |
|
| 1213 |
6.39. cdr_end_id (string) |
| 1214 |
|
| 1215 |
Modifying the id which is used to store the end time. |
| 1216 |
|
| 1217 |
Default value is 'end_time' |
| 1218 |
|
| 1219 |
Example 1.39. cdr_end_id example |
| 1220 |
... |
| 1221 |
modparam("acc", "cdr_end_id", "end") |
| 1222 |
... |
| 1223 |
|
| 1224 |
6.40. cdr_duration_id (string) |
| 1225 |
|
| 1226 |
Modify the id which is used to store the duration. |
| 1227 |
|
| 1228 |
Default value is 'duration' |
| 1229 |
|
| 1230 |
Example 1.40. cdr_duration_id example |
| 1231 |
... |
| 1232 |
modparam("acc", "cdr_duration_id", "d") |
| 1233 |
... |
| 1234 |
|
| 1235 |
6.41. cdr_duration_mode (integer) |
| 1236 |
|
| 1237 |
Modify the precision of the duration stored for the call. |
| 1238 |
|
| 1239 |
Values can be: |
| 1240 |
* 0 - save the cdr duration as seconds. |
| 1241 |
* 1 - (default), save the cdr duration as seconds.milliseconds. |
| 1242 |
* 2 - save the cdr duration as seconds.microseconds. |
| 1243 |
|
| 1244 |
Example 1.41. cdr_duration_mode example |
| 1245 |
... |
| 1246 |
modparam("acc", "cdr_duration_mode", 2) |
| 1247 |
... |
| 1248 |
|
| 1249 |
6.42. cdr_log_enable (int) |
| 1250 |
|
| 1251 |
Control if CDR-based accounting should be written to syslog. |
| 1252 |
|
| 1253 |
0 - off. 1 - on (default). |
| 1254 |
|
| 1255 |
Example 1.42. cdr_log_enable example |
| 1256 |
... |
| 1257 |
modparam("acc", "cdr_log_enable", 0) |
| 1258 |
... |
| 1259 |
|
| 1260 |
6.43. cdrs_table (str) |
| 1261 |
|
| 1262 |
Name of db table to store dialog-based CDRs. |
| 1263 |
|
| 1264 |
Default value is "" (no db storage for dialog-based CDRs). |
| 1265 |
|
| 1266 |
Example 1.43. cdrs_table example |
| 1267 |
... |
| 1268 |
modparam("acc", "cdrs_table", "acc_cdrs") |
| 1269 |
... |
| 1270 |
|
| 1271 |
6.44. time_mode (int) |
| 1272 |
|
| 1273 |
Store additional value related to the time of event. |
| 1274 |
|
| 1275 |
Values can be: |
| 1276 |
* 0 - (default), save only unix timestamp for syslog and datetime for |
| 1277 |
database. |
| 1278 |
* 1 - save seconds in time_attr and microseconds in time_exten. |
| 1279 |
* 2 - save seconds.milliseconds in time_attr. |
| 1280 |
* 3 - save formatted time according to time_format parameter, using |
| 1281 |
the output of localtime(). Used for cdr entries too. |
| 1282 |
* 4 - save formatted time according to time_format parameter, using |
| 1283 |
the output of gmtime(). Used for cdr entries too. |
| 1284 |
|
| 1285 |
Example 1.44. time_mode example |
| 1286 |
... |
| 1287 |
modparam("acc", "time_mode", 1) |
| 1288 |
... |
| 1289 |
|
| 1290 |
6.45. time_attr (str) |
| 1291 |
|
| 1292 |
Name of the syslog attribute or database column where to store |
| 1293 |
additional value related to the time of event. |
| 1294 |
|
| 1295 |
For db accounting, the column has to be of different types, depending |
| 1296 |
on time_mode value. When time_mode is: |
| 1297 |
* 1 - time_attr column has to be int. |
| 1298 |
* 2 - time_attr column has to be double. |
| 1299 |
* 3 - time_attr column has to be varchar(128). |
| 1300 |
* 4 - time_attr column has to be varchar(128). |
| 1301 |
|
| 1302 |
For time_mode=1, this attribute is not written in syslog, because time |
| 1303 |
value is already unix timestamp, but in db accounting time value is |
| 1304 |
datetime and requires a function to get the timestamp. |
| 1305 |
|
| 1306 |
Example 1.45. time_attr example |
| 1307 |
... |
| 1308 |
modparam("acc", "time_attr", "seconds") |
| 1309 |
... |
| 1310 |
|
| 1311 |
6.46. time_exten (str) |
| 1312 |
|
| 1313 |
Name of the syslog attribute or database column where to store extended |
| 1314 |
value related to the time of event. |
| 1315 |
|
| 1316 |
It is used now only for time_mode=1 and database column has to be int: |
| 1317 |
|
| 1318 |
Example 1.46. time_exten example |
| 1319 |
... |
| 1320 |
modparam("acc", "time_exten", "microsecs") |
| 1321 |
... |
| 1322 |
|
| 1323 |
6.47. time_format (str) |
| 1324 |
|
| 1325 |
Specify the format to print the time for time_mode 3 or 4. |
| 1326 |
|
| 1327 |
Default value is %Y-%m-%d %H:%M:%S". |
| 1328 |
|
| 1329 |
Example 1.47. time_format example |
| 1330 |
... |
| 1331 |
modparam("acc", "time_format", "%Y/%m/%d %H:%M:%S") |
| 1332 |
... |
| 1333 |
|
| 1334 |
6.48. reason_from_hf (int) |
| 1335 |
|
| 1336 |
Tells where to take sip_reason from. If value is 0, sip_reason is taken |
| 1337 |
from status line. Otherwise, sip_reason is taken from Reason header |
| 1338 |
field(s) if present. Currently only the first Reason header is used. |
| 1339 |
|
| 1340 |
Default value is 0. |
| 1341 |
|
| 1342 |
Example 1.48. reason_from_hf |
| 1343 |
... |
| 1344 |
modparam("acc", "reason_from_hf", 1) |
| 1345 |
... |
| 1346 |
|
| 1347 |
6.49. clone_msg (int) |
| 1348 |
|
| 1349 |
If set to 1, request structure from transaction is cloned temporarily |
| 1350 |
in the callback to get acc attributes. It is required if you account |
| 1351 |
values from SIP headers to avoid concurrent access to the shared memory |
| 1352 |
transaction structure, specially when accounting 1xx events. If set to |
| 1353 |
0, it uses directly the shared memory structure, be sure you store all |
| 1354 |
needed attributes in AVPs/XAVPs inside request route. |
| 1355 |
|
| 1356 |
Default value is 1. |
| 1357 |
|
| 1358 |
Example 1.49. clone_msg |
| 1359 |
... |
| 1360 |
modparam("acc", "clone_msg", 0) |
| 1361 |
... |
| 1362 |
|
| 1363 |
6.50. cdr_on_failed (int) |
| 1364 |
|
| 1365 |
If set to 1, the module stores the CDR for a failed dialog (calls not |
| 1366 |
answered). If set to 0, those records are not stored, only those for |
| 1367 |
answered calls. |
| 1368 |
|
| 1369 |
Default value is 1. |
| 1370 |
|
| 1371 |
Example 1.50. cdr_on_failed |
| 1372 |
... |
| 1373 |
modparam("acc", "cdr_on_failed", 0) |
| 1374 |
... |
| 1375 |
|
| 1376 |
6.51. acc_extra_size (int) |
| 1377 |
|
| 1378 |
Set the maximum number of extra attributes that can be stored in the |
| 1379 |
accounting record (event accounting record). It is related to log_extra |
| 1380 |
and db_extra module parameters. |
| 1381 |
|
| 1382 |
Default value is 64. |
| 1383 |
|
| 1384 |
Example 1.51. acc_extra_size |
| 1385 |
... |
| 1386 |
modparam("acc", "acc_extra_size", 100) |
| 1387 |
... |
| 1388 |
|
| 1389 |
6.52. cdr_extra_size (int) |
| 1390 |
|
| 1391 |
Set the maximum number of extra attributes that can be stored in the |
| 1392 |
call data record (cdr by dialog module). It is related to cdr_extra |
| 1393 |
module parameter. |
| 1394 |
|
| 1395 |
Default value is 64. |
| 1396 |
|
| 1397 |
Example 1.52. cdr_extra_size |
| 1398 |
... |
| 1399 |
modparam("acc", "cdr_extra_size", 100) |
| 1400 |
... |
| 1401 |
|
| 1402 |
7. Functions |
| 1403 |
|
| 1404 |
7.1. acc_log_request(comment) |
| 1405 |
7.2. acc_db_request(comment, table) |
| 1406 |
7.3. acc_request(comment, table) |
| 1407 |
|
| 1408 |
7.1. acc_log_request(comment) |
| 1409 |
|
| 1410 |
acc_request reports on a request, for example, it can be used to report |
| 1411 |
on missed calls to off-line users who are replied 404 - Not Found. To |
| 1412 |
avoid multiple reports on UDP request retransmission, you would need to |
| 1413 |
embed the action in stateful processing. |
| 1414 |
|
| 1415 |
Meaning of the parameters is as follows: |
| 1416 |
* comment - Comment to be appended. The string can contain any number |
| 1417 |
of pseudo-variables. |
| 1418 |
|
| 1419 |
This function can be used from ANY_ROUTE. |
| 1420 |
|
| 1421 |
Example 1.53. acc_log_request usage |
| 1422 |
... |
| 1423 |
acc_log_request("Some comment"); |
| 1424 |
$var(code) = 404; |
| 1425 |
$avp(reason) = "Not found"; |
| 1426 |
acc_log_request("$var(code) Error: $avp(reason)"); |
| 1427 |
... |
| 1428 |
|
| 1429 |
7.2. acc_db_request(comment, table) |
| 1430 |
|
| 1431 |
Like acc_log_request, acc_db_request reports on a request. The report |
| 1432 |
is sent to database at “db_url”, in the table referred to in the second |
| 1433 |
action parameter. |
| 1434 |
|
| 1435 |
Meaning of the parameters is as follows: |
| 1436 |
* comment - Comment to be appended. The string can contain any number |
| 1437 |
of pseudo-variables. |
| 1438 |
* table - Database table to be used. It can contain config variables |
| 1439 |
that are evaluated at runtime. |
| 1440 |
|
| 1441 |
This function can be used from ANY_ROUTE. |
| 1442 |
|
| 1443 |
Example 1.54. acc_db_request usage |
| 1444 |
... |
| 1445 |
acc_db_request("Some comment", "SomeTable"); |
| 1446 |
acc_db_request("Some comment", "acc_$time(year)_$time(mon)"); |
| 1447 |
acc_db_request("$var(code) Error: $avp(reason)", "SomeTable"); |
| 1448 |
... |
| 1449 |
|
| 1450 |
7.3. acc_request(comment, table) |
| 1451 |
|
| 1452 |
Wrapper around acc_log_request and acc_db_request functions, writing |
| 1453 |
the accounting record to LOG and DATABASE backends. If “db_url” |
| 1454 |
parameter is not set, the acc record is written only to LOG backend. |
| 1455 |
|
| 1456 |
Meaning of the parameters is as follows: |
| 1457 |
* comment - Comment to be used for generating the SIP response code |
| 1458 |
and text fields, if in the format “CODE TEXT”. The CODE should be a |
| 1459 |
valid SIP response code (100..699). The TEXT can be one or many |
| 1460 |
words. If CODE is missing, then 0 is used. The parameter can |
| 1461 |
contain pseudo-variables. |
| 1462 |
* table - Database table to be used. It can contain config variables |
| 1463 |
that are evaluated at runtime. |
| 1464 |
|
| 1465 |
This function can be used from ANY_ROUTE. |
| 1466 |
|
| 1467 |
Example 1.55. acc_db_request usage |
| 1468 |
... |
| 1469 |
acc_request("100 Received", "acc"); |
| 1470 |
acc_request("100 Received", "acc_$time(year)_$time(mon)"); |
| 1471 |
acc_db_request("$var(code) $avp(reason)", "acc"); |
| 1472 |
... |
| 1473 |
|
| 1474 |
Chapter 2. Frequently Asked Questions |
| 1475 |
|
| 1476 |
2.1. What happened with old log_fmt parameter? |
| 1477 |
2.2. What happened with old multi_leg_enabled parameter? |
| 1478 |
2.3. What happened with old src_leg_avp_id and dst_leg_avp_id |
| 1479 |
parameters? |
| 1480 |
|
| 1481 |
2.4. Where can I find more about Kamailio? |
| 1482 |
2.5. Where can I post a question about this module? |
| 1483 |
2.6. How can I report a bug? |
| 1484 |
|
| 1485 |
2.1. |
| 1486 |
|
| 1487 |
What happened with old log_fmt parameter? |
| 1488 |
|
| 1489 |
The parameter became obsolete with the restructure of the data logged |
| 1490 |
by ACC module (refer to the Overview chapter). For similar behaviour |
| 1491 |
you can use the extra accounting (see the corresponding chapter). |
| 1492 |
|
| 1493 |
2.2. |
| 1494 |
|
| 1495 |
What happened with old multi_leg_enabled parameter? |
| 1496 |
|
| 1497 |
The parameter became obsolete by the addition of the new multi_leg_info |
| 1498 |
parameter. The multi-leg accounting is automatically enabled when |
| 1499 |
multi_leg_info is defined. |
| 1500 |
|
| 1501 |
2.3. |
| 1502 |
|
| 1503 |
What happened with old src_leg_avp_id and dst_leg_avp_id parameters? |
| 1504 |
|
| 1505 |
The parameters were replaced by the more generic new parameter |
| 1506 |
multi_leg_info. This allows logging (per-leg) of more information than |
| 1507 |
just dst and src. |
| 1508 |
|
| 1509 |
2.4. |
| 1510 |
|
| 1511 |
Where can I find more about Kamailio? |
| 1512 |
|
| 1513 |
Take a look at https://www.kamailio.org/. |
| 1514 |
|
| 1515 |
2.5. |
| 1516 |
|
| 1517 |
Where can I post a question about this module? |
| 1518 |
|
| 1519 |
First at all check if your question was already answered on one of our |
| 1520 |
mailing lists: |
| 1521 |
* User Mailing List - |
| 1522 |
https://lists.kamailio.org/mailman3/postorius/lists/sr-users.lists. |
| 1523 |
kamailio.org/ |
| 1524 |
* Developer Mailing List - |
| 1525 |
https://lists.kamailio.org/mailman3/postorius/lists/sr-dev.lists.ka |
| 1526 |
mailio.org/ |
| 1527 |
|
| 1528 |
E-mails regarding any stable Kamailio release should be sent to |
| 1529 |
<[email protected]> and e-mails regarding development |
| 1530 |
versions should be sent to <[email protected]>. |
| 1531 |
|
| 1532 |
2.6. |
| 1533 |
|
| 1534 |
How can I report a bug? |
| 1535 |
|
| 1536 |
Please follow the guidelines provided at: |
| 1537 |
https://github.com/kamailio/kamailio/issues. |