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.
Thanks Klaus