Permalink
Browse files

In compare_hosts, decompose_graph and views context there is no

need to connect go gmetad and download any XML. Especially not the
whole tree. This slows down the interface greatly.
  • Loading branch information...
vvuksan committed May 15, 2014
1 parent 56f7463 commit 6df16c88131a828ce6b9855eca7fbfcc5146a2ae
Showing with 42 additions and 29 deletions.
  1. +2 −0 ganglia.php
  2. +6 −0 get_context.php
  3. +34 −29 get_ganglia.php
View
@@ -341,6 +341,8 @@ function Gmetad ()
}
if ($debug) print "<br/>DEBUG: Creating parser\n";
if ( $context == "compare_hosts" or $context == "views" or $context == "decompose_graph")
return TRUE;
$parser = xml_parser_create();
switch ($context)
{
View
@@ -124,6 +124,12 @@
}
# Set context.
#
# 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
$context = NULL;
if(!$user['clustername'] && !$user['hostname'] && $user['controlroom']) {
$context = "control";
View
@@ -5,33 +5,38 @@
# Assumes you have already called get_context.php.
#
if (! Gmetad($conf['ganglia_ip'], $conf['ganglia_port']) )
{
print "<H4>There was an error collecting ganglia data ".
"(${conf['ganglia_ip']}:${conf['ganglia_port']}): $error</H4>\n";
exit;
}
# 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") {
} else {
if (! Gmetad($conf['ganglia_ip'], $conf['ganglia_port']) )
{
print "<H4>There was an error collecting ganglia data ".
"(${conf['ganglia_ip']}:${conf['ganglia_port']}): $error</H4>\n";
exit;
}
# If we have no child data sources, assume something is wrong.
if (!count($grid) and !count($cluster))
{
print "<H4>Ganglia cannot find a data source. Is gmond running?</H4>";
exit;
}
# If we only have one cluster source, suppress MetaCluster output.
if (count($grid) <= 2 and $context=="meta")
{
# Lets look for one cluster (the other is our grid).
foreach($grid as $source)
if (isset($source['CLUSTER']) and $source['CLUSTER'])
{
$standalone = 1;
$context = "cluster";
# Need to refresh data with new context.
Gmetad($conf['ganglia_ip'], $conf['ganglia_port']);
$clustername = $source['NAME'];
}
}
# If we have no child data sources, assume something is wrong.
if (!count($grid) and !count($cluster))
{
print "<H4>Ganglia cannot find a data source. Is gmond running?</H4>";
exit;
}
# If we only have one cluster source, suppress MetaCluster output.
if (count($grid) <= 2 and $context=="meta")
{
# Lets look for one cluster (the other is our grid).
foreach($grid as $source)
if (isset($source['CLUSTER']) and $source['CLUSTER'])
{
$standalone = 1;
$context = "cluster";
# Need to refresh data with new context.
Gmetad($conf['ganglia_ip'], $conf['ganglia_port']);
$clustername = $source['NAME'];
}
}
?>
}

0 comments on commit 6df16c8

Please sign in to comment.