11 <bogdan@voice-system.ro>
23 <bogdan@voice-system.ro>
30 <sven.knoblich@1und1.de>
32 Copyright © 2002, 2003 FhG FOKUS
34 Copyright © 2004, 2006 Voice Sistem SRL
36 Copyright © 2011 1&1 Internet AG
38 Revision $Revision$ $Date$
39 __________________________________________________________________
52 2.2. Definitions and syntax
55 3. Multi Call-Legs accounting
61 4. Call Data Record generation
66 4.2.1. Definitions and syntax
68 4.3. CDR with Multi Call-Legs
73 4.3.2.1. Example for a spiraled Proxy
80 5.2. External Libraries or Applications
84 6.1. early_media (integer)
85 6.2. failed_transaction_flag (integer)
86 6.3. failed_filter (string)
87 6.4. report_ack (integer)
88 6.5. report_cancels (integer)
89 6.6. detect_direction (integer)
90 6.7. acc_prepare_flag (integer)
91 6.8. acc_prepare_always (integer)
92 6.9. multi_leg_info (string)
93 6.10. log_flag (integer)
94 6.11. log_missed_flag (integer)
95 6.12. log_level (integer)
96 6.13. log_facility (string)
97 6.14. log_extra (string)
98 6.15. radius_config (string)
99 6.16. radius_flag (integer)
100 6.17. radius_missed_flag (integer)
101 6.18. service_type (integer)
102 6.19. radius_extra (string)
103 6.20. db_flag (integer)
104 6.21. db_missed_flag (integer)
105 6.22. db_table_acc (string)
106 6.23. db_table_missed_calls (string)
107 6.24. db_url (string)
108 6.25. acc_method_column (string)
109 6.26. acc_from_tag_column (string)
110 6.27. acc_to_tag_column (string)
111 6.28. acc_callid_column (string)
112 6.29. acc_sip_code_column (string)
113 6.30. acc_sip_reason_column (string)
114 6.31. acc_time_column (string)
115 6.32. db_extra (string)
116 6.33. db_insert_mode (integer)
117 6.34. diameter_flag (integer)
118 6.35. diameter_missed_flag (integer)
119 6.36. diameter_client_host (string)
120 6.37. diameter_client_port (int)
121 6.38. diameter_extra (string)
122 6.39. cdr_enable (integer)
123 6.40. cdr_expired_dlg_enable (integer)
124 6.41. cdr_start_on_confirmed (integer)
125 6.42. cdr_facility (integer)
126 6.43. cdr_extra (string)
127 6.44. cdr_start_id (string)
128 6.45. cdr_end_id (string)
129 6.46. cdr_duration_id (string)
130 6.47. cdr_log_enable (int)
131 6.48. cdrs_table (str)
132 6.49. time_mode (int)
133 6.50. time_attr (str)
134 6.51. time_exten (str)
135 6.52. time_format (str)
136 6.53. reason_from_hf (int)
137 6.54. clone_msg (int)
138 6.55. cdr_on_failed (int)
142 7.1. acc_log_request(comment)
143 7.2. acc_db_request(comment, table)
144 7.3. acc_rad_request(comment)
145 7.4. acc_diam_request(comment)
147 2. Frequently Asked Questions
151 1.1. early_media example
152 1.2. failed_transaction_flag example
153 1.3. failed_filter example
154 1.4. report_ack example
155 1.5. report_cancels example
156 1.6. detect_direction example
157 1.7. acc_prepare_flag example
158 1.8. acc_prepare_flag example
159 1.9. multi_leg_info example
160 1.10. log_flag example
161 1.11. log_missed_flag example
162 1.12. log_level example
163 1.13. log_facility example
164 1.14. log_extra example
165 1.15. radius_config example
166 1.16. radius_flag example
167 1.17. radius_missed_flag example
168 1.18. service_type example
169 1.19. radius_extra example
170 1.20. db_flag example
171 1.21. db_missed_flag example
172 1.22. db_table_acc example
173 1.23. db_table_missed_calls example
175 1.25. acc_method_column example
176 1.26. acc_from_tag_column example
177 1.27. acc_to_tag_column example
178 1.28. acc_callid_column example
179 1.29. acc_sip_code_column example
180 1.30. acc_sip_reason_column example
181 1.31. acc_time_column example
182 1.32. db_extra example
183 1.33. db_insert_mode example
184 1.34. diameter_flag example
185 1.35. diameter_missed_flag example
186 1.36. diameter_client_host example
187 1.37. diameter_client_host example
188 1.38. diameter_extra example
189 1.39. cdr_enable example
190 1.40. cdr_expired_dlg_enable example
191 1.41. cdr_start_on_confirmed example
192 1.42. cdr_facility example
193 1.43. cdr_extra example
194 1.44. cdr_start_id example
195 1.45. cdr_end_id example
196 1.46. cdr_duration_id example
197 1.47. cdr_log_enable example
198 1.48. cdrs_table example
199 1.49. time_mode example
200 1.50. time_attr example
201 1.51. time_exten example
202 1.52. time_format example
206 1.56. acc_log_request usage
207 1.57. acc_db_request usage
208 1.58. acc_rad_request usage
209 1.59. acc_diam_request usage
211 Chapter 1. Admin Guide
222 2.2. Definitions and syntax
225 3. Multi Call-Legs accounting
231 4. Call Data Record generation
236 4.2.1. Definitions and syntax
238 4.3. CDR with Multi Call-Legs
243 4.3.2.1. Example for a spiraled Proxy
249 5.1. Kamailio Modules
250 5.2. External Libraries or Applications
254 6.1. early_media (integer)
255 6.2. failed_transaction_flag (integer)
256 6.3. failed_filter (string)
257 6.4. report_ack (integer)
258 6.5. report_cancels (integer)
259 6.6. detect_direction (integer)
260 6.7. acc_prepare_flag (integer)
261 6.8. acc_prepare_always (integer)
262 6.9. multi_leg_info (string)
263 6.10. log_flag (integer)
264 6.11. log_missed_flag (integer)
265 6.12. log_level (integer)
266 6.13. log_facility (string)
267 6.14. log_extra (string)
268 6.15. radius_config (string)
269 6.16. radius_flag (integer)
270 6.17. radius_missed_flag (integer)
271 6.18. service_type (integer)
272 6.19. radius_extra (string)
273 6.20. db_flag (integer)
274 6.21. db_missed_flag (integer)
275 6.22. db_table_acc (string)
276 6.23. db_table_missed_calls (string)
277 6.24. db_url (string)
278 6.25. acc_method_column (string)
279 6.26. acc_from_tag_column (string)
280 6.27. acc_to_tag_column (string)
281 6.28. acc_callid_column (string)
282 6.29. acc_sip_code_column (string)
283 6.30. acc_sip_reason_column (string)
284 6.31. acc_time_column (string)
285 6.32. db_extra (string)
286 6.33. db_insert_mode (integer)
287 6.34. diameter_flag (integer)
288 6.35. diameter_missed_flag (integer)
289 6.36. diameter_client_host (string)
290 6.37. diameter_client_port (int)
291 6.38. diameter_extra (string)
292 6.39. cdr_enable (integer)
293 6.40. cdr_expired_dlg_enable (integer)
294 6.41. cdr_start_on_confirmed (integer)
295 6.42. cdr_facility (integer)
296 6.43. cdr_extra (string)
297 6.44. cdr_start_id (string)
298 6.45. cdr_end_id (string)
299 6.46. cdr_duration_id (string)
300 6.47. cdr_log_enable (int)
301 6.48. cdrs_table (str)
302 6.49. time_mode (int)
303 6.50. time_attr (str)
304 6.51. time_exten (str)
305 6.52. time_format (str)
306 6.53. reason_from_hf (int)
307 6.54. clone_msg (int)
308 6.55. cdr_on_failed (int)
312 7.1. acc_log_request(comment)
313 7.2. acc_db_request(comment, table)
314 7.3. acc_rad_request(comment)
315 7.4. acc_diam_request(comment)
321 ACC module is used to account transactions information to different
322 backends like syslog, SQL, RADIUS and DIAMETER (beta version).
324 To account a transaction and to choose which set of backends to be
325 used, the script writer just has to set some flags (see the module
326 parameters section for flag definitions Section 6, "Parameters"). If
327 the accounting flag for a specific backend is set, the acc module will
328 then report on completed transaction. A typical usage of the module
329 takes no acc-specific script command -- the functionality binds
330 invisibly through transaction processing. Script writers just need to
331 mark the transaction for accounting with proper setflag. Even so, the
332 module allows the script writter to force accounting in special cases
333 via some script functions.
335 The accounting module will log by default a fixed set of attributes for
336 the transaction - if you customize your accounting by adding more
337 information to be logged, please see the next chapter about extra
338 accounting - Section 2, "Extra accounting".
340 The fixed minimal accounting information is:
341 * Request Method name
342 * From header TAG parameter
343 * To header TAG parameter
345 * 3-digit Status code from final reply
346 * Reason phrase from final reply
347 * Time stamp when transaction was completed
349 If a value is not present in request, the empty string is accounted
353 * A single INVITE may produce multiple accounting reports -- that's
354 due to SIP forking feature.
355 * All flags related to accounting need to be set in request
356 processing route - only the "missed-call" flag may be toggled from
357 other types of routes.
358 * If a UA fails in middle of conversation, a proxy will never find
359 out about it. In general, a better practice is to account from an
360 end-device (such as PSTN gateway), which best knows about call
361 status (including media status and PSTN status in case of the
362 gateway). However, CDR-base logging has the option to log existing
363 information from expired dialogs (the dlg_vars in cdr_extra) Please
364 see cdr_expired_dlg_enable parameter - Section 6.40,
365 "cdr_expired_dlg_enable (integer)".
367 The SQL backend support is compiled in the module. For RADIUS and
368 DIAMETER you need to enable it by recompiling the module with properly
369 set defines: uncomment the RAD_ACC or DDIAM_ACC lines in
370 modules/acc/Makefile. To compile RADIUS support, you need to have
371 radiusclient-ng (only versions higher or equal to 0.5.0) installed on
372 your system which is available from
373 http://developer.berlios.de/projects/radiusclient-ng/. The radius
374 client needs to be configured properly. To do so, use the template at
375 etc/radiusclient.conf and make sure that module's radius_config
376 parameter points to its location. In particular, accounting secret must
377 match that one configured in server and proper dictionary is used (one
378 is available at etc/sip_dictionary). Also note that Debian
379 radiusclient-ng uses /var/run/radius.seq as seqfile but Kamailio Debian
380 init script expects /var/run/kamailio/kamailio_radius.seq, so is needed
381 to change it in radiusclient-ng configuration or in Kamailio Debian
382 init script (if not, Kamailio can't create the seq file when not
383 running as root). Uses along with FreeRadius (
384 http://www.freeradius.org/) and Radiator (
385 http://www.open.com.au/radiator/) servers have been reported to us.
387 NOTE: diameter support was developed for DISC (DIameter Server Client
388 project at http://developer.berlios.de/projects/disc/). This project
389 seems to be no longer maintained and DIAMETER specifications were
390 updated in the meantime. Thus, the DIAMETER part in the module is
391 obsolete and needs rework to be usable with opendiameter or other
396 loadmodule "modules/acc/acc.so"
397 modparam("acc", "log_level", 1)
398 modparam("acc", "log_flag", 1)
400 if (uri=~"sip:+40") /* calls to Romania */ {
401 if (!proxy_authorize("sip_domain.net" /* realm */,
402 "subscriber" /* table name */)) {
403 proxy_challenge("sip_domain.net" /* realm */, "0" /* no qop */ );
407 if (method=="INVITE" && !check_from()) {
408 log("from!=digest\n");
409 sl_send_reply("403","Forbidden");
412 setflag(1); /* set for accounting (the same value as in log_flag!)
413 t_relay(); /* enter stateful mode now */
419 2.2. Definitions and syntax
424 Along the static default information, ACC modules allows dynamical
425 selection of extra information to be logged. This allows you to log any
426 pseudo-variable (AVPs, parts of the request, etc).
428 2.2. Definitions and syntax
430 Selection of extra information is done via xxx_extra parameters by
431 specifying the names of additional information you want to log. This
432 information is defined via pseudo-variables and may include headers,
433 AVPs values or other message or system values. The syntax of the
435 * xxx_extra = extra_definition (';'extra_definition)*
436 * extra_definition = log_name '=' pseudo_variable
438 The full list of supported pseudo-variables in Kamailio is available
439 at: http://www.kamailio.org/wiki/cookbooks/devel/pseudovariables
441 Note: For all the ACK processed by tm, the registered callbacks (like
442 acc module) will be called with the corresponding INVITE transaction
443 contexts as long as this is still available. This means that the ACK
444 callbacks will see the AVPs setup for the INVITE transaction and not
445 the AVPs setup before t_relay().
447 Via log_name you define how/where the data will be logged. Its meaning
448 depends of the accounting support which is used:
449 * LOG accounting - log_name will be just printed along with the data
450 in log_name=data format;
451 * DB accounting - log_name will be the name of the DB column where
452 the data will be stored.IMPORTANT: add in db acc table the columns
453 corresponding to each extra data;
454 * RADIUS accounting - log_name will be the AVP name used for packing
455 the data into RADIUS message. The log_name will be translated to
456 AVP number via the dictionary. IMPORTANT: add in RADIUS dictionary
457 the log_name attribute.
458 * DIAMETER accounting - log_name will be the AVP code used for
459 packing the data into DIAMETER message. The AVP code is given
460 directly as integer, since DIAMETER has no dictionary support yet.
461 IMPORTANT: log_name must be a number.
465 Some pseudo variables may return more than one value (like headers or
466 AVPs). In this case, the returned values are embedded in a single
467 string in a comma-separated format.
469 3. Multi Call-Legs accounting
477 A SIP call can have multiple legs due forwarding actions. For example
478 user A calls user B which forwards the call to user C. There is only
479 one SIP call but with 2 legs ( A to B and B to C). Accounting the legs
480 of a call is required for proper billing of the calls (if C is a PSTN
481 number and the call is billed, user B must pay for the call - as last
482 party modifing the call destination-, and not A - as initiator of the
483 call. Call forwarding on server is only one example which shows the
484 necessity of the having an accounting engine with multiple legs
489 First how it works: The idea is to have a set of AVPs and for each call
490 leg to store a set of values in the AVPs. The meaning of the AVP
491 content is stricly decided by the script writer - it can be the origin
492 and source of the leg, its status or any other related information. If
493 you have a set of 4 AVPS (AVP1, AVP2, AVP3, AVP4), then for the "A call
494 B and B forwards to C" example, you need to set a different set of
495 values for the AVPs for each leg ([A,B] and [B,C]) . The script writer
496 must take care and properly insert all these AVP from the script (in
497 proper order and with the correct type).
499 When the accounting information for the call will be written/sent, all
500 the call-leg pairs will be added (based on the found AVP sets).
502 By default, the multiple call-leg support is disabled - it can be
503 enabled just be setting the per-leg set of AVPs via the multi_leg_info
508 For each call, all the values of the AVP set (which defines a call-leg)
509 will be logged. How the information will be actually logged, depends of
511 * syslog -- all leg-sets will be added to one record string as
512 AVP1=xxx, AVP2=xxxx ,... sets.
513 * database -- each pair will be separately logged (due DB data
514 structure constraints); several records will be written, the
515 difference between them being only the fields corresponding to the
519 You will need to add in your DB (all acc related tables) the colums
520 for call-leg info (a column for each AVP of the set).
521 * Radius -- all sets will be added to the same Radius accounting
522 message as RADIUS AVPs - for each call-leg a set of RADIUS AVPs
523 will be added (corresponding to the per-leg AVP set)
526 You will need to add in your dictionary the RADIUS AVPs used in
527 call-leg AVP set definition.
528 * Diameter same as for RADIUS.
530 4. Call Data Record generation
535 4.2.1. Definitions and syntax
537 4.3. CDR with Multi Call-Legs
542 4.3.2.1. Example for a spiraled Proxy
548 In addition to transaction-based logging, it is possible to generate
549 and log Call Data Records (CDRs) directly from Kamailio. Apart from a
550 basic set of CDR fields which are always included (covering start time,
551 end time, and duration), the approach allows flexible specification of
552 additional fields that should be taken into account using the
553 configuration script. This is very similar to how transaction-based
554 logging may be customized with the exception that CDRs rely on dialogs
555 instead of transactions to store relevant information during a call.
557 In order to set up CDR generation, you must enable the CDR switch and
558 load the dialog module. You probably also want to specify a set of
559 pseudo-variables that define more relevant CDR fields. Pseudo-variables
560 may be assigned arbitrarily during script execution, and the module
561 will make sure that the variable content will be transformed into a CDR
562 by the end of the dialog.
564 To use CDR logging in a correct manner, you should only use the
565 dialog-based pseudo-variables (dlg_var) from the dialog module. This
566 allows you to save values right from the beginning through all requests
567 and replies until termination of the call. While not recommended, it is
568 still possible to use other pseudo-variables as well. Except for
569 pseudo-variables valid in the call-final transaction, however,
570 information given will not be stored in the CDR as they cannot be
571 accessed by the end of the call when the CDR is logged.
573 Sometimes, dialogs expire because the UA has a problem and a final
574 message is never transmitted. You can toggle on/off the generation of
575 CDR-based logging in such cases with only the dlg_vars showing by using
576 the cdr_expired_dlg_enable parameter - Section 6.40,
577 "cdr_expired_dlg_enable (integer)". Default behavior is not logging.
581 This section is similar to the "LOG accounting" part of Section 2,
584 4.2.1. Definitions and syntax
586 Selection of extra information is done similar to the transaction extra
587 Section 2.2, "Definitions and syntax".
588 * cdr_extra = cdr_extra_definition (';'cdr_extra_definition)*
589 * cdr_extra_definition = cdr_log_name '=' pseudo_variable
591 See also Section 6.43, "cdr_extra (string)".
593 The full list of supported pseudo-variables in Sip-Router is available
594 at: http://sip-router.org/wiki/cookbooks/pseudo-variables/devel
596 4.3. CDR with Multi Call-Legs
600 As mentioned in Section 3, "Multi Call-Legs accounting", a leg
601 represents a parallel or forwarded call. In contrast to the normal
602 accounting the cdr logging uses dialogs instead of transaction to log
603 data. This may reduce the amount of information but it also make it
604 possible to combine all important data in one cdr at once. A second
605 mechanism to process multiple data-sets into one cdr is not further
610 When you route messages multiple times through your proxy (e.g. to
611 handle "call-forwardings") you have to use detect_spirals from the
612 dialog modules. Otherwise the proxy can't identify and reuse existing
615 To get the correct call-forwarding-chain you have to store each cf*
616 with the corresponding caller and callee in a dialog based
617 pseudo-variable (dlg_var) (e.g. chain=B;cfa;C|C;cfnr;D). Additionally
618 it is necessary to store the caller and callee for each leg. All this
619 helps to identify the involved phone parners and forwarding chain. When
620 you route such calls multiple times to the same Proxy, you could store
621 the caller and callee within an transaction based avp and write it into
622 the dialog based dlg_var pv during a 200 INVITE.
624 4.3.2.1. Example for a spiraled Proxy
627 # A calls B (transaction 1)
632 # B cfa C (transaction 2)
635 $dlg_var(chain)='B;cfu;C';
637 # C cfnr D (transaction 3)
640 $dlg_var(chain)=$dlg_var(chain) + "|" + "C;cfnr;D";
642 # C confirms call (200 reply of transaction 2)
643 $dlg_var(caller) = $avp(caller); #caller='B'
644 $dlg_var(callee) = $avp(callee); #callee='C'
649 For each call, all dialog corresponding variables will be logged. After
650 a call is finished, the generated call data record information will be
651 logged as string (VAR1=xxx,VAR2=xxxx,...) to the syslog.
655 5.1. Kamailio Modules
656 5.2. External Libraries or Applications
658 5.1. Kamailio Modules
660 The module depends on the following modules (in the other words the
661 listed modules must be loaded before this module):
662 * tm -- Transaction Manager
663 * a database module -- If SQL support is used.
664 * rr -- Record Route, if "detect_direction" module parameter is
666 * dialog -- Dialog, if "cdr_enable" module parameter is enabled.
668 5.2. External Libraries or Applications
670 The following libraries or applications must be installed before
671 running Kamailio with this module loaded:
672 * radiusclient-ng 0.5.0 or higher -- if compiled with RADIUS support.
673 See http://developer.berlios.de/projects/radiusclient-ng/.
677 6.1. early_media (integer)
678 6.2. failed_transaction_flag (integer)
679 6.3. failed_filter (string)
680 6.4. report_ack (integer)
681 6.5. report_cancels (integer)
682 6.6. detect_direction (integer)
683 6.7. acc_prepare_flag (integer)
684 6.8. acc_prepare_always (integer)
685 6.9. multi_leg_info (string)
686 6.10. log_flag (integer)
687 6.11. log_missed_flag (integer)
688 6.12. log_level (integer)
689 6.13. log_facility (string)
690 6.14. log_extra (string)
691 6.15. radius_config (string)
692 6.16. radius_flag (integer)
693 6.17. radius_missed_flag (integer)
694 6.18. service_type (integer)
695 6.19. radius_extra (string)
696 6.20. db_flag (integer)
697 6.21. db_missed_flag (integer)
698 6.22. db_table_acc (string)
699 6.23. db_table_missed_calls (string)
700 6.24. db_url (string)
701 6.25. acc_method_column (string)
702 6.26. acc_from_tag_column (string)
703 6.27. acc_to_tag_column (string)
704 6.28. acc_callid_column (string)
705 6.29. acc_sip_code_column (string)
706 6.30. acc_sip_reason_column (string)
707 6.31. acc_time_column (string)
708 6.32. db_extra (string)
709 6.33. db_insert_mode (integer)
710 6.34. diameter_flag (integer)
711 6.35. diameter_missed_flag (integer)
712 6.36. diameter_client_host (string)
713 6.37. diameter_client_port (int)
714 6.38. diameter_extra (string)
715 6.39. cdr_enable (integer)
716 6.40. cdr_expired_dlg_enable (integer)
717 6.41. cdr_start_on_confirmed (integer)
718 6.42. cdr_facility (integer)
719 6.43. cdr_extra (string)
720 6.44. cdr_start_id (string)
721 6.45. cdr_end_id (string)
722 6.46. cdr_duration_id (string)
723 6.47. cdr_log_enable (int)
724 6.48. cdrs_table (str)
725 6.49. time_mode (int)
726 6.50. time_attr (str)
727 6.51. time_exten (str)
728 6.52. time_format (str)
729 6.53. reason_from_hf (int)
730 6.54. clone_msg (int)
731 6.55. cdr_on_failed (int)
733 6.1. early_media (integer)
735 Should be early media (any provisional reply with body) accounted too ?
737 Default value is 0 (no).
739 Example 1.1. early_media example
741 modparam("acc", "early_media", 1)
744 6.2. failed_transaction_flag (integer)
746 Per transaction flag which says if the transaction should be accounted
747 also in case of failure (status>=300).
749 Default value is not-set (no flag).
751 Example 1.2. failed_transaction_flag example
753 modparam("acc", "failed_transaction_flag", 4)
756 6.3. failed_filter (string)
758 A string of failure response codes from 300 to 999 separated by commas.
759 Failed transaction will not be accounted if its response code is in the
760 list even when failed_transaction_flag is set.
762 Default value is not-set (failure filtering is off).
764 Example 1.3. failed_filter example
766 modparam("acc", "failed_filter", "404,407")
769 6.4. report_ack (integer)
771 Shall acc attempt to account e2e ACKs too ? Note that this is really
772 only an attempt, as e2e ACKs may take a different path (unless RR
773 enabled) and mismatch original INVITE (e2e ACKs are a separate
774 transaction). The flag for accounting has to be set for each ACK as
777 Default value is 0 (no).
779 Example 1.4. report_ack example
781 modparam("acc", "report_ack", 1)
784 6.5. report_cancels (integer)
786 By default, CANCEL reporting is disabled -- most accounting
787 applications wants to see INVITE's cancellation status. Turn on if you
788 explicitly want to account CANCEL transactions.
790 Default value is 0 (no).
792 Example 1.5. report_cancels example
794 modparam("acc", "report_cancels", 1)
797 6.6. detect_direction (integer)
799 Controlles the direction detection for sequential requests. If enabled
800 (non zero value), for sequential requests with upstream direction (from
801 callee to caller), the FROM and TO will be swapped (the direction will
802 be preserved as in the original request).
804 It affects all values related to TO and FROM headers (body, URI,
805 username, domain, TAG).
807 Default value is 0 (disabled).
809 Example 1.6. detect_direction example
811 modparam("acc", "detect_direction", 1)
814 6.7. acc_prepare_flag (integer)
816 Per transaction flag which says if the transaction may be accounted
817 later, with flags set in TM module specific routes (e.g., like
818 failure_route). If this flag is not set and acc or missed_call flag are
819 not set either in request route block, there is no way to mark the
820 request for transaction later unless you set acc_prepare_always. If
821 either acc or missed_call flags are set in request route block, there
822 is no need to set this flag.
824 Default value is not-set (no flag).
826 Example 1.7. acc_prepare_flag example
828 modparam("acc", "acc_prepare_flag", 5)
831 6.8. acc_prepare_always (integer)
833 Prepare all request even if acc_prepare_flag is not set to mark the
834 request for transaction later.
836 Default value is not-set (previous behaviour).
838 Example 1.8. acc_prepare_flag example
840 modparam("acc", "acc_prepare_always", 1)
843 6.9. multi_leg_info (string)
845 Defines the AVP set to be used in per-call-leg accounting. See
846 Section 3, "Multi Call-Legs accounting" for a detailed description of
847 the Multi Call-Legs accounting.
849 If empty, the multi-leg accounting support will be disabled.
851 Default value is 0 (disabled).
853 Example 1.9. multi_leg_info example
855 # for syslog-based accounting, use any text you want to be printed
856 modparam("acc", "multi_leg_info",
857 "text1=$avp(src);text2=$avp(dst)")
858 # for mysql-based accounting, use the names of the columns
859 modparam("acc", "multi_leg_info",
860 "leg_src=$avp(src);leg_dst=$avp(dst)")
861 # for RADIUS-based accounting, use the names of the RADIUS AVPs
862 modparam("acc", "multi_leg_info",
863 "RAD_LEG_SRC=$avp(src);RAD_LEG_SRC=$avp(dst)")
864 # for DIAMETER-based accounting, use the DIAMETER AVP ID (as integer)
865 modparam("acc", "multi_leg_info",
866 "2345=$avp(src);2346=$avp(dst)")
869 6.10. log_flag (integer)
871 Request flag which needs to be set to account a transaction via syslog.
873 Default value is not-set (no flag).
875 Example 1.10. log_flag example
877 modparam("acc", "log_flag", 2)
880 6.11. log_missed_flag (integer)
882 Request flag which needs to be set to account missed calls via syslog.
884 Default value is not-set (no flag).
886 Example 1.11. log_missed_flag example
888 modparam("acc", "log_missed_flag", 3)
891 6.12. log_level (integer)
893 Log level at which accounting messages are issued to syslog.
895 Default value is L_NOTICE.
897 Example 1.12. log_level example
899 modparam("acc", "log_level", 2) # Set log_level to 2
902 6.13. log_facility (string)
904 Log facility to which accounting messages are issued to syslog. This
905 allows to easily seperate the accounting specific logging from the
908 Default value is LOG_DAEMON.
910 Example 1.13. log_facility example
912 modparam("acc", "log_facility", "LOG_DAEMON")
915 6.14. log_extra (string)
917 Extra values to be logged. See section Section 2, "Extra accounting"
920 Default value is NULL.
922 Example 1.14. log_extra example
924 modparam("acc", "log_extra", "ua=$hdr(User-Agent);uuid=$avp(i:123)")
927 6.15. radius_config (string)
929 This parameter is radius specific. Path to radius client configuration
930 file, set the referred config file correctly and specify there address
931 of server, shared secret (should equal that in
932 /usr/local/etc/raddb/clients for freeRadius servers) and dictionary,
933 see etc for an example of config file and dictionary.
935 If the parameter is set to empty string, the RADIUS accounting support
936 will be disabled (even if compiled).
938 Default value is "NULL".
940 Example 1.15. radius_config example
942 modparam("acc", "radius_config", "/etc/radiusclient/radiusclient.conf")
945 6.16. radius_flag (integer)
947 Request flag which needs to be set to account a transaction -- RADIUS
950 Default value is not-set (no flag).
952 Example 1.16. radius_flag example
954 modparam("acc", "radius_flag", 2)
957 6.17. radius_missed_flag (integer)
959 Request flag which needs to be set to account missed calls -- RADIUS
962 Default value is not-set (no flag).
964 Example 1.17. radius_missed_flag example
966 modparam("acc", "radius_missed_flag", 3)
969 6.18. service_type (integer)
971 Radius service type used for accounting.
973 Default value is 15 (SIP).
975 Example 1.18. service_type example
977 modparam("acc", "service_type", 16)
980 6.19. radius_extra (string)
982 Extra values to be logged via RADIUS - RADIUS specific. See section
983 Section 2, "Extra accounting" for more details.
985 Default value is NULL.
987 Example 1.19. radius_extra example
989 modparam("acc", "radius_extra", "via=$hdr(Via[*]); email=$avp(s:email)")
992 6.20. db_flag (integer)
994 Request flag which needs to be set to account a transaction -- database
997 Default value is not-set (no flag).
999 Example 1.20. db_flag example
1001 modparam("acc", "db_flag", 2)
1004 6.21. db_missed_flag (integer)
1006 Request flag which needs to be set to account missed calls -- database
1009 Default value is not-set (no flag).
1011 Example 1.21. db_missed_flag example
1013 modparam("acc", "db_missed_flag", 3)
1016 6.22. db_table_acc (string)
1018 Table name of accounting successfull calls -- database specific. It can
1019 contain config variables that will be evaluated at runtime.
1021 Default value is "acc"
1023 Example 1.22. db_table_acc example
1025 modparam("acc", "db_table_acc", "myacc_table")
1026 modparam("acc", "db_table_acc", "acc_$time(year)_$time(mon)")
1029 6.23. db_table_missed_calls (string)
1031 Table name for accounting missed calls -- database specific. It can
1032 contain config variables that will be evaluated at runtime.
1034 Default value is "missed_calls"
1036 Example 1.23. db_table_missed_calls example
1038 modparam("acc", "db_table_missed_calls", "myMC_table")
1041 6.24. db_url (string)
1043 SQL address -- database specific. If is set to NULL or emty string, the
1044 SQL support is disabled.
1046 Default value is "NULL" (SQL disabled).
1048 Example 1.24. db_url example
1050 modparam("acc", "db_url", "mysql://user:password@localhost/kamailio")
1053 6.25. acc_method_column (string)
1055 Column name in accounting table to store the request's method name as
1058 Default value is "method".
1060 Example 1.25. acc_method_column example
1062 modparam("acc", "acc_method_column", "method")
1065 6.26. acc_from_tag_column (string)
1067 Column name in accounting table to store the From header TAG parameter.
1069 Default value is "from_tag".
1071 Example 1.26. acc_from_tag_column example
1073 modparam("acc", "acc_from_tag_column", "from_tag")
1076 6.27. acc_to_tag_column (string)
1078 Column name in accounting table to store the To header TAG parameter.
1080 Default value is "to_tag".
1082 Example 1.27. acc_to_tag_column example
1084 modparam("acc", "acc_to_tag_column", "to_tag")
1087 6.28. acc_callid_column (string)
1089 Column name in accounting table to store the request's Callid value.
1091 Default value is "callid".
1093 Example 1.28. acc_callid_column example
1095 modparam("acc", "acc_callid_column", "callid")
1098 6.29. acc_sip_code_column (string)
1100 Column name in accounting table to store the final reply's numric code
1101 value in string format.
1103 Default value is "sip_code".
1105 Example 1.29. acc_sip_code_column example
1107 modparam("acc", "acc_sip_code_column", "sip_code")
1110 6.30. acc_sip_reason_column (string)
1112 Column name in accounting table to store the final reply's reason
1115 Default value is "sip_reason".
1117 Example 1.30. acc_sip_reason_column example
1119 modparam("acc", "acc_sip_reason_column", "sip_reason")
1122 6.31. acc_time_column (string)
1124 Column name in accounting table to store the time stamp of the
1125 transaction completion in date-time format.
1127 Default value is "time".
1129 Example 1.31. acc_time_column example
1131 modparam("acc", "acc_time_column", "time")
1134 6.32. db_extra (string)
1136 Extra values to be logged into database - DB specific. See section
1137 Section 2, "Extra accounting" for more details.
1139 Default value is NULL.
1141 Example 1.32. db_extra example
1143 modparam("acc", "db_extra", "ct=$hdr(Content-type); email=$avp(s:email)")
1146 6.33. db_insert_mode (integer)
1148 If set to 1, use INSERT DELAYED to add records to accounting tables
1149 when the DB driver has support for it. If no INSERT DELAYED support is
1150 offered by DB driver, then standard INSERT is used. Beware that MySQL
1151 InnoDB engine doesn't support INSERT DELAYED, thus be sure the acc
1152 tables are defined with different type (e.g., MyISAM).
1154 If set to 2, async insert is used if the db driver module has support
1155 for it and if async_workers core parameter value is greater than 0. If
1156 not, then standard INSERT is used.
1158 Default value is 0 (no INSERT DELAYED nor async insert).
1160 Example 1.33. db_insert_mode example
1162 modparam("acc", "db_insert_mode", 1)
1165 6.34. diameter_flag (integer)
1167 Request flag which needs to be set to account a transaction -- DIAMETER
1170 Default value is not-set (no flag).
1172 Example 1.34. diameter_flag example
1174 modparam("acc", "diameter_flag", 2)
1177 6.35. diameter_missed_flag (integer)
1179 Request flag which needs to be set to account missed calls -- DIAMETER
1182 Default value is not-set (no flag).
1184 Example 1.35. diameter_missed_flag example
1186 modparam("acc", "diameter_missed_flag", 3)
1189 6.36. diameter_client_host (string)
1191 Hostname of the machine where the DIAMETER Client is running --
1194 Default value is "localhost".
1196 Example 1.36. diameter_client_host example
1198 modparam("acc", "diameter_client_host", "3a_server.net")
1201 6.37. diameter_client_port (int)
1203 Port number where the Diameter Client is listening -- DIAMETER
1206 Default value is 3000.
1208 Example 1.37. diameter_client_host example
1210 modparam("acc", "diameter_client_port", 3000)
1213 6.38. diameter_extra (string)
1215 Extra values to be logged via DIAMETER - DIAMETER specific. See section
1216 Section 2, "Extra accounting" for more details.
1218 Default value is NULL.
1220 Example 1.38. diameter_extra example
1222 modparam("acc", "diameter_extra", "7846=$hdr(Content-type);7847=$avp(s:email)")
1225 6.39. cdr_enable (integer)
1227 Should CDR-based logging be enabled?
1229 0 - off (default). 1 - on.
1231 Example 1.39. cdr_enable example
1233 modparam("acc", "cdr_enable", 1)
1236 6.40. cdr_expired_dlg_enable (integer)
1238 Should CDR-based logging be enabled in case of expired dialogs?
1240 0 - off (default). 1 - on.
1242 Example 1.40. cdr_expired_dlg_enable example
1244 modparam("acc", "cdr_expired_dlg_enable", 1)
1247 6.41. cdr_start_on_confirmed (integer)
1249 Should the start time be taken from the time when the dialog is
1250 created, or when the dialog is confirmed?
1252 0 - use time of dialog creation (default). 1 - use time of dialog
1255 Example 1.41. cdr_start_on_confirmed example
1257 modparam("acc", "cdr_start_on_confirmed", 1)
1260 6.42. cdr_facility (integer)
1262 Log facility to which CDR messages are issued to syslog. This allows to
1263 easily seperate CDR-specific logging from the other log messages.
1265 Default value is LOG_DAEMON.
1267 Example 1.42. cdr_facility example
1269 modparam("acc", "cdr_facility", "LOG_DAEMON")
1272 6.43. cdr_extra (string)
1274 Set of pseudo-variables defining custom CDR fields. See Section 4.2,
1275 "CDR Extra" for more details.
1277 Default value is NULL.
1279 Example 1.43. cdr_extra example
1281 modparam("acc", "cdr_extra", "c1=$dlg_var(caller);c2=$dlg_var(callee)"
1284 6.44. cdr_start_id (string)
1286 Modifying the id which is used to store the start time.
1288 Default value is 'start_time'
1290 Example 1.44. cdr_start_id example
1292 modparam("acc", "cdr_start_id", "start")
1295 6.45. cdr_end_id (string)
1297 Modifying the id which is used to store the end time.
1299 Default value is 'end_time'
1301 Example 1.45. cdr_end_id example
1303 modparam("acc", "cdr_end_id", "end")
1306 6.46. cdr_duration_id (string)
1308 Modify the id which is used to store the duration.
1310 Default value is 'duration'
1312 Example 1.46. cdr_duration_id example
1314 modparam("acc", "cdr_duration_id", "d")
1317 6.47. cdr_log_enable (int)
1319 Control if CDR-based accounting should be written to syslog.
1321 0 - off. 1 - on (default).
1323 Example 1.47. cdr_log_enable example
1325 modparam("acc", "cdr_log_enable", 0)
1328 6.48. cdrs_table (str)
1330 Name of db table to store dialog-based CDRs.
1332 Default value is "" (no db storage for dialog-based CDRs).
1334 Example 1.48. cdrs_table example
1336 modparam("acc", "cdrs_table", "acc_cdrs")
1339 6.49. time_mode (int)
1341 Store additional value related to the time of event.
1344 * 0 - (default), save only unix timestamp for syslog and datetime for
1346 * 1 - save seconds in time_attr and microseconds in time_exten.
1347 * 2 - save seconds.miliseconds in time_attr.
1348 * 3 - save formatted time according to time_format parameter, using
1349 the output of localtime().
1350 * 4 - save formatted time according to time_format parameter, using
1351 the output of gmtime().
1353 Example 1.49. time_mode example
1355 modparam("acc", "time_mode", 1)
1358 6.50. time_attr (str)
1360 Name of the syslog attribute or database column where to store
1361 additional value related to the time of event.
1363 For db accounting, the column has to be of different types, depending
1364 on time_mode value. When time_mode is:
1365 * 1 - time_attr column has to be int.
1366 * 2 - time_attr column has to be double.
1367 * 3 - time_attr column has to be varchar(128).
1368 * 4 - time_attr column has to be varchar(128).
1370 For time_mode=1, this attribute is not written in syslog, because time
1371 value is already unix timestamp, but in db accounting time value is
1372 datetime and requires a function to get the timestamp.
1374 Example 1.50. time_attr example
1376 modparam("acc", "time_attr", "seconds")
1379 6.51. time_exten (str)
1381 Name of the syslog attribute or database column where to store extended
1382 value related to the time of event.
1384 It is used now only for time_mode=1 and database column has to be int:
1386 Example 1.51. time_exten example
1388 modparam("acc", "time_exten", "micorsecs")
1391 6.52. time_format (str)
1393 Specify the format to print the time for time_mode 3 or 4.
1395 Default value is %Y-%m-%d %H:%M:%S".
1397 Example 1.52. time_format example
1399 modparam("acc", "time_format", "%Y/%m/%d %H:%M:%S")
1402 6.53. reason_from_hf (int)
1404 Tells where to take sip_reason from. If value is 0, sip_reason is taken
1405 from status line. Otherwise, sip_reason is taken from Reason header
1406 field(s) if present. Currently only the first Reason header is used.
1410 Example 1.53. reason_from_hf
1412 modparam("acc", "reason_from_hf", 1)
1415 6.54. clone_msg (int)
1417 If set to 1, request structure from transaction is cloned temporarily
1418 in the callback to get acc attributes. It is required if you account
1419 values from SIP headers to avoid concurent access to the shared memory
1420 transaction structure, specially when accounting 1xx events. If set to
1421 0, it uses directly the shared memory structure, be sure you store all
1422 needed attributes in AVPs/XAVPs inside request route.
1426 Example 1.54. clone_msg
1428 modparam("acc", "clone_msg", 0)
1431 6.55. cdr_on_failed (int)
1433 If set to 1, the module stores the CDR for a failed dialog (calls not
1434 answered). If set to 0, those records are not stored, only those for
1439 Example 1.55. cdr_on_failed
1441 modparam("acc", "cdr_on_failed", 0)
1446 7.1. acc_log_request(comment)
1447 7.2. acc_db_request(comment, table)
1448 7.3. acc_rad_request(comment)
1449 7.4. acc_diam_request(comment)
1451 7.1. acc_log_request(comment)
1453 acc_request reports on a request, for example, it can be used to report
1454 on missed calls to off-line users who are replied 404 - Not Found. To
1455 avoid multiple reports on UDP request retransmission, you would need to
1456 embed the action in stateful processing.
1458 Meaning of the parameters is as follows:
1459 * comment - Comment to be appended. The string can contain any number
1460 of pseudo-variables.
1462 This function can be used from ANY_ROUTE.
1464 Example 1.56. acc_log_request usage
1466 acc_log_request("Some comment");
1468 $avp(reason) = "Not found";
1469 acc_log_request("$var(code) Error: $avp(reason)");
1472 7.2. acc_db_request(comment, table)
1474 Like acc_log_request, acc_db_request reports on a request. The report
1475 is sent to database at "db_url", in the table referred to in the second
1478 Meaning of the parameters is as follows:
1479 * comment - Comment to be appended. The string can contain any number
1480 of pseudo-variables.
1481 * table - Database table to be used. It can contain config variables
1482 that are evaluated at runtime.
1484 This function can be used from ANY_ROUTE.
1486 Example 1.57. acc_db_request usage
1488 acc_db_request("Some comment", "SomeTable");
1489 acc_db_request("Some comment", "acc_$time(year)_$time(mon)");
1490 acc_db_request("$var(code) Error: $avp(reason)", "SomeTable");
1493 7.3. acc_rad_request(comment)
1495 Like acc_log_request, acc_rad_request reports on a request. It reports
1496 to radius server as configured in "radius_config".
1498 Meaning of the parameters is as follows:
1499 * comment - Comment to be appended. The string can contain any number
1500 of pseudo-variables.
1502 This function can be used from ANY_ROUTE.
1504 Example 1.58. acc_rad_request usage
1506 acc_rad_request("Some comment");
1507 acc_rad_request("$var(code) Error: $avp(reason)");
1510 7.4. acc_diam_request(comment)
1512 Like acc_log_request, acc_diam_request reports on a request. It reports
1513 to the configured Diameter server.
1515 Meaning of the parameters is as follows:
1516 * comment - Comment to be appended. The string can contain any number
1517 of pseudo-variables.
1519 This function can be used from ANY_ROUTE.
1521 Example 1.59. acc_diam_request usage
1523 acc_diam_request("Some comment");
1524 acc_diam_request("$var(code) Error: $avp(reason)");
1527 Chapter 2. Frequently Asked Questions
1529 2.1. What happend with old log_fmt parameter
1530 2.2. What happend with old multi_leg_enabled parameter
1531 2.3. What happend with old src_leg_avp_id and dst_leg_avp_id parameters
1532 2.4. Where can I find more about Kamailio?
1533 2.5. Where can I post a question about this module?
1534 2.6. How can I report a bug?
1538 What happend with old log_fmt parameter
1540 The parameter became obsolete with the restructure of the data logged
1541 by ACC module (refer to the Overview chapter). For similar behaviour
1542 you can use the extra accouting (see the coresponding chapter).
1546 What happend with old multi_leg_enabled parameter
1548 The parameter becaome obsolete by the addition of the new
1549 multi_leg_info parameter. The multi-leg accouting is automatically
1550 enabled when multi_leg_info is defined.
1554 What happend with old src_leg_avp_id and dst_leg_avp_id parameters
1556 The parameter was replaced by the more generic new parameter
1557 multi_leg_info. This allows logging (per-leg) of more information than
1562 Where can I find more about Kamailio?
1564 Take a look at http://www.kamailio.org/.
1568 Where can I post a question about this module?
1570 First at all check if your question was already answered on one of our
1572 * User Mailing List -
1573 http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
1574 * Developer Mailing List -
1575 http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
1577 E-mails regarding any stable Kamailio release should be sent to
1578 <sr-users@lists.sip-router.org> and e-mails regarding development
1579 versions should be sent to <sr-dev@lists.sip-router.org>.
1581 If you want to keep the mail private, send it to
1582 <sr-users@lists.sip-router.org>.
1586 How can I report a bug?
1588 Please follow the guidelines provided at:
1589 https://github.com/kamailio/kamailio/issues.