Skip to content

Commit

Permalink
Merge pull request #240 from cddude229/optimize-xml-volume
Browse files Browse the repository at this point in the history
Provide the option to remove unnecessary XML data
  • Loading branch information
vvuksan committed Aug 3, 2014
2 parents a114d58 + 02898d3 commit 0d17fe3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions conf_default.php.in
Original file line number Diff line number Diff line change
Expand Up @@ -433,4 +433,9 @@ $conf['display_views_using_tree'] = false;
# when the tree is first created in a browser session. Path entries are
# separated using "--"
#$conf['view_tree_nodes_initially_open'] = array();

# Gmetad will send back <EXTRA_DATA> information that is not utilized
# in many code paths. This will pre-emptively strip out the tags in
# those code paths to save time during XML parsing.
$conf['strip_extra'] = true;
?>
7 changes: 5 additions & 2 deletions ganglia.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ function Gmetad ()
if ( $context == "compare_hosts" or $context == "views" or $context == "decompose_graph")
return TRUE;
$parser = xml_parser_create();
$strip_extra = $conf['strip_extra'];
switch ($context)
{
case "meta":
Expand All @@ -357,12 +358,12 @@ function Gmetad ()
case "cluster":
xml_set_element_handler($parser, "start_cluster", "end_all");
$request = "/$clustername";
break;
break;
case "index_array":
case "views":
xml_set_element_handler($parser, "start_everything", "end_all");
$request = "/";
break;
break;
case "cluster-summary":
xml_set_element_handler($parser, "start_cluster_summary", "end_all");
$request = "/$clustername?filter=summary";
Expand All @@ -371,6 +372,7 @@ function Gmetad ()
case "host":
xml_set_element_handler($parser, "start_host", "end_all");
$request = "/$clustername/$hostname";
$strip_extra = false;
break;
}

Expand Down Expand Up @@ -404,6 +406,7 @@ function Gmetad ()
while(!feof($fp))
{
$data = fread($fp, 16384);
if($strip_extra) $data = preg_replace('/<EXTRA_DATA>.*?<\/EXTRA_DATA>/s', '', $data);
if (!xml_parse($parser, $data, feof($fp)))
{
$error = sprintf("XML error: %s at %d",
Expand Down

0 comments on commit 0d17fe3

Please sign in to comment.