[Kamailio-Devel] calculating average statistics

Klaus Darilion klaus.mailinglists at pernau.at
Wed Aug 27 16:15:23 CEST 2008


Hi Juha!

How do you calculate average?

What about having 4 variables e.g. for DNS response times:
dns_query_max
dns_query_min
dns_query_total (sum of all dns response times)
dns_query_count

If average value is needed, either the module calculates it 
(dns_query_total / dns_query_count) or the module provides the plain 
values and e.g. kamctl does the calculation.

regards
klaus

Juha Heinanen schrieb:
> it turned out that average stat cannot be easily calculated, because
> simple moving average favors old values and is therefore not very
> useful.  a weighted or exponential average implementation, on the other
> hand, would require storing also values of older values, which would be
> too costly.
> 
> after average dead end, i tried to add min_update and max_update stats
> macros.  they work fine, but if i try to initialize min stats variable
> in mod_init, kamailio does not start at all:
> 
> update_min(peering_min_verify_dst_delay, MAX_UINT);
> 
> if i comment the above line, kamalio starts fine.  could it be that
> module's statistics variables are not processed yet, when mod_init is
> executed?
> 
> what comes to kamailio statistics in general,  it is like i mentioned in
> my previous message: current statistics implementation does not support
> anything else but counter statistics, which i consider a big
> limitation.  
> 
> other statistics (like min/max) could be supported, but it requires that
> atomic and non-atomic stuff is activated at the same time.
> unfortunately also value field in struct stat_var is atomic/non-atomic
> dependent:
> 
> #ifdef NO_ATOMIC_OPS
> typedef unsigned int stat_val;
> #else
> typedef atomic_t stat_val;
> #endif
> 
> this means that even if you have a non-atomic implementation of some
> stats, it has to use on i386 architecture atomic value representation.
> in theory, one could add both in the union, but that would mean even
> bigger changes in statistics implementation.
> 
> in summary, current statistics implementation becomes a mess if one
> tries to implement other stats than counters and i, as a simple module
> programmer, may not be the right person to clean the mess up.
> 
> -- juha
> 
> _______________________________________________
> Devel mailing list
> Devel at lists.kamailio.org
> http://lists.kamailio.org/cgi-bin/mailman/listinfo/devel



More information about the Devel mailing list