[SR-Users] cdr processing questions

Евгений Голей goley_ev_sp at mail.ru
Tue Jan 9 09:49:48 CET 2018


Hello!

Regarding the second and third question.  I once did like this:

route
{
    route(checks);
    route(reqinit);
..
    route(class4);
}

route[reqinit]
{
    ....

    if (has_totag() && (uri == myself) && is_method("INVITE|ACK|BYE|UPDATE"))
    {
        if(match_dialog())
        {
            # sequential request -> obey Route indication
            if(is_method("BYE"))
            {
                t_on_reply("manage_reply_class4");
                xlog("[$ci] INFO BYE DIALOG_DID=$DLG_did DLG_lifetime=$DLG_lifetime \n");
                route(acc_stop);

            }
            else
            if(is_method("INVITE"))
            {
                xlog("[$ci] INFO Re-Invite has come for: $fU");
                if(match_dialog())
                {
                    xlog("[$ci] INFO dialog matched");
                    t_relay();
                    exit;
                }
            }
            #loose_route();
            t_relay();
            exit;
        }
        if ( is_method("ACK") ) 
        {
            if ( t_check_trans() ) 
            {
                # non loose-route, but stateful ACK; must be an ACK after 
                # a 487 or e.g. 404 from upstream server
                route(acc_stop);
                t_relay();
                exit;
            } 
            else 
            {
                # ACK without matching transaction ->
                # ignore and discard
                exit;
            }
        }
        xlog("[$ci] INFO No such dialog\n");
    }
    # handle cancel and re-transmissions
    if ( is_method("CANCEL") )
    {
        xlog("[$ci] INFO Cancel message from: $fU\n");
        if ( t_check_trans() )
        {
                        route(acc_stop);
            t_relay();
        }
        exit;
    }
}

route[class4]
{
    if is_method("INVITE")
    {
        .....
        route(acc_start);
    }
..
}

onreply_route[manage_reply_class4]
{
    
    if (is_method("INVITE") && t_check_status("200") || t_check_status("[4|5|6][0-9][0-9]") && !t_check_status("1[0-9][0-9]"))
    {
                $avp(call_time_setup) = $Ts - $avp(call_time_created_Ts);
               route(acc_update);
    }
}

route[acc_start]
{
       $avp(time_call_created) = $time(%F %T);
        $avp(call_time_created_Ts) =$Ts;
        $avp(call_fuo) = $fU;
        $avp(call_tuo) = $tU;
        $avp(call_mi) = $mi;
        avp_db_query("insert into acc (method, from_tag, callid, time, created, ruo, fuo, tuo, mi, fgw) 
                values ('$rm', '$ft', '$ci', '$avp(time_call_created)', 
                    '$avp(time_call_created)', '$avp(call_ruo)', '$avp(call_fuo)', '$avp(call_tuo)', 
                    '$avp(call_mi)', '$avp(call_gw_source)')");
}

route[acc_update]
{
    avp_db_query("select callid from acc where callid='$ci'","$avp(call_id)");
        if($avp(call_id))
        {
            avp_db_query("update acc set to_tag = '$tt', sip_code = '$rs', sip_reason = '$rr', 
                        setuptime = '$avp(call_time_setup)', tgw = '$avp(call_gw_dest)',
                        ru = '$avp(call_ru)', fu = '$fU', tu = '$tU' 
                    where callid='$ci'");
        }

}

route[acc_stop]
{
    avp_db_query("select callid from acc where callid='$ci'","$avp(call_id)");    
    if($avp(call_id))
        {
            avp_db_query("update acc set duration = '$DLG_lifetime'    where callid = '$ci'");
        }
}


>Понедельник,  8 января 2018, 0:50 +03:00 от voipspace voipspace <voipspace at yandex.com>:
>
>
>
>A few question;
>
>Firstly
>
>With mod acc and acc_cdr i see the default fields logged is only start_time, end_time, duration.
>
>This is an actual entry logged.
>
>start_time, end_time, duration
>1515353126, 1515353135, 9.660000
>Hello!
>
>Regarding the second and third question.  I once did like this:
>Why is the duration 9.660000? 
>
>It seems wrong because it is more then the difference in time
>
>1515353135 - 1515353126 = 9
>
>
>
>Secondly
>
>What is a reliable way to capture and log start time, answer time, and end time.
>How do I get the duration info. a) start time to end time. b) answer to end time. 
>
>Is there an built in variable that store this info?
>
>
>Thirdly
>
>dialog events listed as:
>
>event_route[dialog:start]
>event_route[dialog:end]
>event_route[dialog:failed]
>
>There does not seems to be a event for answer so then how to be notified when a dialog is answered?
>
>Regards
>
>_______________________________________________
>Kamailio (SER) - Users Mailing List
>sr-users at lists.kamailio.org
>https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


-- 
С уважением,
Евгений Голей
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20180109/2814d375/attachment.html>


More information about the sr-users mailing list