Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Eliminate hostname as a metric

  • Loading branch information...
commit 5c188d34660b30a3812cb2e39740fb755380f81e 1 parent 57ad99c
@vvuksan vvuksan authored
Showing with 20 additions and 14 deletions.
  1. +2 −1  ganglia.php
  2. +18 −13 search.php
View
3  ganglia.php
@@ -199,7 +199,8 @@ function start_everything ($parser, $tagname, $attrs)
case "METRIC":
$metricname = $attrs['NAME'];
- $index_array['metrics'][$metricname][] = $hostname;
+ if ( $metricname != $hostname )
+ $index_array['metrics'][$metricname][] = $hostname;
break;
default:
View
31 search.php
@@ -8,24 +8,29 @@
$query = $_GET['q'];
$results = "";
-// First we look for the hosts
-foreach ( $index_array['hosts'] as $key => $host_name ) {
- if ( preg_match("/$query/", $host_name ) ) {
- $cluster_name = $index_array['cluster'][$host_name];
- $results .= "Host: <a target=\"_blank\" href=\"?c=" . $cluster_name . "&h=" . $host_name . "&m=cpu_report&r=hour&s=descending&hc=4&mc=2\">" . $host_name . "</a><br>";
+if ( $query != "" ) {
+
+ // First we look for the hosts
+ foreach ( $index_array['hosts'] as $key => $host_name ) {
+ if ( preg_match("/$query/", $host_name ) ) {
+ $cluster_name = $index_array['cluster'][$host_name];
+ $results .= "Host: <a target=\"_blank\" href=\"?c=" . $cluster_name . "&h=" . $host_name . "&m=cpu_report&r=hour&s=descending&hc=4&mc=2\">" . $host_name . "</a><br>";
+ }
}
-}
-// Now let's look through metrics.
-foreach ( $index_array['metrics'] as $metric_name => $hosts ) {
- if ( preg_match("/$query/", $metric_name ) ) {
- $cluster_name = $index_array['cluster'][$host_name];
- foreach ( $hosts as $key => $host_name ) {
- $results .= "Metric: <a target=\"_blank\" href=\"?c=" . $cluster_name . "&h=" . $host_name . "&m=cpu_report&r=hour&s=descending&hc=4&mc=2#metric_" . $metric_name . "\">" . $host_name . " (" . $metric_name . " )</a><br>";
+ // Now let's look through metrics.
+ foreach ( $index_array['metrics'] as $metric_name => $hosts ) {
+ if ( preg_match("/$query/", $metric_name ) ) {
+ $cluster_name = $index_array['cluster'][$host_name];
+ foreach ( $hosts as $key => $host_name ) {
+ $results .= "Metric: <a target=\"_blank\" href=\"?c=" . $cluster_name . "&h=" . $host_name . "&m=cpu_report&r=hour&s=descending&hc=4&mc=2#metric_" . $metric_name . "\">" . $host_name . " (" . $metric_name . " )</a><br>";
+ }
}
}
-}
+} else {
+ $results .= "Empty query string";
+}
if ( $results == "" ) {
print "No results. Try a different search term. Currently only one search term supported.";
Please sign in to comment.
Something went wrong with that request. Please try again.