[OpenSIPS-Users] Access to statistics variables from within script
Bogdan-Andrei Iancu
bogdan at voice-system.ro
Thu Mar 4 12:45:56 CET 2010
Hi Richard,
1 important comment here - the global vars are something more powerful
than statistic vars. And of course, they come with more penalties.
Operating with the global vars requires internal locking (over the
variable) - this may lead to a general slowdown of opensips as all the
procs will keep syncronizing over the lock for the this vars. The stat
vars are using atomic ops (internally) and they do not require locking.
just my 2 cents on this,
Bogdan
Richard Revels wrote:
> Most likely this is where Bogdan is headed but, if you only want to increment and reset some variables in the script there are global vars available to do that with. cfgutils module.
>
> #first a var that is shared across all processes
> modparam("cfgutils", "shvset", "didtracker=i:0")
>
> #now one that will be unique to each process thread
> modparam("cfgutils", "varset", "threadtracker=s:00000")
>
> Then in the script to, say, randomly select a from user:
>
> $avp(s:newfromheader) = $hdr(From);
> $avp(s:holder)=$shv(didtracker);
> $shv(didtracker)=$shv(didtracker) + 1;
> if( $shv(didtracker) == 50000 )
> $shv(didtracker)=0;
> $avp(s:offset)= 5 - $(avp(s:holder){s.len});
> $var(matchup)=$(var(threadtracker){s.substr,0,$avp(s:offset)}) + $avp(s:holder);
> if( dp_translate("42", "$var(matchup)/$var(matchup)") )
> {
> $avp(s:newfromheader) = "sip:" + $var(matchup) + "@" + $fd; #this could change again for oli tag or something so
> setflag(FLAG_CHANGED_FROMHEADER); #use flag to insure we only change from header once in t_relay route
> }
>
>
> Richard
>
> On Mar 3, 2010, at 7:56 PM, Paweł Pierścionek wrote:
>
>
>> On 2010-03-03, at 19:20, Bogdan-Andrei Iancu wrote:
>>
>>
>>> Hi Pawel,
>>>
>>> for read, the stats vars are available only via the MI interface (the
>>> get_statistics function).
>>>
>>> do you want to read the stats from the statistics module only, or all of
>>> them?
>>>
>> Nah, only the ones defined in my script/statistics module and log/print them and reset them in a timer route.
>>
>> Pawel,_______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
--
Bogdan-Andrei Iancu
www.voice-system.ro
More information about the Users
mailing list