Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 97 lines (76 sloc) 2.733 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
<?php
include_once("./global.php");

$tpl = new Dwoo_Template_File( template("compare_hosts.tpl") );
$data = new Dwoo_Data();
$data->assign("range",$range);

$size = isset($clustergraphsize) ? $clustergraphsize : 'default';
//set to 'default' to preserve old behavior
$size = $size == 'medium' ? 'default' : $size;

retrieve_metrics_cache();

$matches = array();
if (array_key_exists('hreg', $_GET)) {
  foreach ( $_GET['hreg'] as $key => $query ) {
    if ($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[] =
            array ("hostname" => $host_name,
                   "clustername" => $index_array['cluster'][$host_name]);
        }
      }
    }
  }
}

#print "<PRE>";print_r($index_array['metrics']);

$host_metrics = array();
$host_cluster = array();
foreach ( $matches as $index => $match ) {
  $hostname = $match['hostname'];
  $host_cluster[] = $match['hostname'] . "|" . $match['clustername'];
  foreach ( $index_array['metrics'] as $metric_name => $hosts ) {
    if ( array_search( $hostname , $hosts ) !== FALSE &&
         ! isset($host_metrics[$metric_name]) ) {
      $host_metrics[$metric_name] = 1;
    }
  }
}

# Join the hosts in a list into a string which we pass to graphs
$host_list = join(",", $host_cluster);

ksort($host_metrics);
#print "<PRE>";print_r($host_metrics);

$hmetrics = array();
foreach ( $host_metrics as $name => $value )
  $hmetrics[] = $name;


$hreg = "";
if (array_key_exists('hreg', $_GET)) {
  foreach ( $_GET['hreg'] as $index => $arg ) {
    $hreg .= "&hreg[]=" . $arg;
  }
}

if ( isset($_GET['hreg']) ) {
  $data->assign("hreg_arg", $_GET['hreg'][0]);
} else {
  $data->assign("hreg_arg", "");
}

$size = isset($clustergraphsize) ? $clustergraphsize : 'default';
//set to 'default' to preserve old behavior
$size = $size == 'medium' ? 'default' : $size;

$additional_host_img_css_classes = "";
if ( isset($conf['zoom_support']) && $conf['zoom_support'] === true )
    $additional_host_img_css_classes = "host_${size}_zoomable";

$data->assign("additional_host_img_css_classes", $additional_host_img_css_classes);

$graphargs = "&r=" . $range;
if ($cs)
   $graphargs .= "&amp;cs=" . rawurlencode($cs);
if ($ce)
   $graphargs .= "&amp;ce=" . rawurlencode($ce);

$data->assign("hreg", $hreg);
$data->assign("graphargs", $graphargs);
$data->assign("host_list", $host_list);
$data->assign("host_metrics", $hmetrics);
$data->assign("number_of_metrics", sizeof($hmetrics));

$data->assign('GRAPH_BASE_ID', $GRAPH_BASE_ID);
$data->assign('SHOW_EVENTS_BASE_ID', $SHOW_EVENTS_BASE_ID);

$dwoo->output($tpl, $data);

?>
Something went wrong with that request. Please try again.