[OpenSIPS-Users] $rl_count in 2.2.2
Pat Burke
pat at voxtelesys.com
Fri Jan 13 12:55:33 EST 2017
Hi Răzvan,
Thanks. That worked correctly. I figured it was simple.
Thanks again,
Pat
Hi, Pat! The way you are using $rl_count is wrong, because the $rl_count pseudo variable only accepts strings or other pvars, not formatted strings (such as "cps_$avp(trunk_group)"). To achieve what you are trying to do is to assign the name to a pvar and feed it in the $rl_count's name: $var(rl_name) = "cps_" + $avp(trunk_group); $json(call_details/tg_cps) = $rl_count($var(rl_name)); Let me know how this goes. Best regards, Răzvan Crainea OpenSIPS Solutions www.opensips-solutions.com On 01/13/2017 12:48 AM, Pat Burke wrote: > Hello, >> I am trying to get the current rate limit value using $rl_count, but > it is giving the following error. > ERROR:ratelimit:pv_get_rl_count: invalid name > WARNING:core:do_assign: no value in right expression at > /etc/opensips/opensips_proxy.cfg:598 > 4024438929 SCRIPT:CCLIMIT:INFO: rl_limit for cps_90761 = 0 >> Here is the code >>
$json(call_details/tg_cps) = 0; # Default to 0 >> ... >> if ($avp(maxcps) != NULL && $avp(maxcps) > 0) { > if (!rl_check("cps_$avp(trunk_group)", "$avp(maxcps)")) { > xlog("L_NOTICE", "$rU SCRIPT:CPSLIMIT:DBG: Max > $avp(maxcps) cps reached for trunk group $avp(trunk_group) \n"); > $avp(error_reason) = $avp(error_reason) + > $avp(trunk_group) + " CPS limit reached."; > send_reply("403", "Max CPS limit reached"); > exit; > } > } > $json(call_details/tg_cps) = $rl_count("cps_$avp(trunk_group)"); > xlog("L_INFO", "$rU SCRIPT:CCLIMIT:INFO: rl_limit for > cps_$avp(trunk_group) = $json(call_details/tg_cps) \n"); >>> From the command opensipsctl fifo rl_list | grep cps_90761, I get > PIPE:: id=cps_90761 algorithm=TAILDROP limit=2 counter=0 >> What am I missing? >> Regards, > *Pat Burke* >>>>
_______________________________________________ > Users mailing list > Users at lists.opensips.org> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20170113/c1cfeb55/attachment.html>
More information about the Users
mailing list