[SR-Users] collecting statistics

Daniel-Constantin Mierla miconda at gmail.com
Thu Mar 15 12:24:33 CET 2012



On 3/15/12 12:02 PM, Klaus Darilion wrote:
> On 15.03.2012 11:49, Daniel-Constantin Mierla wrote:
>> Hello,
>>
>> On 3/15/12 9:23 AM, Klaus Darilion wrote:
>>> Hi!
>>>
>>> I want to collect statistics on a load-balancer, e.g. how many
>>> NOTIFYs, SUBSCRIBEs, ... and the respective response codes, e.g.
>>> NOTIFYs-200, NOTIFYs-408,...., response time from the backend-servers,
>>> ...
>>>
>>> Further I want to do this separately for each backend-server in the
>>> cluster, i.e. for every IP address in the dispatcher list.
>>>
>>> Built in statistics or not detailed enough, so thought of implementing
>>> the counting and measuring in script using htable and a periodic timer
>>> which dumps the htable values to log file.
>>>
>>> Thus, I will end up with lots of code, especially for dumping I have
>>> to address all possible keys manually:
>>>
>>> e.g. request route:
>>> $var(key) = $rm + "::" + $dd;
>>> $sht(stat=>$var(key)) = $sht(stat=>$var(key)) + 1;
>>>
>>> e.g. reply route:
>>> if ($rs != "200" && $rs != "480" ) {
>>> $var(key) = $rm + "::" + $si + "::XXX";
>>> } else {
>>> $var(key) = $rm + "::" + $si + "::" + $rs;
>>> }
>>> $sht(stat=>$var(key)) = $sht(stat=>$var(key)) + 1;
>>>
>>> e.g. dumping:
>>> xlog("PUBLISH::83.136.32.169=$sht(stat=>PUBLISH::83.136.32.169)");
>>> $sht(stat=>PUBLISH::83.136.32.169)=0;
>>> xlog("PUBLISH_200::83.136.32.169=$sht(stat=>PUBLISH_200::83.136.32.169)"); 
>>>
>>>
>>> $sht(stat=>PUBLISH_200::83.136.32.169)=0;xlog("PUBLISH_480::83.136.32.169=$sht(stat=>PUBLISH_480::83.136.32.169)"); 
>>>
>>>
>>> $sht(stat=>PUBLISH_480::83.136.32.169)=0;
>>> xlog("PUBLISH_XXX::83.136.32.169=$sht(stat=>PUBLISH_XXX::83.136.32.169)"); 
>>>
>>>
>>> $sht(stat=>PUBLISH_XXX::83.136.32.169)=0;
>>>
>>>
>>> It works, but is not very nice, IMO. Thus, I wonder if someone has a
>>> better, more elegant way to achieve this.
>> I use htable for similar stats, but I pull them via mi/rpc commands -- a
>> whole table can be dumped at once.
>
> How do you reset the counters? I couldn't find a MI command for that.
>
I keep timestamp (or sequence number) of the dump and do diffs. Do you 
need reset for other purposes?

Maybe you can do it, like setting the htable to load from an empty db 
table, don't write back there, and after dump do a db reload via mi, but 
it is not atomic.

Cheers,
Daniel

-- 
Daniel-Constantin Mierla
Kamailio Advanced Training, April 23-26, 2012, Berlin, Germany
http://www.asipto.com/index.php/kamailio-advanced-training/




More information about the sr-users mailing list