Ejemplo n.º 1
0
                $data = array();
                $data['stats'] = Library_Command_Factory::instance('stats_api')->stats($server['hostname'], $server['port']);
                $data['slabs'] = Library_Analysis::slabs(Library_Command_Factory::instance('slabs_api')->slabs($server['hostname'], $server['port']));
                $stats = Library_Analysis::merge($stats, $data['stats']);
                # Computing stats
                if (isset($data['slabs']['total_malloced'], $data['slabs']['total_wasted'])) {
                    $slabs['total_malloced'] += $data['slabs']['total_malloced'];
                    $slabs['total_wasted'] += $data['slabs']['total_wasted'];
                }
                $status[$server['hostname'] . ':' . $server['port']] = $data['stats'] != array() ? $data['stats']['version'] : '';
                $uptime[$server['hostname'] . ':' . $server['port']] = $data['stats'] != array() ? $data['stats']['uptime'] : '';
            }
        } elseif (isset($_GET['server']) && ($server = $_ini->server($_GET['server']))) {
            # Getting Stats & Slabs stats
            $stats = Library_Command_Factory::instance('stats_api')->stats($server['hostname'], $server['port']);
            $slabs = Library_Analysis::slabs(Library_Command_Factory::instance('slabs_api')->slabs($server['hostname'], $server['port']));
            $settings = Library_Command_Factory::instance('stats_api')->settings($server['hostname'], $server['port']);
        }
        # Stats are well formed
        if ($stats !== false && $stats != array()) {
            # Analysis
            $stats = Library_Analysis::stats($stats);
            include 'View/Stats/Stats.tpl';
        } else {
            include 'View/Stats/Error.tpl';
        }
        unset($stats);
        break;
}
# Showing footer
include 'View/Footer.tpl';
Ejemplo n.º 2
0
         # Calculating query time length
         $actual[$server['hostname'] . ':' . $server['port']]['query_time'] = max((microtime(true) - $time) * 1000, 1);
     }
     # Analysing stats
     foreach ($_ini->cluster($cluster) as $server) {
         # Making an alias
         $server = $server['hostname'] . ':' . $server['port'];
         # Diff between old and new dump
         $stats[$server] = Library_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_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'];
         }
     }
     # Saving new stats dump
     file_put_contents($file_path, serialize($actual));
     # Showing stats
     include 'View/LiveStats/Stats.tpl';
     break;
     # Default : No command
 # Default : No command