From a9d82aabc5a9f3553d2fda108784fa64d75f2f7d Mon Sep 17 00:00:00 2001 From: Matija Turk Date: Fri, 13 Sep 2024 17:58:11 +0200 Subject: [PATCH] database cdr working need to rafine and syslog still not working --- kamailio.cfg | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/kamailio.cfg b/kamailio.cfg index 931fdd1..7d2a21e 100644 --- a/kamailio.cfg +++ b/kamailio.cfg @@ -28,6 +28,7 @@ loadmodule "db_flatstore.so" cfgengine "native" fork=yes children=4 +#debug=3 log_facility=LOG_LOCAL0 log_prefix="{$mt $hdr(CSeq) $ci} " # RTPProxy settings @@ -54,30 +55,33 @@ modparam("uac","auth_realm_avp","$avp(arealm)") # TM settings modparam("tm", "auto_inv_100_reason", "Trying") # CDR STUFF -#!define FLD_DLG 4 +#!define DLG_FLAG 4 #!define FLT_ACC 5 #!define FLT_ACCMISSED 6 #!define FLT_ACCFAILED 7 -#!define FLT_ACCDB 7 -#modparam("dialog", "dlg_flag", FLD_DLG) +modparam("dialog", "dlg_flag", DLG_FLAG) -modparam("acc", "db_url", "flatstore:/var/log/cdrs") -modparam("acc", "early_media", 0) -modparam("acc", "report_ack", 0) -modparam("acc", "report_cancels", 0) -modparam("acc", "detect_direction", 0) -modparam("acc", "db_flag", FLT_ACCDB) -modparam("acc", "log_flag", FLT_ACC) -modparam("acc", "log_level", 3) -modparam("acc", "log_missed_flag", FLT_ACCMISSED) -modparam("acc","cdr_extra","src_user=$fU;src_domain=$fd;src_ip=$si;dst_user=$rU;dst_ouser=$tU;dst_domain=$rd;sip_code=$rs;sip_reason=$rr;callid=$dlg(callid);dst_ip=$Ri") -modparam("acc","log_extra","src_user=$fU;src_domain=$fd;src_ip=$si;dst_user=$rU;dst_ouser=$tU;dst_domain=$rd;sip_code=$rs;sip_reason=$rr;callid=$dlg(callid);dst_ip=$Ri") -modparam("acc", "failed_transaction_flag", FLT_ACCFAILED) +# ACC +# -- cdr accounting to database +#modparam("acc", "db_extra", "from_user=$fU; from_domain=$fd; src_ip=$si; ruri_user=$rU; ruri_domain=$rd ; callid=$ci; cidhash=$dlg_var(cidhash)") +#modparam("acc", "cdr_extra","src_user=$fU;src_domain=$fd;src_ip=$si;dst_user=$rU;dst_ouser=$tU;dst_domain=$rd;sip_code=$rs;sip_reason=$rr;callid=$dlg(callid);dst_ip=$Ri") +# -- cdr accounting to database +modparam("acc", "db_url", "flatstore:/var/log/acc") +modparam("acc", "cdrs_table", "kam_users_cdrs") modparam("acc", "cdr_enable", 1) +modparam("acc", "cdr_skip", "nocdr") +modparam("acc", "cdr_extra_nullable", 1) modparam("acc", "cdr_log_enable", 1) +modparam("acc", "cdr_on_failed", 1) +modparam("acc", "cdr_expired_dlg_enable", 1) modparam("acc", "cdr_start_on_confirmed", 1) -modparam("acc", "log_facility", "LOG_LOCAL0") -modparam("acc", "cdr_facility", "LOG_LOCAL0") +modparam("acc", "cdr_facility", "LOG_LOCAL2") +modparam("acc", "cdr_extra","src_user=$fU;src_domain=$fd;src_ip=$si;dst_user=$rU;dst_ouser=$tU;dst_domain=$rd;sip_code=$rs;sip_reason=$rr;callid=$dlg(callid);dst_ip=$Ri") + +# DIALOG +modparam("dialog", "dlg_flag", DLG_FLAG) +modparam("dialog", "dlg_match_mode", 1) +modparam("dialog", "enable_stats", 1) /* Main SIP request routing logic * - processing of any incoming SIP request starts with this route @@ -142,15 +146,14 @@ route[RELAY] { } if (is_method("INVITE")) { if(!t_is_set("failure_route")) t_on_failure("MANAGE_FAILURE"); + setflag(DLG_FLAG); + setflag(FLT_ACC); # do accounting + setflag(FLT_ACCFAILED); # even if the transaction fails } # Force RTPENGINE if (is_method("INVITE")) { rtpengine_manage("replace-origin replace-session-connection force-relay"); } - # Start writing CDRs - setflag(FLD_DLG); - setflag(FLT_ACC); - setflag(FLT_ACCDB); # update $du to set the destination address for proxying based on caller IP if ($siz==$avp(sip1) || $siz==$avp(sip2)) { $du = "sip:" + $avp(customerpbxip);