Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

use regular expression for metric at aggregate graphs #27

Merged
merged 1 commit into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 30, 2011
  1. @koebi001
This page is out of date. Refresh to see the latest.
Showing with 59 additions and 21 deletions.
  1. +2 −2 ganglia-web/aggregate_graphs.php
  2. +57 −19 ganglia-web/graph.php
View
4 ganglia-web/aggregate_graphs.php
@@ -69,8 +69,8 @@ function createAggregateGraph() {
<td>Host Regular expression e.g. web-[0,4], web or (web|db):</td>
<td colspan=2><input name="hreg[]" id="hreg" size=60></td>
<tr>
-<tr><td>Metric (not a report e.g. load_one, cpu_system):</td>
-<td colspan=2><input name="m" id="metric_chooser"></td>
+<tr><td>Metric Regular expression (not a report e.g. load_one, bytes_(in|out)):</td>
+<td colspan=2><input name="mreg[]" id="metric_chooser"></td>
</tr>
<tr>
<td>Graph Type:</td><td>
View
76 ganglia-web/graph.php
@@ -1,5 +1,5 @@
<?php
-/* $Id: graph.php 2583 2011-04-27 19:35:48Z bernardli $ */
+/* $Id: graph.php 2591 2011-05-10 13:42:54Z vvuksan $ */
include_once "./eval_conf.php";
include_once "./get_context.php";
include_once "./functions.php";
@@ -234,35 +234,73 @@
}
}
+ if( isset($_GET['mreg'])){
+ // Find matching metrics
+ foreach ( $_GET['mreg'] as $key => $query ) {
+ foreach ( $index_array['metrics'] as $key => $m_name ) {
+ if ( preg_match("/$query/i", $key ) ) {
+ $metric_matches[] = $key;
+ }
+ }
+ }
+ }
+ if( isset($metric_matches)){
+ $metric_matches_unique = array_unique($metric_matches);
+ }
+ else{
+ $metric_matches_unique = array($metric_name);
+ }
+ if( !isset($metric_name)){
+ if( sizeof($metric_matches_unique)==1){
+ $graph_config["report_name"]=$metric_matches_unique[0];
+ $graph_config["title"]=$metric_matches_unique[0];
+ }
+ else{
+ $graph_config["report_name"]=isset($_GET["mreg"]) ? implode($_GET["mreg"]) : NULL;
+ $graph_config["title"]=isset($_GET["mreg"]) ? implode($_GET["mreg"]) : NULL;
+ }
+ }
+
if ( isset($matches)) {
- $matches_unique = array_unique($matches);
-
- // Create graph_config series from matched hosts
- foreach ( $matches_unique as $key => $host_cluster ) {
+ $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 $key => $m_name ) {
+
// We need to cycle the available colors
$color_index = $counter % $color_count;
-
- $out = explode("|", $host_cluster);
-
- $host_name = $out[0];
- $cluster_name = $out[1];
- $label = '';
+ // next loop if there is no metric for this hostname
+ if( !in_array($host_name, $index_array['metrics'][$m_name]))
+ continue;
+
+ $label = '';
if ($conf['strip_domainname'] == True )
- $label = strip_domainname($host_name);
+ $label = strip_domainname($host_name);
else
- $label = $host_name;
-
+ $label = $host_name;
+ if( isset($metric_matches) and sizeof($metric_matches_unique)>1)
+ $label.=" $m_name";
+
$graph_config['series'][] = array ( "hostname" => $host_name , "clustername" => $cluster_name,
- "metric" => $metric_name, "color" => $colors[$color_index], "label" => $label, "line_width" => $line_width, "type" => $graph_type);
- $counter++;
-
+ "metric" => $m_name, "color" => $colors[$color_index], "label" => $label, "line_width" => $line_width, "type" => $graph_type);
+
+ $counter++;
+
}
-
+ }
+
}
#print "<PRE>"; print_r($graph_config); exit(1);
-
+
}
//////////////////////////////////////////////////////////////////////////////
Something went wrong with that request. Please try again.