public function getDashboardTitleHTML($title, $time = null, $until = null) { $time_html = ''; $id = preg_replace("/[^a-z0-9]/", "", strtolower($title)); if (!empty($time)) { $time_html = "(" . Dashboard::displayTime($time); if (!empty($until)) { $time_html .= " - " . Dashboard::displayTime($until); } $time_html .= ")"; } return "<h2 id=\"{$id}\" class=\"section-title\"><a href=\"#{$id}\">{$title}</a> {$time_html}</h2>"; }
public static function render($name, $graphs, $selects = array(), $currentValues = array()) { // Necessary to do unshift-with-a-key $selects = array_reverse($selects, true); $selects['time'] = Dashboard::getTimes(); $selects = array_reverse($selects, true); // Default $currentValues['time'] = '1h'; foreach ($selects as $name => $select) { if (!empty($_GET[$name])) { $currentValues[$name] = $_GET[$name]; } else { if (!isset($currentValues[$name])) { $currentValues[$name] = null; } } } ?> <!DOCTYPE html> <html> <head> <title><?php echo $name; ?> </title> <link rel="stylesheet" type="text/css" href="css/screen.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> <script src="js/dashboard.js"></script> </head> <body id="deploy" class="dashboard"> <div id="status"></div> <form id="controls" action="<?php echo $_SERVER['PHP_SELF']; ?> "> <?php foreach ($selects as $name => $select) { echo "<select name=\"{$name}\">"; foreach ($select as $key => $value) { echo "<option value=\"{$key}\""; if ($key == $currentValues[$name]) { echo "selected"; } echo ">{$value}</option>"; } echo "</select>"; } ?> </form> <?php foreach ($graphs as $section => $items) { echo "<div class=\"graphgroup\">"; echo "<h1>" . htmlentities($section) . " (" . Dashboard::displayTime($currentValues['time']) . ")</h1>\n"; foreach ($items as $item) { $item->setTime($currentValues['time']); echo $item->getDashboardHTML(); } echo "</div>"; } ?> </body> </html> <?php }
public function getPageURLForHostnameAndCluster($hostname, $cluster) { $p = array(); $p['r'] = Dashboard::displayTime($this->time); $p['h'] = $hostname; $p['c'] = $cluster; return $this->url . '?' . http_build_query($p); }
$tabs = Dashboard::$DB_TABS; $tab_url = Dashboard::getTabUrl(__FILE__); include 'phplib/template_tabs.php'; ?> <form id="controls" action="<?php echo $_SERVER['PHP_SELF']; ?> "> <?php echo Controls::buildTimeControl($time, $times); ?> </form> <div class='section'> <?php $activity_arr = array('pgb_v2_avg_querytime', 'pgb_v2_avg_req', 'pgb_v2_cl_active', 'pgb_v2_cl_waiting', 'pgb_v2_sv_active', 'pgb_v2_sv_idle', 'pgb_v2_sv_used'); foreach ($pgbouncer_cluster_arr as &$cluster) { echo "<h2>{$cluster["name"]} pgBouncer pool status (" . Dashboard::displayTime($time) . ")</h2>"; foreach ($activity_arr as &$activity) { $g = new Graph_Ganglia($time); $g->addMetric("{$cluster["name"]}", "{$cluster["machines"]}", "{$activity}"); echo $g->getDashboardHTML('medium', GraphConstants::THREE_GRAPH_WIDTH); } } ?> </div> </body> </html>