<?php include_once "./eval_conf.php"; include_once "./functions.php"; retrieve_metrics_cache(); ///////////////////////////////////////////////////////////////////////////// // With Mobile view we are gonna utilize the capability of putting in // multiple pages in the same payload so that we avoid HTTP round trips ///////////////////////////////////////////////////////////////////////////// ?> <!DOCTYPE html> <html> <head> <title>Ganglia Mobile</title> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes"> <link rel="stylesheet" href="css/jquery.mobile-1.0.min.css" /> <script src="js/jquery-1.7.1.min.js"></script> <script src="js/jquery.mobile-1.0.min.js"></script> <script type="text/javascript" src="js/jquery.liveSearch.js"></script> <link type="text/css" href="css/jquery.liveSearch.css" rel="stylesheet" /> <style> .ui-mobile .ganglia-mobile { background: #e5e5e5 top center repeat-x; } h2 { margin-top:1.5em; } p code { font-size:1.2em; font-weight:bold; } dt { font-weight: bold; margin: 2em 0 .5em; } dt code, dd code { font-size:1.3em; line-height:150%; } </style> </head> <body> <?php // Build cluster array. So we know if there is more than 1
function build_aggregate_graph_config($graph_type, $line_width, $hreg, $mreg, $glegend, $exclude_host_from_legend_label) { global $conf, $index_array, $hosts, $grid, $clusters, $debug, $metrics; retrieve_metrics_cache(); $color_count = sizeof($conf['graph_colors']); $graph_config["report_name"] = isset($mreg) ? sanitize(implode($mreg)) : NULL; $graph_config["title"] = isset($mreg) ? sanitize(implode($mreg)) : NULL; $graph_config["glegend"] = isset($glegend) ? sanitize($glegend) : "show"; $counter = 0; /////////////////////////////////////////////////////////////////////////// // Find matching hosts foreach ($hreg as $key => $query) { foreach ($index_array['hosts'] as $key => $host_name) { if (preg_match("/{$query}/i", $host_name)) { // We can have same hostname in multiple clusters $matches[] = $host_name . "|" . $index_array['cluster'][$host_name]; } } } if (isset($mreg)) { // Find matching metrics foreach ($mreg as $key => $query) { foreach ($index_array['metrics'] as $key => $m_name) { if (preg_match("/{$query}/i", $key, $metric_subexpr)) { if (isset($metric_subexpr) && count($metric_subexpr) > 1) { $legend = array(); for ($i = 1; $i < count($metric_subexpr); $i++) { $legend[] = $metric_subexpr[$i]; } $metric_matches[$key] = implode(' ', $legend); } else { $metric_matches[$key] = $key; } } } } ksort($metric_matches); } if (isset($metric_matches)) { $metric_matches_unique = array_unique($metric_matches); } else { $metric_matches_unique = array($metric_name => $metric_name); } if (isset($matches)) { $matches_unique = array_unique($matches); // Create graph_config series from matched hosts and metrics foreach ($matches_unique as $key => $host_cluster) { $out = explode("|", $host_cluster); $host_name = $out[0]; $cluster_name = $out[1]; foreach ($metric_matches_unique as $m_name => $legend) { // We need to cycle the available colors $color_index = $counter % $color_count; // next loop if there is no metric for this hostname if (!in_array($host_name, $index_array['metrics'][$m_name])) { continue; } $label = ''; if ($exclude_host_from_legend_label) { $label = $legend; } else { if ($conf['strip_domainname'] == True) { $label = strip_domainname($host_name); } else { $label = $host_name; } if (isset($metric_matches) and sizeof($metric_matches_unique) > 1) { $label .= " {$legend}"; } } $graph_config['series'][] = array("hostname" => $host_name, "clustername" => $cluster_name, "metric" => $m_name, "color" => $conf['graph_colors'][$color_index], "label" => $label, "line_width" => $line_width, "type" => $graph_type); $counter++; } } } return $graph_config; }
cache: false, data: params + "&embed=1" , success: function(data) { $("#aggregate_graph_display").html(data); }}); return false; } $(function() { var availablemetrics = [ <?php require_once './eval_conf.php'; require_once './functions.php'; $available_metrics = array(); retrieve_metrics_cache("metric_list"); asort($index_array['metrics']); foreach ($index_array['metrics'] as $key => $value) { $available_metrics[] = "\"{$value}\""; } print join(",", $available_metrics); unset($available_metrics); ?> ]; $( ".ag_buttons" ).button(); $( "#graph_type_menu" ).buttonset(); $( "#graph_legend_menu" ).buttonset(); $("#hreg").change(function() { $.cookie("ganglia-aggregate-graph-hreg" + window.name,