$time = 0; # Requesting stats for each server foreach ($_ini->cluster($cluster) as $name => $server) { # Start query time calculation $time = microtime(true); # Asking server for stats $actual[$name] = Library_Command_Factory::instance('stats_api')->stats($server['hostname'], $server['port']); # Calculating query time length $actual[$name]['query_time'] = max((microtime(true) - $time) * 1000, 1); } # Analysing stats foreach ($_ini->cluster($cluster) as $name => $server) { # Making an alias @FIXME Used ? $server = $name; # Diff between old and new dump $stats[$server] = Library_Data_Analysis::diff($previous[$server], $actual[$server]); } # Making stats for each server foreach ($stats as $server => $array) { # Analysing request if (isset($stats[$server]['uptime']) && $stats[$server]['uptime'] > 0) { # Computing stats $stats[$server] = Library_Data_Analysis::stats($stats[$server]); # Because we make a diff on every key, we must reasign some values $stats[$server]['bytes_percent'] = sprintf('%.1f', $actual[$server]['bytes'] / $actual[$server]['limit_maxbytes'] * 100); $stats[$server]['bytes'] = $actual[$server]['bytes']; $stats[$server]['limit_maxbytes'] = $actual[$server]['limit_maxbytes']; $stats[$server]['curr_connections'] = $actual[$server]['curr_connections']; $stats[$server]['query_time'] = $actual[$server]['query_time']; } }