[SR-Users] Handling quota/call limits - kamailio 1.5

Graham Wooden graham at g-rock.net
Sat Oct 1 03:08:38 CEST 2011


Hi there,

Finally getting around to introducing some call limits and starting with the
inbound calls.  However, I ran into an issue about how to get the "in use"
count to be updated in my quota table.

What is the best way to get s:in_use to update so it can be calculated?
Here is my snippet of code:

if (is_method("INVITE")) {
    avp_db_query("select quota, in_use from quota where
username='$rU'","$avp(s:quota);$avp(s:in_use)");
                   
    if ($avp(s:in_use) >= $avp(s:quota)){
        xlog ("DEBUG: Trunk $rU is over quota");
        sl_send_reply("503","User over quota");
    }
.
.
} 


This opens up two more questions: How to decrease the call count when a BYE
is received - maybe do a subtraction and the do a avp_db_query to update the
table? 

And of course there is the BYE that won't be present (ie. When a call just
rings and hangs up before it gets answered). Maybe ACC's missed_calls can
somewhat be used to help determine?

Thanks for any pointers and guidance.  I am running Kamailio 1.5.

Thanks,

-graham





More information about the sr-users mailing list