[SR-Users] call count / and work with despatcher

jaflong jaflong jaflong at yandex.com
Wed May 25 01:37:32 CEST 2016


Hi Everyone,

What is a accurate way to get current call count. I am only relaying calls.

Initialy I tried the code below. It seemed to work, it reported the correct number of calls I had dialed. I get the result  through kamcmd htable get command.


------------------------------------------
under route[RELAY]
#
# COUNT
#
if (is_method("BYE")) {
        $var(n) = $shtdec(callcount=>active);
        sht_rm_name_re("callcount=>$ft");
}

--------------------------------------------

# Manage incoming replies
onreply_route[MANAGE_REPLY] {
        #
        # COUNT
        #
        if (status=="200") {
                if (is_method("INVITE")) {
                        # On start
                        if($sht(callcount=>active) == $null) {
                                $sht(callcount=>active) = 0;
                        }
                        # New call
                        if ($sht(callcount=>$ft::from_tag)== $null) {
                                $sht(callcount=>$ft::from_tag) = $ft;
                                $var(n) = $shtinc(callcount=>active);
                        }
                }
                xlog("L_INFO", "This is a 200 OK reply\n");
        }

        xdbg("incoming reply\n");
        if(status=~"[12][0-9][0-9]") {
                route(NATMANAGE);
        }
}

-------------------------------------------------------

However I wanted to distribute calls to several servers

I further added the despatcher  code below

# round robin dispatching on gateways group '1'

        if(!ds_select_dst("1", "4")) {
                send_reply("404", "No destination");
                exit;
        } 
        xlog("L_INFO", "-----RELAYING going to <$ru> via <$du> time [$Tf] -----\n");


This makes my counting code above give incorrect call count.

How can I make call count work with dispatcher ? Do advise how I can do this

Regards 



More information about the sr-users mailing list