diff --git a/ganglia.php b/ganglia.php index ebdb6194..4c71a4a4 100644 --- a/ganglia.php +++ b/ganglia.php @@ -11,6 +11,7 @@ $gweb_root = dirname(__FILE__); include_once($gweb_root . "/version.php"); +include_once("./global.php"); $error=""; @@ -341,8 +342,9 @@ function Gmetad () } if ($debug) print "
DEBUG: Creating parser\n"; - if ( $context == "compare_hosts" or $context == "views" or $context == "decompose_graph") + if ( in_array($context, $SKIP_GMETAD_CONTEXTS) ) { return TRUE; + } $parser = xml_parser_create(); $strip_extra = $conf['strip_extra']; switch ($context) diff --git a/get_context.php b/get_context.php index dfad77bb..deb79164 100644 --- a/get_context.php +++ b/get_context.php @@ -127,9 +127,9 @@ # # WARNING WARNING WARNING WARNING. If you create another context # e.g. views, compare_hosts please make sure you add those to -# get_ganglia.php and ganglia.php otherwise you may be making -# requests to the gmetad any time you access it which will impact -# performance read make it really slow +# global.php, otherwise you may be making requests to the gmetad +# any time you access it which will impact performance read make +# it really slow $context = NULL; if(!$user['clustername'] && !$user['hostname'] && $user['controlroom']) { $context = "control"; diff --git a/get_ganglia.php b/get_ganglia.php index 36e21dd3..a6296105 100644 --- a/get_ganglia.php +++ b/get_ganglia.php @@ -7,7 +7,7 @@ # If we are in compare_hosts, views and decompose_graph context we shouldn't attempt # any connections to the gmetad -if ( $context == "compare_hosts" or $context == "views" or $context == "decompose_graph") { +if ( in_array($context, $SKIP_GMETAD_CONTEXTS) ) { } else { if (! Gmetad($conf['ganglia_ip'], $conf['ganglia_port']) ) @@ -39,4 +39,6 @@ } } -} \ No newline at end of file +} + +?> diff --git a/global.php b/global.php index 6dc2d895..fce9bdb4 100644 --- a/global.php +++ b/global.php @@ -2,4 +2,9 @@ $SHOW_EVENTS_BASE_ID = "show_events_"; $TIME_SHIFT_BASE_ID = "time_shift_"; $GRAPH_BASE_ID = "graph_img_"; -?> \ No newline at end of file +$SKIP_GMETAD_CONTEXTS = array ( + "compare_hosts" + , "decompose_graph" + , "views" +); +?>