1<?php 2include_once("./global.php"); 3 4$tpl = new Dwoo_Template_File( template("compare_hosts.tpl") ); 5$data = new Dwoo_Data(); 6$data->assign("range",$range); 7 8$size = isset($clustergraphsize) ? $clustergraphsize : 'default'; 9//set to 'default' to preserve old behavior 10$size = $size == 'medium' ? 'default' : $size; 11 12retrieve_metrics_cache(); 13 14$matches = array(); 15if (array_key_exists('hreg', $_GET)) { 16 foreach ( $_GET['hreg'] as $key => $query ) { 17 if ($query != '') { 18 foreach ( $index_array['hosts'] as $key => $host_name ) { 19 if ( preg_match("/$query/i", $host_name ) ) { 20 // We can have same hostname in multiple clusters 21 foreach ($index_array['cluster'][$host_name] AS $clustername) { 22 $matches[] = array ("hostname" => $host_name, "clustername" => $clustername); 23 } 24 } 25 } 26 } 27 } 28} 29 30#print "<PRE>";print_r($index_array['metrics']); 31 32$host_metrics = array(); 33$host_cluster = array(); 34foreach ( $matches as $index => $match ) { 35 $hostname = $match['hostname']; 36 $host_cluster[] = $match['hostname'] . "|" . $match['clustername']; 37 foreach ( $index_array['metrics'] as $metric_name => $hosts ) { 38 if ( array_search( $hostname , $hosts ) !== FALSE && 39 ! isset($host_metrics[$metric_name]) ) { 40 $host_metrics[$metric_name] = 1; 41 } 42 } 43} 44 45# Join the hosts in a list into a string which we pass to graphs 46$host_list = join(",", $host_cluster); 47 48ksort($host_metrics); 49#print "<PRE>";print_r($host_metrics); 50 51$hmetrics = array(); 52foreach ( $host_metrics as $name => $value ) 53 $hmetrics[] = $name; 54 55 56$hreg = ""; 57if (array_key_exists('hreg', $_GET)) { 58 foreach ( $_GET['hreg'] as $index => $arg ) { 59 $hreg .= "&hreg[]=" . rawurlencode($arg); 60 } 61} 62 63if ( isset($_GET['hreg']) ) { 64 $data->assign("hreg_arg", htmlspecialchars($_GET['hreg'][0]) ); 65} else { 66 $data->assign("hreg_arg", ""); 67} 68 69$size = isset($clustergraphsize) ? $clustergraphsize : 'default'; 70//set to 'default' to preserve old behavior 71$size = $size == 'medium' ? 'default' : $size; 72 73$additional_host_img_css_classes = ""; 74if ( isset($conf['zoom_support']) && $conf['zoom_support'] === true ) 75 $additional_host_img_css_classes = "host_${size}_zoomable"; 76 77$data->assign("additional_host_img_css_classes", $additional_host_img_css_classes); 78 79$graphargs = "&r=" . $range; 80if ($cs) 81 $graphargs .= "&cs=" . rawurlencode($cs); 82if ($ce) 83 $graphargs .= "&ce=" . rawurlencode($ce); 84 85$data->assign("hreg", $hreg); 86$data->assign("graphargs", $graphargs); 87$data->assign("host_list", $host_list); 88$data->assign("host_metrics", $hmetrics); 89$data->assign("number_of_metrics", count($hmetrics)); 90 91$data->assign('GRAPH_BASE_ID', $GRAPH_BASE_ID); 92$data->assign('SHOW_EVENTS_BASE_ID', $SHOW_EVENTS_BASE_ID); 93 94$dwoo->output($tpl, $data); 95 96?> 97