diff --git a/cluster_view.php b/cluster_view.php index dc954ff4..0b9d4ae4 100644 --- a/cluster_view.php +++ b/cluster_view.php @@ -401,9 +401,28 @@ function get_cluster_optional_reports($conf, json_decode(file_get_contents($cluster_file), TRUE)); } + // Here we are looking for reports like cluster_.*_report.json + + if ($handle = opendir($conf['gweb_root'] . '/graph.d/')) { + $fs_reports = array(); + // If we are using RRDtool reports can be json or PHP suffixes + if ( $conf['graph_engine'] == "rrdtool" ) + $report_suffix = "php|json"; + else + $report_suffix = "json"; + + while (false !== ($file = readdir($handle))) { + if ( preg_match("/(cluster_" . $clustername . ".*)(_report)\.(" . $report_suffix .")/", $file, $out) ) { + $fs_reports["$out[1]"] = $out[1] . "_report"; + } + } + + closedir($handle); + } + # Merge arrays $reports["included_reports"] = - array_merge($default_reports["included_reports"],$override_reports["included_reports"]); + array_merge($default_reports["included_reports"],$override_reports["included_reports"],$fs_reports); $reports["excluded_reports"] = array_merge($default_reports["excluded_reports"],$override_reports["excluded_reports"]); diff --git a/conf_default.php.in b/conf_default.php.in index 0d83c1c2..1da0f578 100644 --- a/conf_default.php.in +++ b/conf_default.php.in @@ -188,6 +188,12 @@ $conf['strip_domainname'] = false; # $conf['cluster_hide_down_hosts'] = false; +# +# hide special metrics from drop-down list in cluster view, +# all metrics matching the regular expression are hidden +# +$conf['cluster_hide_metrics_from_menu'] = '^(cluster|host)_.*_report'; + # # Optional summary graphs # This function is deprecated. Please configure included reports diff --git a/edit_optional_graphs.php b/edit_optional_graphs.php index 95e3ea3d..a4655727 100644 --- a/edit_optional_graphs.php +++ b/edit_optional_graphs.php @@ -185,8 +185,10 @@ function create_radio_button($variable_name, $variable_value = "ignored") { while (false !== ($file = readdir($handle))) { if ( preg_match("/(.*)(_report)\.(" . $report_suffix .")/", $file, $out) ) { - if ( ! in_array($out[1] . "_report", $available_reports) ) - $available_reports[] = $out[1] . "_report"; + if ( ! preg_match("/((cluster|host)_.*)(_report)/", $file) ) { + if ( ! in_array($out[1] . "_report", $available_reports) ) + $available_reports[] = $out[1] . "_report"; + } } } diff --git a/header.php b/header.php index 046f4762..4df17a35 100755 --- a/header.php +++ b/header.php @@ -394,7 +394,9 @@ function make_node_menu($self, if (count($metrics)) { foreach ($metrics as $firsthost => $bar) { foreach ($metrics[$firsthost] as $m => $foo) - $context_metrics[$m] = $m; + if ( ! preg_match("/" . $conf['cluster_hide_metrics_from_menu'] . "/", $m) ) { + $context_metrics[$m] = $m; + } } foreach ($reports as $r => $foo) $context_metrics[] = $r; @@ -423,8 +425,10 @@ function make_node_menu($self, while (false !== ($file = readdir($handle))) { if ( preg_match("/(.*)(_report)\.(" . $report_suffix .")/", $file, $out) ) { - if ( ! in_array($out[1] . "_report", $context_metrics) ) - $context_metrics[] = $out[1] . "_report"; + if ( ! preg_match("/" . $conf['cluster_hide_metrics_from_menu'] . "/", $file) ) { + if ( ! in_array($out[1] . "_report", $context_metrics) ) + $context_metrics[] = $out[1] . "_report"; + } } } diff --git a/host_view.php b/host_view.php index 3ee98ee9..74a94748 100644 --- a/host_view.php +++ b/host_view.php @@ -88,11 +88,32 @@ function getOptionalReports($hostname, } } + // Here we are looking for reports like host_.*_report.json + + if ($handle = opendir($conf['gweb_root'] . '/graph.d/')) { + $fs_reports = array(); + // If we are using RRDtool reports can be json or PHP suffixes + if ( $conf['graph_engine'] == "rrdtool" ) + $report_suffix = "php|json"; + else + $report_suffix = "json"; + + while (false !== ($file = readdir($handle))) { + if ( preg_match("/(host_" . $hostname . ".*)(_report)\.(" . $report_suffix .")/", $file, $out) ) { + $fs_reports["$out[1]"] = $out[1] . "_report"; + } + } + + closedir($handle); + } + + // Merge arrays $reports["included_reports"] = array_merge( $default_reports["included_reports"], $cluster_override_reports["included_reports"], - $override_reports["included_reports"]); + $override_reports["included_reports"], + $fs_reports); $reports["excluded_reports"] = array_merge( $default_reports["excluded_reports"] ,