From 8f7733799a74d5e566729eabcb662c6c492bbaef Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Sun, 9 Oct 2011 11:59:10 +0000 Subject: [PATCH] fixes (fix map, flush rrdtool pipe) git-svn-id: http://www.observium.org/svn/observer/trunk@2674 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/map.php | 17 +++++++++-------- includes/defaults.inc.php | 4 ++-- includes/rrdtool.inc.php | 2 ++ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/html/map.php b/html/map.php index 7736562ca..c20d39dbc 100755 --- a/html/map.php +++ b/html/map.php @@ -39,7 +39,7 @@ if (isset($_GET['device'])) { $where = "WHERE device_id = ".mres($_GET['device'] if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) { - $map = 'digraph G { sep=0.01; size="12,5.5"; pack=100; bgcolor=transparent; splines=true; overlap=scale; concentrate=0; epsilon=0.001; rankdir=0; + $map = 'digraph G { sep=0.01; size="120,50.5"; pack=100; bgcolor=transparent; splines=true; overlap=scale; concentrate=0; epsilon=0.001; rankdir=0; node [ fontname="helvetica", fontstyle=bold, style=filled, color=white, fillcolor=lightgrey, overlap=false]; edge [ bgcolor=white, fontname="helvetica", fontstyle=bold, arrowhead=dot, arrowtail=dot]; graph [bgcolor=transparent]; @@ -159,17 +159,18 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) $_GET['format'] = 'png'; } - if ($links > 10) ### Unflatten if there are more than 10 links. beyond that it gets messy + if ($links > 30) ### Unflatten if there are more than 10 links. beyond that it gets messy { - $maptool = $config['unflatten'] . ' -f -l 5 | ' . $config['dot']; + $maptool = $config['unflatten'] . ' -f -l 5 | ' . $config['neato']; } else { - $maptool = $config['dot']; + $maptool = $config['neato']; } - if ($where == '') { $maptool = $config['sdfp'] . ' -Gpack -Gcharset=latin1 -Gsize=200,200'; } +# if ($where == '') { $maptool = $config['sfdp'] . ' -Gpack -Gcharset=latin1 -Gsize=200,200'; } $descriptorspec = array(0 => array("pipe", "r"),1 => array("pipe", "w") ); - $process = proc_open('/usr/bin/dot -Tsvg',$descriptorspec,$pipes); + + $process = proc_open($maptool.' -T'.$_GET['format'],$descriptorspec,$pipes); if (is_resource($process)) { fwrite($pipes[0], "$map"); @@ -181,7 +182,7 @@ if (isset($_GET['format']) && preg_match("/^[a-z]*$/", $_GET['format'])) if ($_GET['format'] == "png") { - header("Content-type: image/".$_GET['format']); + header("Content-type: image/png"); } elseif ($_GET['format'] == "svg") { header("Content-type: image/svg+xml"); $img = str_replace(" - + '); } diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index a30d0bd5a..b1b461d37 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -31,7 +31,7 @@ $config['virsh'] = "/usr/bin/virsh"; $config['dot'] = "/usr/bin/dot"; $config['unflatten'] = "/usr/bin/unflatten"; $config['neato'] = "/usr/bin/neato"; -$config['sfdp'] = "/usr/bin/sfdp"; +$config['sfdp'] = "/usr/bin/sfdp"; ### RRDCacheD - Make sure it can write to your RRD dir! @@ -66,7 +66,7 @@ $config['int_l2tp'] = 0; # Enable L2TP Port Types $config['show_locations'] = 1; # Enable Locations on menu $config['show_locations_dropdown'] = 1; # Enable Locations dropdown on menu $config['show_services'] = 1; # Enable Services on menu -$config['ports_page_default'] = "details"; ## eg "details" "graphs/bits" ### THIS NO LONGER WORKS +$config['ports_page_default'] = "details"; ## eg "details" or "basic" ### SNMP Settings - Timeouts/Retries disabled as default #$config['snmp']['timeout'] = 1; # timeout in seconds diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index 421e01405..b3c1eb1d3 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -161,6 +161,8 @@ function rrdtool($command, $filename, $options) echo("

"); echo("\n".$cmd."\n"); echo("

"); + } else { + $tmp = stream_get_contents($rrd_pipes[1]).stream_get_contents($rrd_pipes[2]); } }