[OpenSIPS-Users] Access to statistics variables from within script

Richard Revels rrevels at bandwidth.com
Thu Mar 4 12:37:33 CET 2010


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




More information about the Users mailing list