Skip to content

Commit

Permalink
Refactor gmetad loading exception fix into single location. Add missi…
Browse files Browse the repository at this point in the history
…ng end PHP tag.
  • Loading branch information
jbuchbinder committed Aug 4, 2014
1 parent 5a5a38b commit 2b7a5fe
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
4 changes: 3 additions & 1 deletion ganglia.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
$gweb_root = dirname(__FILE__);

include_once($gweb_root . "/version.php");
include_once("./global.php");

$error="";

Expand Down Expand Up @@ -341,8 +342,9 @@ function Gmetad ()
}

if ($debug) print "<br/>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)
Expand Down
6 changes: 3 additions & 3 deletions get_context.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
6 changes: 4 additions & 2 deletions get_ganglia.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']) )
Expand Down Expand Up @@ -39,4 +39,6 @@
}
}

}
}

?>
7 changes: 6 additions & 1 deletion global.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
$SHOW_EVENTS_BASE_ID = "show_events_";
$TIME_SHIFT_BASE_ID = "time_shift_";
$GRAPH_BASE_ID = "graph_img_";
?>
$SKIP_GMETAD_CONTEXTS = array (
"compare_hosts"
, "decompose_graph"
, "views"
);
?>

0 comments on commit 2b7a5fe

Please sign in to comment.