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

2010-03-04 Thread Bogdan-Andrei Iancu
Paweł,

this can be simpler done with an external script that runs on cron and 
periodically fetch the stats you need (via opensipsctl fifo 
get_statistics), dump the values somewhere and resets them (via 
opensipsctl fifo reset_statistics - 
http://www.opensips.org/Resources/DocsCoreMi16#toc11).

The idea is to keep non-sip processing outside opensips - let opensips 
to its job with the SIP stuff and do other apps to take care of the side 
jobs (like CDRs, stats, etc).

Do you think this will work for you ?

Regards,
Bogdan

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@lists.opensips.org
 http://lists.opensips.org/cgi-bin/mailman/listinfo/users
   


-- 
Bogdan-Andrei Iancu
www.voice-system.ro


___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


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

2010-03-04 Thread Richard Revels
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:0)

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) == 5 )
$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@lists.opensips.org
 http://lists.opensips.org/cgi-bin/mailman/listinfo/users


___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


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

2010-03-04 Thread Richard Revels
Or you could do this too.  : 


On Mar 4, 2010, at 5:48 AM, Bogdan-Andrei Iancu wrote:

 Paweł,
 
 this can be simpler done with an external script that runs on cron and 
 periodically fetch the stats you need (via opensipsctl fifo 
 get_statistics), dump the values somewhere and resets them (via 
 opensipsctl fifo reset_statistics - 
 http://www.opensips.org/Resources/DocsCoreMi16#toc11).
 
 The idea is to keep non-sip processing outside opensips - let opensips 
 to its job with the SIP stuff and do other apps to take care of the side 
 jobs (like CDRs, stats, etc).
 
 Do you think this will work for you ?
 
 Regards,
 Bogdan
 
 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@lists.opensips.org
 http://lists.opensips.org/cgi-bin/mailman/listinfo/users
 
 
 
 -- 
 Bogdan-Andrei Iancu
 www.voice-system.ro
 
 
 ___
 Users mailing list
 Users@lists.opensips.org
 http://lists.opensips.org/cgi-bin/mailman/listinfo/users


___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


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

2010-03-04 Thread Bogdan-Andrei Iancu
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:0)

 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) == 5 )
 $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@lists.opensips.org
 http://lists.opensips.org/cgi-bin/mailman/listinfo/users
 


 ___
 Users mailing list
 Users@lists.opensips.org
 http://lists.opensips.org/cgi-bin/mailman/listinfo/users
   


-- 
Bogdan-Andrei Iancu
www.voice-system.ro


___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


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

2010-03-04 Thread Richard Revels
Good to remember.  Thank you.  I normally spend tons of time thinking about how 
and why I'm accessing the database and file system and no time thinking about 
how I'm manipulating variables in script.  

While we are on this subject, I've always wondered about something, but not 
enough to test it out.  I had to modify the snippet below quite a bit before 
sending it due to the fact that I use m4 and let it convert strings to integer 
named avp's.  One of the primary reasons I started using m4 was the warning in 
the docs about the speed difference of manipulating avp's with string names vs 
avp's with integer names and how using aliases on the avp's was a better idea.  
Do you know if any comparisons were ever done to quantify that difference?  I'm 
wondering if the difference between reading, then modifying 1000 avp's using 
string vs integer would be like 10 milliseconds vs 1 second or 10 milliseconds 
vs 100 milliseconds.

Like I say, this was never a big enough concern to make me test it out but if 
you know then I would like to know.  : 

Richard
 
On Mar 4, 2010, at 6:45 AM, Bogdan-Andrei Iancu wrote:

 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:0)
 
 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) == 5 )
$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@lists.opensips.org
 http://lists.opensips.org/cgi-bin/mailman/listinfo/users
 
 
 
 ___
 Users mailing list
 Users@lists.opensips.org
 http://lists.opensips.org/cgi-bin/mailman/listinfo/users
 
 
 
 -- 
 Bogdan-Andrei Iancu
 www.voice-system.ro
 
 
 ___
 Users mailing list
 Users@lists.opensips.org
 http://lists.opensips.org/cgi-bin/mailman/listinfo/users


___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


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

2010-03-04 Thread Bogdan-Andrei Iancu
Hi Richard,

definitely there is a difference , but never tried to quantify it - of 
course, we can make a simple script to loop 10 times and search for 
an AVP in a list of 100 AVPs.
But as searching for an AVP is pure CPU, the question is how relevant is 
this difference relative to a DB query duration or DNS lookup ;)

Regards,
Bogdan

Richard Revels wrote:
 Good to remember.  Thank you.  I normally spend tons of time thinking about 
 how and why I'm accessing the database and file system and no time thinking 
 about how I'm manipulating variables in script.  

 While we are on this subject, I've always wondered about something, but not 
 enough to test it out.  I had to modify the snippet below quite a bit before 
 sending it due to the fact that I use m4 and let it convert strings to 
 integer named avp's.  One of the primary reasons I started using m4 was the 
 warning in the docs about the speed difference of manipulating avp's with 
 string names vs avp's with integer names and how using aliases on the avp's 
 was a better idea.  Do you know if any comparisons were ever done to quantify 
 that difference?  I'm wondering if the difference between reading, then 
 modifying 1000 avp's using string vs integer would be like 10 milliseconds vs 
 1 second or 10 milliseconds vs 100 milliseconds.

 Like I say, this was never a big enough concern to make me test it out but if 
 you know then I would like to know.  : 

 Richard
  
 On Mar 4, 2010, at 6:45 AM, Bogdan-Andrei Iancu wrote:

   
 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:0)

 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) == 5 )
$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.

 


-- 
Bogdan-Andrei Iancu
www.voice-system.ro


___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


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

2010-03-03 Thread Bogdan-Andrei Iancu
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?

Regards,
Bogdan

Paweł Pierścionek wrote:
 Hi,

 I can update and reset stats variable from within a script. But can I access 
 it's value from the script itself?

 Pawel,
 

 ___
 Users mailing list
 Users@lists.opensips.org
 http://lists.opensips.org/cgi-bin/mailman/listinfo/users
   


-- 
Bogdan-Andrei Iancu
www.voice-system.ro


___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users


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

2010-03-03 Thread Paweł Pierścionek

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,

smime.p7s
Description: S/MIME cryptographic signature
___
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users