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.
Cheers,
Daniel
--
Daniel-Constantin Mierla
Kamailio Advanced Training, April 23-26, 2012, Berlin, Germany
http://www.asipto.com/index.php/kamailio-advanced-training/