11 <bogdan@voice-system.ro>
23 <bogdan@voice-system.ro>
28 <sven.knoblich@1und1.de>
30 Copyright © 2002, 2003 FhG FOKUS
32 Copyright © 2004, 2006 Voice Sistem SRL
34 Copyright © 2011 1&1 Internet AG
36 Revision $Revision$ $Date$
37 __________________________________________________________________
50 2.2. Definitions and syntax
53 3. Multi Call-Legs accounting
59 4. Call Data Record generation
64 4.2.1. Definitions and syntax
66 4.3. CDR with Multi Call-Legs
71 4.3.2.1. Example for a spiraled Proxy
78 5.2. External Libraries or Applications
82 6.1. early_media (integer)
83 6.2. failed_transaction_flag (integer)
84 6.3. failed_filter (string)
85 6.4. report_ack (integer)
86 6.5. report_cancels (integer)
87 6.6. detect_direction (integer)
88 6.7. acc_prepare_flag (integer)
89 6.8. acc_prepare_always (integer)
90 6.9. multi_leg_info (string)
91 6.10. log_flag (integer)
92 6.11. log_missed_flag (integer)
93 6.12. log_level (integer)
94 6.13. log_facility (string)
95 6.14. log_extra (string)
96 6.15. radius_config (string)
97 6.16. radius_flag (integer)
98 6.17. radius_missed_flag (integer)
99 6.18. service_type (integer)
100 6.19. radius_extra (string)
101 6.20. db_flag (integer)
102 6.21. db_missed_flag (integer)
103 6.22. db_table_acc (string)
104 6.23. db_table_missed_calls (string)
105 6.24. db_url (string)
106 6.25. acc_method_column (string)
107 6.26. acc_from_tag_column (string)
108 6.27. acc_to_tag_column (string)
109 6.28. acc_callid_column (string)
110 6.29. acc_sip_code_column (string)
111 6.30. acc_sip_reason_column (string)
112 6.31. acc_time_column (string)
113 6.32. db_extra (string)
114 6.33. db_insert_mode (integer)
115 6.34. diameter_flag (integer)
116 6.35. diameter_missed_flag (integer)
117 6.36. diameter_client_host (string)
118 6.37. diameter_client_port (int)
119 6.38. diameter_extra (string)
120 6.39. cdr_enable (integer)
121 6.40. cdr_expired_dlg_enable (integer)
122 6.41. cdr_start_on_confirmed (integer)
123 6.42. cdr_facility (integer)
124 6.43. cdr_extra (string)
125 6.44. cdr_start_id (string)
126 6.45. cdr_end_id (string)
127 6.46. cdr_duration_id (string)
128 6.47. cdr_log_enable (int)
129 6.48. cdrs_table (str)
130 6.49. time_mode (int)
131 6.50. time_attr (str)
132 6.51. time_exten (str)
133 6.52. time_format (str)
134 6.53. reason_from_hf (int)
135 6.54. clone_msg (int)
136 6.55. cdr_on_failed (int)
140 7.1. acc_log_request(comment)
141 7.2. acc_db_request(comment, table)
142 7.3. acc_rad_request(comment)
143 7.4. acc_diam_request(comment)
145 2. Frequently Asked Questions
149 1.1. early_media example
150 1.2. failed_transaction_flag example
151 1.3. failed_filter example
152 1.4. report_ack example
153 1.5. report_cancels example
154 1.6. detect_direction example
155 1.7. acc_prepare_flag example
156 1.8. acc_prepare_flag example
157 1.9. multi_leg_info example
158 1.10. log_flag example
159 1.11. log_missed_flag example
160 1.12. log_level example
161 1.13. log_facility example
162 1.14. log_extra example
163 1.15. radius_config example
164 1.16. radius_flag example
165 1.17. radius_missed_flag example
166 1.18. service_type example
167 1.19. radius_extra example
168 1.20. db_flag example
169 1.21. db_missed_flag example
170 1.22. db_table_acc example
171 1.23. db_table_missed_calls example
173 1.25. acc_method_column example
174 1.26. acc_from_tag_column example
175 1.27. acc_to_tag_column example
176 1.28. acc_callid_column example
177 1.29. acc_sip_code_column example
178 1.30. acc_sip_reason_column example
179 1.31. acc_time_column example
180 1.32. db_extra example
181 1.33. db_insert_mode example
182 1.34. diameter_flag example
183 1.35. diameter_missed_flag example
184 1.36. diameter_client_host example
185 1.37. diameter_client_host example
186 1.38. diameter_extra example
187 1.39. cdr_enable example
188 1.40. cdr_expired_dlg_enable example
189 1.41. cdr_start_on_confirmed example
190 1.42. cdr_facility example
191 1.43. cdr_extra example
192 1.44. cdr_start_id example
193 1.45. cdr_end_id example
194 1.46. cdr_duration_id example
195 1.47. cdr_log_enable example
196 1.48. cdrs_table example
197 1.49. time_mode example
198 1.50. time_attr example
199 1.51. time_exten example
200 1.52. time_format example
204 1.56. acc_log_request usage
205 1.57. acc_db_request usage
206 1.58. acc_rad_request usage
207 1.59. acc_diam_request usage
209 Chapter 1. Admin Guide
220 2.2. Definitions and syntax
223 3. Multi Call-Legs accounting
229 4. Call Data Record generation
234 4.2.1. Definitions and syntax
236 4.3. CDR with Multi Call-Legs
241 4.3.2.1. Example for a spiraled Proxy
247 5.1. Kamailio Modules
248 5.2. External Libraries or Applications
252 6.1. early_media (integer)
253 6.2. failed_transaction_flag (integer)
254 6.3. failed_filter (string)
255 6.4. report_ack (integer)
256 6.5. report_cancels (integer)
257 6.6. detect_direction (integer)
258 6.7. acc_prepare_flag (integer)
259 6.8. acc_prepare_always (integer)
260 6.9. multi_leg_info (string)
261 6.10. log_flag (integer)
262 6.11. log_missed_flag (integer)
263 6.12. log_level (integer)
264 6.13. log_facility (string)
265 6.14. log_extra (string)
266 6.15. radius_config (string)
267 6.16. radius_flag (integer)
268 6.17. radius_missed_flag (integer)
269 6.18. service_type (integer)
270 6.19. radius_extra (string)
271 6.20. db_flag (integer)
272 6.21. db_missed_flag (integer)
273 6.22. db_table_acc (string)
274 6.23. db_table_missed_calls (string)
275 6.24. db_url (string)
276 6.25. acc_method_column (string)
277 6.26. acc_from_tag_column (string)
278 6.27. acc_to_tag_column (string)
279 6.28. acc_callid_column (string)
280 6.29. acc_sip_code_column (string)
281 6.30. acc_sip_reason_column (string)
282 6.31. acc_time_column (string)
283 6.32. db_extra (string)
284 6.33. db_insert_mode (integer)
285 6.34. diameter_flag (integer)
286 6.35. diameter_missed_flag (integer)
287 6.36. diameter_client_host (string)
288 6.37. diameter_client_port (int)
289 6.38. diameter_extra (string)
290 6.39. cdr_enable (integer)
291 6.40. cdr_expired_dlg_enable (integer)
292 6.41. cdr_start_on_confirmed (integer)
293 6.42. cdr_facility (integer)
294 6.43. cdr_extra (string)
295 6.44. cdr_start_id (string)
296 6.45. cdr_end_id (string)
297 6.46. cdr_duration_id (string)
298 6.47. cdr_log_enable (int)
299 6.48. cdrs_table (str)
300 6.49. time_mode (int)
301 6.50. time_attr (str)
302 6.51. time_exten (str)
303 6.52. time_format (str)
304 6.53. reason_from_hf (int)
305 6.54. clone_msg (int)
306 6.55. cdr_on_failed (int)
310 7.1. acc_log_request(comment)
311 7.2. acc_db_request(comment, table)
312 7.3. acc_rad_request(comment)
313 7.4. acc_diam_request(comment)
319 ACC module is used to account transactions information to different
320 backends like syslog, SQL, RADIUS and DIAMETER (beta version).
322 To account a transaction and to choose which set of backends to be
323 used, the script writer just has to set some flags (see the module
324 parameters section for flag definitions Section 6, "Parameters"). If
325 the accounting flag for a specific backend is set, the acc module will
326 then report on completed transaction. A typical usage of the module
327 takes no acc-specific script command -- the functionality binds
328 invisibly through transaction processing. Script writers just need to
329 mark the transaction for accounting with proper setflag. Even so, the
330 module allows the script writter to force accounting in special cases
331 via some script functions.
333 The accounting module will log by default a fixed set of attributes for
334 the transaction - if you customize your accounting by adding more
335 information to be logged, please see the next chapter about extra
336 accounting - Section 2, "Extra accounting".
338 The fixed minimal accounting information is:
339 * Request Method name
340 * From header TAG parameter
341 * To header TAG parameter
343 * 3-digit Status code from final reply
344 * Reason phrase from final reply
345 * Time stamp when transaction was completed
347 If a value is not present in request, the empty string is accounted
351 * A single INVITE may produce multiple accounting reports -- that's
352 due to SIP forking feature.
353 * All flags related to accounting need to be set in request
354 processing route - only the "missed-call" flag may be toggled from
355 other types of routes.
356 * If a UA fails in middle of conversation, a proxy will never find
357 out about it. In general, a better practice is to account from an
358 end-device (such as PSTN gateway), which best knows about call
359 status (including media status and PSTN status in case of the
360 gateway). However, CDR-base logging has the option to log existing
361 information from expired dialogs (the dlg_vars in cdr_extra) Please
362 see cdr_expired_dlg_enable parameter - Section 6.40,
363 "cdr_expired_dlg_enable (integer)".
365 The SQL backend support is compiled in the module. For RADIUS and
366 DIAMETER you need to enable it by recompiling the module with properly
367 set defines: uncomment the RAD_ACC or DDIAM_ACC lines in
368 modules/acc/Makefile. To compile RADIUS support, you need to have
369 radiusclient-ng (only versions higher or equal to 0.5.0) installed on
370 your system which is available from
371 http://developer.berlios.de/projects/radiusclient-ng/. The radius
372 client needs to be configured properly. To do so, use the template at
373 etc/radiusclient.conf and make sure that module's radius_config
374 parameter points to its location. In particular, accounting secret must
375 match that one configured in server and proper dictionary is used (one
376 is available at etc/sip_dictionary). Also note that Debian
377 radiusclient-ng uses /var/run/radius.seq as seqfile but Kamailio Debian
378 init script expects /var/run/kamailio/kamailio_radius.seq, so is needed
379 to change it in radiusclient-ng configuration or in Kamailio Debian
380 init script (if not, Kamailio can't create the seq file when not
381 running as root). Uses along with FreeRadius (
382 http://www.freeradius.org/) and Radiator (
383 http://www.open.com.au/radiator/) servers have been reported to us.
385 NOTE: diameter support was developed for DISC (DIameter Server Client
386 project at http://developer.berlios.de/projects/disc/). This project
387 seems to be no longer maintained and DIAMETER specifications were
388 updated in the meantime. Thus, the DIAMETER part in the module is
389 obsolete and needs rework to be usable with opendiameter or other
394 loadmodule "modules/acc/acc.so"
395 modparam("acc", "log_level", 1)
396 modparam("acc", "log_flag", 1)
398 if (uri=~"sip:+40") /* calls to Romania */ {
399 if (!proxy_authorize("sip_domain.net" /* realm */,
400 "subscriber" /* table name */)) {
401 proxy_challenge("sip_domain.net" /* realm */, "0" /* no qop */ );
405 if (method=="INVITE" && !check_from()) {
406 log("from!=digest\n");
407 sl_send_reply("403","Forbidden");
410 setflag(1); /* set for accounting (the same value as in log_flag!)
411 t_relay(); /* enter stateful mode now */
417 2.2. Definitions and syntax
422 Along the static default information, ACC modules allows dynamical
423 selection of extra information to be logged. This allows you to log any
424 pseudo-variable (AVPs, parts of the request, etc).
426 2.2. Definitions and syntax
428 Selection of extra information is done via xxx_extra parameters by
429 specifying the names of additional information you want to log. This
430 information is defined via pseudo-variables and may include headers,
431 AVPs values or other message or system values. The syntax of the
433 * xxx_extra = extra_definition (';'extra_definition)*
434 * extra_definition = log_name '=' pseudo_variable
436 The full list of supported pseudo-variables in Kamailio is available
437 at: http://www.kamailio.org/wiki/cookbooks/devel/pseudovariables
439 Note: For all the ACK processed by tm, the registered callbacks (like
440 acc module) will be called with the corresponding INVITE transaction
441 contexts as long as this is still available. This means that the ACK
442 callbacks will see the AVPs setup for the INVITE transaction and not
443 the AVPs setup before t_relay().
445 Via log_name you define how/where the data will be logged. Its meaning
446 depends of the accounting support which is used:
447 * LOG accounting - log_name will be just printed along with the data
448 in log_name=data format;
449 * DB accounting - log_name will be the name of the DB column where
450 the data will be stored.IMPORTANT: add in db acc table the columns
451 corresponding to each extra data;
452 * RADIUS accounting - log_name will be the AVP name used for packing
453 the data into RADIUS message. The log_name will be translated to
454 AVP number via the dictionary. IMPORTANT: add in RADIUS dictionary
455 the log_name attribute.
456 * DIAMETER accounting - log_name will be the AVP code used for
457 packing the data into DIAMETER message. The AVP code is given
458 directly as integer, since DIAMETER has no dictionary support yet.
459 IMPORTANT: log_name must be a number.
463 Some pseudo variables may return more than one value (like headers or
464 AVPs). In this case, the returned values are embedded in a single
465 string in a comma-separated format.
467 3. Multi Call-Legs accounting
475 A SIP call can have multiple legs due forwarding actions. For example
476 user A calls user B which forwards the call to user C. There is only
477 one SIP call but with 2 legs ( A to B and B to C). Accounting the legs
478 of a call is required for proper billing of the calls (if C is a PSTN
479 number and the call is billed, user B must pay for the call - as last
480 party modifing the call destination-, and not A - as initiator of the
481 call. Call forwarding on server is only one example which shows the
482 necessity of the having an accounting engine with multiple legs
487 First how it works: The idea is to have a set of AVPs and for each call
488 leg to store a set of values in the AVPs. The meaning of the AVP
489 content is stricly decided by the script writer - it can be the origin
490 and source of the leg, its status or any other related information. If
491 you have a set of 4 AVPS (AVP1, AVP2, AVP3, AVP4), then for the "A call
492 B and B forwards to C" example, you need to set a different set of
493 values for the AVPs for each leg ([A,B] and [B,C]) . The script writer
494 must take care and properly insert all these AVP from the script (in
495 proper order and with the correct type).
497 When the accounting information for the call will be written/sent, all
498 the call-leg pairs will be added (based on the found AVP sets).
500 By default, the multiple call-leg support is disabled - it can be
501 enabled just be setting the per-leg set of AVPs via the multi_leg_info
506 For each call, all the values of the AVP set (which defines a call-leg)
507 will be logged. How the information will be actually logged, depends of
509 * syslog -- all leg-sets will be added to one record string as
510 AVP1=xxx, AVP2=xxxx ,... sets.
511 * database -- each pair will be separately logged (due DB data
512 structure constraints); several records will be written, the
513 difference between them being only the fields corresponding to the
517 You will need to add in your DB (all acc related tables) the colums
518 for call-leg info (a column for each AVP of the set).
519 * Radius -- all sets will be added to the same Radius accounting
520 message as RADIUS AVPs - for each call-leg a set of RADIUS AVPs
521 will be added (corresponding to the per-leg AVP set)
524 You will need to add in your dictionary the RADIUS AVPs used in
525 call-leg AVP set definition.
526 * Diameter same as for RADIUS.
528 4. Call Data Record generation
533 4.2.1. Definitions and syntax
535 4.3. CDR with Multi Call-Legs
540 4.3.2.1. Example for a spiraled Proxy
546 In addition to transaction-based logging, it is possible to generate
547 and log Call Data Records (CDRs) directly from Kamailio. Apart from a
548 basic set of CDR fields which are always included (covering start time,
549 end time, and duration), the approach allows flexible specification of
550 additional fields that should be taken into account using the
551 configuration script. This is very similar to how transaction-based
552 logging may be customized with the exception that CDRs rely on dialogs
553 instead of transactions to store relevant information during a call.
555 In order to set up CDR generation, you must enable the CDR switch and
556 load the dialog module. You probably also want to specify a set of
557 pseudo-variables that define more relevant CDR fields. Pseudo-variables
558 may be assigned arbitrarily during script execution, and the module
559 will make sure that the variable content will be transformed into a CDR
560 by the end of the dialog.
562 To use CDR logging in a correct manner, you should only use the
563 dialog-based pseudo-variables (dlg_var) from the dialog module. This
564 allows you to save values right from the beginning through all requests
565 and replies until termination of the call. While not recommended, it is
566 still possible to use other pseudo-variables as well. Except for
567 pseudo-variables valid in the call-final transaction, however,
568 information given will not be stored in the CDR as they cannot be
569 accessed by the end of the call when the CDR is logged.
571 Sometimes, dialogs expire because the UA has a problem and a final
572 message is never transmitted. You can toggle on/off the generation of
573 CDR-based logging in such cases with only the dlg_vars showing by using
574 the cdr_expired_dlg_enable parameter - Section 6.40,
575 "cdr_expired_dlg_enable (integer)". Default behavior is not logging.
579 This section is similar to the "LOG accounting" part of Section 2,
582 4.2.1. Definitions and syntax
584 Selection of extra information is done similar to the transaction extra
585 Section 2.2, "Definitions and syntax".
586 * cdr_extra = cdr_extra_definition (';'cdr_extra_definition)*
587 * cdr_extra_definition = cdr_log_name '=' pseudo_variable
589 See also Section 6.43, "cdr_extra (string)".
591 The full list of supported pseudo-variables in Sip-Router is available
592 at: http://sip-router.org/wiki/cookbooks/pseudo-variables/devel
594 4.3. CDR with Multi Call-Legs
598 As mentioned in Section 3, "Multi Call-Legs accounting", a leg
599 represents a parallel or forwarded call. In contrast to the normal
600 accounting the cdr logging uses dialogs instead of transaction to log
601 data. This may reduce the amount of information but it also make it
602 possible to combine all important data in one cdr at once. A second
603 mechanism to process multiple data-sets into one cdr is not further
608 When you route messages multiple times through your proxy (e.g. to
609 handle "call-forwardings") you have to use detect_spirals from the
610 dialog modules. Otherwise the proxy can't identify and reuse existing
613 To get the correct call-forwarding-chain you have to store each cf*
614 with the corresponding caller and callee in a dialog based
615 pseudo-variable (dlg_var) (e.g. chain=B;cfa;C|C;cfnr;D). Additionally
616 it is necessary to store the caller and callee for each leg. All this
617 helps to identify the involved phone parners and forwarding chain. When
618 you route such calls multiple times to the same Proxy, you could store
619 the caller and callee within an transaction based avp and write it into
620 the dialog based dlg_var pv during a 200 INVITE.
622 4.3.2.1. Example for a spiraled Proxy
625 # A calls B (transaction 1)
630 # B cfa C (transaction 2)
633 $dlg_var(chain)='B;cfu;C';
635 # C cfnr D (transaction 3)
638 $dlg_var(chain)=$dlg_var(chain) + "|" + "C;cfnr;D";
640 # C confirms call (200 reply of transaction 2)
641 $dlg_var(caller) = $avp(caller); #caller='B'
642 $dlg_var(callee) = $avp(callee); #callee='C'
647 For each call, all dialog corresponding variables will be logged. After
648 a call is finished, the generated call data record information will be
649 logged as string (VAR1=xxx,VAR2=xxxx,...) to the syslog.
653 5.1. Kamailio Modules
654 5.2. External Libraries or Applications
656 5.1. Kamailio Modules
658 The module depends on the following modules (in the other words the
659 listed modules must be loaded before this module):
660 * tm -- Transaction Manager
661 * a database module -- If SQL support is used.
662 * rr -- Record Route, if "detect_direction" module parameter is
664 * dialog -- Dialog, if "cdr_enable" module parameter is enabled.
666 5.2. External Libraries or Applications
668 The following libraries or applications must be installed before
669 running Kamailio with this module loaded:
670 * radiusclient-ng 0.5.0 or higher -- if compiled with RADIUS support.
671 See http://developer.berlios.de/projects/radiusclient-ng/.
675 6.1. early_media (integer)
676 6.2. failed_transaction_flag (integer)
677 6.3. failed_filter (string)
678 6.4. report_ack (integer)
679 6.5. report_cancels (integer)
680 6.6. detect_direction (integer)
681 6.7. acc_prepare_flag (integer)
682 6.8. acc_prepare_always (integer)
683 6.9. multi_leg_info (string)
684 6.10. log_flag (integer)
685 6.11. log_missed_flag (integer)
686 6.12. log_level (integer)
687 6.13. log_facility (string)
688 6.14. log_extra (string)
689 6.15. radius_config (string)
690 6.16. radius_flag (integer)
691 6.17. radius_missed_flag (integer)
692 6.18. service_type (integer)
693 6.19. radius_extra (string)
694 6.20. db_flag (integer)
695 6.21. db_missed_flag (integer)
696 6.22. db_table_acc (string)
697 6.23. db_table_missed_calls (string)
698 6.24. db_url (string)
699 6.25. acc_method_column (string)
700 6.26. acc_from_tag_column (string)
701 6.27. acc_to_tag_column (string)
702 6.28. acc_callid_column (string)
703 6.29. acc_sip_code_column (string)
704 6.30. acc_sip_reason_column (string)
705 6.31. acc_time_column (string)
706 6.32. db_extra (string)
707 6.33. db_insert_mode (integer)
708 6.34. diameter_flag (integer)
709 6.35. diameter_missed_flag (integer)
710 6.36. diameter_client_host (string)
711 6.37. diameter_client_port (int)
712 6.38. diameter_extra (string)
713 6.39. cdr_enable (integer)
714 6.40. cdr_expired_dlg_enable (integer)
715 6.41. cdr_start_on_confirmed (integer)
716 6.42. cdr_facility (integer)
717 6.43. cdr_extra (string)
718 6.44. cdr_start_id (string)
719 6.45. cdr_end_id (string)
720 6.46. cdr_duration_id (string)
721 6.47. cdr_log_enable (int)
722 6.48. cdrs_table (str)
723 6.49. time_mode (int)
724 6.50. time_attr (str)
725 6.51. time_exten (str)
726 6.52. time_format (str)
727 6.53. reason_from_hf (int)
728 6.54. clone_msg (int)
729 6.55. cdr_on_failed (int)
731 6.1. early_media (integer)
733 Should be early media (any provisional reply with body) accounted too ?
735 Default value is 0 (no).
737 Example 1.1. early_media example
739 modparam("acc", "early_media", 1)
742 6.2. failed_transaction_flag (integer)
744 Per transaction flag which says if the transaction should be accounted
745 also in case of failure (status>=300).
747 Default value is not-set (no flag).
749 Example 1.2. failed_transaction_flag example
751 modparam("acc", "failed_transaction_flag", 4)
754 6.3. failed_filter (string)
756 A string of failure response codes from 300 to 999 separated by commas.
757 Failed transaction will not be accounted if its response code is in the
758 list even when failed_transaction_flag is set.
760 Default value is not-set (failure filtering is off).
762 Example 1.3. failed_filter example
764 modparam("acc", "failed_filter", "404,407")
767 6.4. report_ack (integer)
769 Shall acc attempt to account e2e ACKs too ? Note that this is really
770 only an attempt, as e2e ACKs may take a different path (unless RR
771 enabled) and mismatch original INVITE (e2e ACKs are a separate
772 transaction). The flag for accounting has to be set for each ACK as
775 Default value is 0 (no).
777 Example 1.4. report_ack example
779 modparam("acc", "report_ack", 1)
782 6.5. report_cancels (integer)
784 By default, CANCEL reporting is disabled -- most accounting
785 applications wants to see INVITE's cancellation status. Turn on if you
786 explicitly want to account CANCEL transactions.
788 Default value is 0 (no).
790 Example 1.5. report_cancels example
792 modparam("acc", "report_cancels", 1)
795 6.6. detect_direction (integer)
797 Controlles the direction detection for sequential requests. If enabled
798 (non zero value), for sequential requests with upstream direction (from
799 callee to caller), the FROM and TO will be swapped (the direction will
800 be preserved as in the original request).
802 It affects all values related to TO and FROM headers (body, URI,
803 username, domain, TAG).
805 Default value is 0 (disabled).
807 Example 1.6. detect_direction example
809 modparam("acc", "detect_direction", 1)
812 6.7. acc_prepare_flag (integer)
814 Per transaction flag which says if the transaction may be accounted
815 later, with flags set in TM module specific routes (e.g., like
816 failure_route). If this flag is not set and acc or missed_call flag are
817 not set either in request route block, there is no way to mark the
818 request for transaction later unless you set acc_prepare_always. If
819 either acc or missed_call flags are set in request route block, there
820 is no need to set this flag.
822 Default value is not-set (no flag).
824 Example 1.7. acc_prepare_flag example
826 modparam("acc", "acc_prepare_flag", 5)
829 6.8. acc_prepare_always (integer)
831 Prepare all request even if acc_prepare_flag is not set to mark the
832 request for transaction later.
834 Default value is not-set (previous behaviour).
836 Example 1.8. acc_prepare_flag example
838 modparam("acc", "acc_prepare_always", 1)
841 6.9. multi_leg_info (string)
843 Defines the AVP set to be used in per-call-leg accounting. See
844 Section 3, "Multi Call-Legs accounting" for a detailed description of
845 the Multi Call-Legs accounting.
847 If empty, the multi-leg accounting support will be disabled.
849 Default value is 0 (disabled).
851 Example 1.9. multi_leg_info example
853 # for syslog-based accounting, use any text you want to be printed
854 modparam("acc", "multi_leg_info",
855 "text1=$avp(src);text2=$avp(dst)")
856 # for mysql-based accounting, use the names of the columns
857 modparam("acc", "multi_leg_info",
858 "leg_src=$avp(src);leg_dst=$avp(dst)")
859 # for RADIUS-based accounting, use the names of the RADIUS AVPs
860 modparam("acc", "multi_leg_info",
861 "RAD_LEG_SRC=$avp(src);RAD_LEG_SRC=$avp(dst)")
862 # for DIAMETER-based accounting, use the DIAMETER AVP ID (as integer)
863 modparam("acc", "multi_leg_info",
864 "2345=$avp(src);2346=$avp(dst)")
867 6.10. log_flag (integer)
869 Request flag which needs to be set to account a transaction via syslog.
871 Default value is not-set (no flag).
873 Example 1.10. log_flag example
875 modparam("acc", "log_flag", 2)
878 6.11. log_missed_flag (integer)
880 Request flag which needs to be set to account missed calls via syslog.
882 Default value is not-set (no flag).
884 Example 1.11. log_missed_flag example
886 modparam("acc", "log_missed_flag", 3)
889 6.12. log_level (integer)
891 Log level at which accounting messages are issued to syslog.
893 Default value is L_NOTICE.
895 Example 1.12. log_level example
897 modparam("acc", "log_level", 2) # Set log_level to 2
900 6.13. log_facility (string)
902 Log facility to which accounting messages are issued to syslog. This
903 allows to easily seperate the accounting specific logging from the
906 Default value is LOG_DAEMON.
908 Example 1.13. log_facility example
910 modparam("acc", "log_facility", "LOG_DAEMON")
913 6.14. log_extra (string)
915 Extra values to be logged. See section Section 2, "Extra accounting"
918 Default value is NULL.
920 Example 1.14. log_extra example
922 modparam("acc", "log_extra", "ua=$hdr(User-Agent);uuid=$avp(i:123)")
925 6.15. radius_config (string)
927 This parameter is radius specific. Path to radius client configuration
928 file, set the referred config file correctly and specify there address
929 of server, shared secret (should equal that in
930 /usr/local/etc/raddb/clients for freeRadius servers) and dictionary,
931 see etc for an example of config file and dictionary.
933 If the parameter is set to empty string, the RADIUS accounting support
934 will be disabled (even if compiled).
936 Default value is "NULL".
938 Example 1.15. radius_config example
940 modparam("acc", "radius_config", "/etc/radiusclient/radiusclient.conf")
943 6.16. radius_flag (integer)
945 Request flag which needs to be set to account a transaction -- RADIUS
948 Default value is not-set (no flag).
950 Example 1.16. radius_flag example
952 modparam("acc", "radius_flag", 2)
955 6.17. radius_missed_flag (integer)
957 Request flag which needs to be set to account missed calls -- RADIUS
960 Default value is not-set (no flag).
962 Example 1.17. radius_missed_flag example
964 modparam("acc", "radius_missed_flag", 3)
967 6.18. service_type (integer)
969 Radius service type used for accounting.
971 Default value is 15 (SIP).
973 Example 1.18. service_type example
975 modparam("acc", "service_type", 16)
978 6.19. radius_extra (string)
980 Extra values to be logged via RADIUS - RADIUS specific. See section
981 Section 2, "Extra accounting" for more details.
983 Default value is NULL.
985 Example 1.19. radius_extra example
987 modparam("acc", "radius_extra", "via=$hdr(Via[*]); email=$avp(s:email)")
990 6.20. db_flag (integer)
992 Request flag which needs to be set to account a transaction -- database
995 Default value is not-set (no flag).
997 Example 1.20. db_flag example
999 modparam("acc", "db_flag", 2)
1002 6.21. db_missed_flag (integer)
1004 Request flag which needs to be set to account missed calls -- database
1007 Default value is not-set (no flag).
1009 Example 1.21. db_missed_flag example
1011 modparam("acc", "db_missed_flag", 3)
1014 6.22. db_table_acc (string)
1016 Table name of accounting successfull calls -- database specific. It can
1017 contain config variables that will be evaluated at runtime.
1019 Default value is "acc"
1021 Example 1.22. db_table_acc example
1023 modparam("acc", "db_table_acc", "myacc_table")
1024 modparam("acc", "db_table_acc", "acc_$time(year)_$time(mon)")
1027 6.23. db_table_missed_calls (string)
1029 Table name for accounting missed calls -- database specific. It can
1030 contain config variables that will be evaluated at runtime.
1032 Default value is "missed_calls"
1034 Example 1.23. db_table_missed_calls example
1036 modparam("acc", "db_table_missed_calls", "myMC_table")
1039 6.24. db_url (string)
1041 SQL address -- database specific. If is set to NULL or emty string, the
1042 SQL support is disabled.
1044 Default value is "NULL" (SQL disabled).
1046 Example 1.24. db_url example
1048 modparam("acc", "db_url", "mysql://user:password@localhost/kamailio")
1051 6.25. acc_method_column (string)
1053 Column name in accounting table to store the request's method name as
1056 Default value is "method".
1058 Example 1.25. acc_method_column example
1060 modparam("acc", "acc_method_column", "method")
1063 6.26. acc_from_tag_column (string)
1065 Column name in accounting table to store the From header TAG parameter.
1067 Default value is "from_tag".
1069 Example 1.26. acc_from_tag_column example
1071 modparam("acc", "acc_from_tag_column", "from_tag")
1074 6.27. acc_to_tag_column (string)
1076 Column name in accounting table to store the To header TAG parameter.
1078 Default value is "to_tag".
1080 Example 1.27. acc_to_tag_column example
1082 modparam("acc", "acc_to_tag_column", "to_tag")
1085 6.28. acc_callid_column (string)
1087 Column name in accounting table to store the request's Callid value.
1089 Default value is "callid".
1091 Example 1.28. acc_callid_column example
1093 modparam("acc", "acc_callid_column", "callid")
1096 6.29. acc_sip_code_column (string)
1098 Column name in accounting table to store the final reply's numric code
1099 value in string format.
1101 Default value is "sip_code".
1103 Example 1.29. acc_sip_code_column example
1105 modparam("acc", "acc_sip_code_column", "sip_code")
1108 6.30. acc_sip_reason_column (string)
1110 Column name in accounting table to store the final reply's reason
1113 Default value is "sip_reason".
1115 Example 1.30. acc_sip_reason_column example
1117 modparam("acc", "acc_sip_reason_column", "sip_reason")
1120 6.31. acc_time_column (string)
1122 Column name in accounting table to store the time stamp of the
1123 transaction completion in date-time format.
1125 Default value is "time".
1127 Example 1.31. acc_time_column example
1129 modparam("acc", "acc_time_column", "time")
1132 6.32. db_extra (string)
1134 Extra values to be logged into database - DB specific. See section
1135 Section 2, "Extra accounting" for more details.
1137 Default value is NULL.
1139 Example 1.32. db_extra example
1141 modparam("acc", "db_extra", "ct=$hdr(Content-type); email=$avp(s:email)")
1144 6.33. db_insert_mode (integer)
1146 If set to 1, use INSERT DELAYED to add records to accounting tables
1147 when the DB driver has support for it. If no INSERT DELAYED support is
1148 offered by DB driver, then standard INSERT is used. Beware that MySQL
1149 InnoDB engine doesn't support INSERT DELAYED, thus be sure the acc
1150 tables are defined with different type (e.g., MyISAM).
1152 If set to 2, async insert is used if the db driver module has support
1153 for it and if async_workers core parameter value is greater than 0. If
1154 not, then standard INSERT is used.
1156 Default value is 0 (no INSERT DELAYED nor async insert).
1158 Example 1.33. db_insert_mode example
1160 modparam("acc", "db_insert_mode", 1)
1163 6.34. diameter_flag (integer)
1165 Request flag which needs to be set to account a transaction -- DIAMETER
1168 Default value is not-set (no flag).
1170 Example 1.34. diameter_flag example
1172 modparam("acc", "diameter_flag", 2)
1175 6.35. diameter_missed_flag (integer)
1177 Request flag which needs to be set to account missed calls -- DIAMETER
1180 Default value is not-set (no flag).
1182 Example 1.35. diameter_missed_flag example
1184 modparam("acc", "diameter_missed_flag", 3)
1187 6.36. diameter_client_host (string)
1189 Hostname of the machine where the DIAMETER Client is running --
1192 Default value is "localhost".
1194 Example 1.36. diameter_client_host example
1196 modparam("acc", "diameter_client_host", "3a_server.net")
1199 6.37. diameter_client_port (int)
1201 Port number where the Diameter Client is listening -- DIAMETER
1204 Default value is 3000.
1206 Example 1.37. diameter_client_host example
1208 modparam("acc", "diameter_client_port", 3000)
1211 6.38. diameter_extra (string)
1213 Extra values to be logged via DIAMETER - DIAMETER specific. See section
1214 Section 2, "Extra accounting" for more details.
1216 Default value is NULL.
1218 Example 1.38. diameter_extra example
1220 modparam("acc", "diameter_extra", "7846=$hdr(Content-type);7847=$avp(s:email)")
1223 6.39. cdr_enable (integer)
1225 Should CDR-based logging be enabled?
1227 0 - off (default). 1 - on.
1229 Example 1.39. cdr_enable example
1231 modparam("acc", "cdr_enable", 1)
1234 6.40. cdr_expired_dlg_enable (integer)
1236 Should CDR-based logging be enabled in case of expired dialogs?
1238 0 - off (default). 1 - on.
1240 Example 1.40. cdr_expired_dlg_enable example
1242 modparam("acc", "cdr_expired_dlg_enable", 1)
1245 6.41. cdr_start_on_confirmed (integer)
1247 Should the start time be taken from the time when the dialog is
1248 created, or when the dialog is confirmed?
1250 0 - use time of dialog creation (default). 1 - use time of dialog
1253 Example 1.41. cdr_start_on_confirmed example
1255 modparam("acc", "cdr_start_on_confirmed", 1)
1258 6.42. cdr_facility (integer)
1260 Log facility to which CDR messages are issued to syslog. This allows to
1261 easily seperate CDR-specific logging from the other log messages.
1263 Default value is LOG_DAEMON.
1265 Example 1.42. cdr_facility example
1267 modparam("acc", "cdr_facility", "LOG_DAEMON")
1270 6.43. cdr_extra (string)
1272 Set of pseudo-variables defining custom CDR fields. See Section 4.2,
1273 "CDR Extra" for more details.
1275 Default value is NULL.
1277 Example 1.43. cdr_extra example
1279 modparam("acc", "cdr_extra", "c1=$dlg_var(caller);c2=$dlg_var(callee)"
1282 6.44. cdr_start_id (string)
1284 Modifying the id which is used to store the start time.
1286 Default value is 'start_time'
1288 Example 1.44. cdr_start_id example
1290 modparam("acc", "cdr_start_id", "start")
1293 6.45. cdr_end_id (string)
1295 Modifying the id which is used to store the end time.
1297 Default value is 'end_time'
1299 Example 1.45. cdr_end_id example
1301 modparam("acc", "cdr_end_id", "end")
1304 6.46. cdr_duration_id (string)
1306 Modify the id which is used to store the duration.
1308 Default value is 'duration'
1310 Example 1.46. cdr_duration_id example
1312 modparam("acc", "cdr_duration_id", "d")
1315 6.47. cdr_log_enable (int)
1317 Control if CDR-based accounting should be written to syslog.
1319 0 - off. 1 - on (default).
1321 Example 1.47. cdr_log_enable example
1323 modparam("acc", "cdr_log_enable", 0)
1326 6.48. cdrs_table (str)
1328 Name of db table to store dialog-based CDRs.
1330 Default value is "" (no db storage for dialog-based CDRs).
1332 Example 1.48. cdrs_table example
1334 modparam("acc", "cdrs_table", "acc_cdrs")
1337 6.49. time_mode (int)
1339 Store additional value related to the time of event.
1342 * 0 - (default), save only unix timestamp for syslog and datetime for
1344 * 1 - save seconds in time_attr and microseconds in time_exten.
1345 * 2 - save seconds.miliseconds in time_attr.
1346 * 3 - save formatted time according to time_format parameter, using
1347 the output of localtime().
1348 * 4 - save formatted time according to time_format parameter, using
1349 the output of gmtime().
1351 Example 1.49. time_mode example
1353 modparam("acc", "time_mode", 1)
1356 6.50. time_attr (str)
1358 Name of the syslog attribute or database column where to store
1359 additional value related to the time of event.
1361 For db accounting, the column has to be of different types, depending
1362 on time_mode value. When time_mode is:
1363 * 1 - time_attr column has to be int.
1364 * 2 - time_attr column has to be double.
1365 * 3 - time_attr column has to be varchar(128).
1366 * 4 - time_attr column has to be varchar(128).
1368 For time_mode=1, this attribute is not written in syslog, because time
1369 value is already unix timestamp, but in db accounting time value is
1370 datetime and requires a function to get the timestamp.
1372 Example 1.50. time_attr example
1374 modparam("acc", "time_attr", "seconds")
1377 6.51. time_exten (str)
1379 Name of the syslog attribute or database column where to store extended
1380 value related to the time of event.
1382 It is used now only for time_mode=1 and database column has to be int:
1384 Example 1.51. time_exten example
1386 modparam("acc", "time_exten", "micorsecs")
1389 6.52. time_format (str)
1391 Specify the format to print the time for time_mode 3 or 4.
1393 Default value is %Y-%m-%d %H:%M:%S".
1395 Example 1.52. time_format example
1397 modparam("acc", "time_format", "%Y/%m/%d %H:%M:%S")
1400 6.53. reason_from_hf (int)
1402 Tells where to take sip_reason from. If value is 0, sip_reason is taken
1403 from status line. Otherwise, sip_reason is taken from Reason header
1404 field(s) if present. Currently only the first Reason header is used.
1408 Example 1.53. reason_from_hf
1410 modparam("acc", "reason_from_hf", 1)
1413 6.54. clone_msg (int)
1415 If set to 1, request structure from transaction is cloned temporarily
1416 in the callback to get acc attributes. It is required if you account
1417 values from SIP headers to avoid concurent access to the shared memory
1418 transaction structure, specially when accounting 1xx events. If set to
1419 0, it uses directly the shared memory structure, be sure you store all
1420 needed attributes in AVPs/XAVPs inside request route.
1424 Example 1.54. clone_msg
1426 modparam("acc", "clone_msg", 0)
1429 6.55. cdr_on_failed (int)
1431 If set to 1, the module stores the CDR for a failed dialog (calls not
1432 answered). If set to 0, those records are not stored, only those for
1437 Example 1.55. cdr_on_failed
1439 modparam("acc", "cdr_on_failed", 0)
1444 7.1. acc_log_request(comment)
1445 7.2. acc_db_request(comment, table)
1446 7.3. acc_rad_request(comment)
1447 7.4. acc_diam_request(comment)
1449 7.1. acc_log_request(comment)
1451 acc_request reports on a request, for example, it can be used to report
1452 on missed calls to off-line users who are replied 404 - Not Found. To
1453 avoid multiple reports on UDP request retransmission, you would need to
1454 embed the action in stateful processing.
1456 Meaning of the parameters is as follows:
1457 * comment - Comment to be appended. The string can contain any number
1458 of pseudo-variables.
1460 This function can be used from ANY_ROUTE.
1462 Example 1.56. acc_log_request usage
1464 acc_log_request("Some comment");
1466 $avp(reason) = "Not found";
1467 acc_log_request("$var(code) Error: $avp(reason)");
1470 7.2. acc_db_request(comment, table)
1472 Like acc_log_request, acc_db_request reports on a request. The report
1473 is sent to database at "db_url", in the table referred to in the second
1476 Meaning of the parameters is as follows:
1477 * comment - Comment to be appended. The string can contain any number
1478 of pseudo-variables.
1479 * table - Database table to be used. It can contain config variables
1480 that are evaluated at runtime.
1482 This function can be used from ANY_ROUTE.
1484 Example 1.57. acc_db_request usage
1486 acc_db_request("Some comment", "SomeTable");
1487 acc_db_request("Some comment", "acc_$time(year)_$time(mon)");
1488 acc_db_request("$var(code) Error: $avp(reason)", "SomeTable");
1491 7.3. acc_rad_request(comment)
1493 Like acc_log_request, acc_rad_request reports on a request. It reports
1494 to radius server as configured in "radius_config".
1496 Meaning of the parameters is as follows:
1497 * comment - Comment to be appended. The string can contain any number
1498 of pseudo-variables.
1500 This function can be used from ANY_ROUTE.
1502 Example 1.58. acc_rad_request usage
1504 acc_rad_request("Some comment");
1505 acc_rad_request("$var(code) Error: $avp(reason)");
1508 7.4. acc_diam_request(comment)
1510 Like acc_log_request, acc_diam_request reports on a request. It reports
1511 to the configured Diameter server.
1513 Meaning of the parameters is as follows:
1514 * comment - Comment to be appended. The string can contain any number
1515 of pseudo-variables.
1517 This function can be used from ANY_ROUTE.
1519 Example 1.59. acc_diam_request usage
1521 acc_diam_request("Some comment");
1522 acc_diam_request("$var(code) Error: $avp(reason)");
1525 Chapter 2. Frequently Asked Questions
1527 2.1. What happend with old log_fmt parameter
1528 2.2. What happend with old multi_leg_enabled parameter
1529 2.3. What happend with old src_leg_avp_id and dst_leg_avp_id parameters
1530 2.4. Where can I find more about Kamailio?
1531 2.5. Where can I post a question about this module?
1532 2.6. How can I report a bug?
1536 What happend with old log_fmt parameter
1538 The parameter became obsolete with the restructure of the data logged
1539 by ACC module (refer to the Overview chapter). For similar behaviour
1540 you can use the extra accouting (see the coresponding chapter).
1544 What happend with old multi_leg_enabled parameter
1546 The parameter becaome obsolete by the addition of the new
1547 multi_leg_info parameter. The multi-leg accouting is automatically
1548 enabled when multi_leg_info is defined.
1552 What happend with old src_leg_avp_id and dst_leg_avp_id parameters
1554 The parameter was replaced by the more generic new parameter
1555 multi_leg_info. This allows logging (per-leg) of more information than
1560 Where can I find more about Kamailio?
1562 Take a look at http://www.kamailio.org/.
1566 Where can I post a question about this module?
1568 First at all check if your question was already answered on one of our
1570 * User Mailing List -
1571 http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
1572 * Developer Mailing List -
1573 http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
1575 E-mails regarding any stable Kamailio release should be sent to
1576 <sr-users@lists.sip-router.org> and e-mails regarding development
1577 versions should be sent to <sr-dev@lists.sip-router.org>.
1579 If you want to keep the mail private, send it to
1580 <sr-users@lists.sip-router.org>.
1584 How can I report a bug?
1586 Please follow the guidelines provided at:
1587 http://sip-router.org/tracker.