From a40a1244bf0510c47df00e8ab05ba17aa9a85f66 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Sun, 2 May 2010 19:47:09 +0000 Subject: [PATCH] remove some crap from graphs setup. fetch device array inside graph file, not in graph.php. mres() in graph.php. try to switch to generic $_GET['id'] for everything (peers and ports undone?) git-svn-id: http://www.observium.org/svn/observer/trunk@1084 61d68cd4-352d-0410-923a-c4978735b2b8 --- config.php.default | 2 +- html/graph.php | 34 +++++-------------- html/includes/graphs/device_bits.inc.php | 8 ++--- html/includes/graphs/device_cpu.inc.php | 6 ++-- .../graphs/device_cpu_powerconnect.inc.php | 4 ++- .../graphs/device_cpu_procurve.inc.php | 4 ++- html/includes/graphs/device_cpu_unix.inc.php | 5 +-- html/includes/graphs/device_fanspeeds.inc.php | 8 ++--- .../graphs/device_hrprocesses.inc.php | 4 ++- html/includes/graphs/device_hrusers.inc.php | 4 ++- html/includes/graphs/device_icmp.inc.php | 4 ++- .../graphs/device_icmp_informational.inc.php | 4 ++- html/includes/graphs/device_ip.inc.php | 3 +- .../graphs/device_ipSystemStats.inc.php | 5 +-- .../graphs/device_ip_fragmented.inc.php | 4 +-- html/includes/graphs/device_load.inc.php | 3 +- html/includes/graphs/device_load_unix.inc.php | 3 +- .../graphs/device_load_windows.inc.php | 3 +- html/includes/graphs/device_memory.inc.php | 5 +-- .../graphs/device_memory_procurve.inc.php | 3 +- .../graphs/device_memory_unix.inc.php | 3 +- .../graphs/device_memory_windows.inc.php | 3 +- .../includes/graphs/device_processors.inc.php | 5 +-- html/includes/graphs/device_storage.inc.php | 6 ++-- html/includes/graphs/device_tcp.inc.php | 3 +- .../graphs/device_temperatures.inc.php | 5 +-- html/includes/graphs/device_toner.inc.php | 5 +-- html/includes/graphs/device_udp.inc.php | 3 +- html/includes/graphs/device_uptime.inc.php | 7 ++-- html/includes/graphs/device_voltages.inc.php | 5 +-- includes/static-config.php | 2 +- 31 files changed, 87 insertions(+), 76 deletions(-) diff --git a/config.php.default b/config.php.default index 991bf7bd64..a07bacb7e9 100755 --- a/config.php.default +++ b/config.php.default @@ -108,7 +108,7 @@ $config['ports_page_default'] = "details/"; ### Which additional features should we enable? -$config['enable_bgp'] = 1; # Enable BGP session collection and display +$config['enable_bgp'] = 1; # Enable BGP session collection and display $config['enable_syslog'] = 0; # Enable Syslog $config['enable_billing'] = 0; # Enable Billing $config['enable_inventory'] = 1; # Enable Inventory diff --git a/html/graph.php b/html/graph.php index 76ec3ce2d4..bf24aa5279 100644 --- a/html/graph.php +++ b/html/graph.php @@ -15,22 +15,18 @@ if($_GET['debug']) { include("../includes/rewrites.php"); include("includes/authenticate.inc.php"); -# if(!$_SESSION['authenticated']) { echo("not authenticated"); exit; } + if(!$_SESSION['authenticated']) { echo("not authenticated"); exit; } if($_GET['device']) { - $device_id = $_GET['device']; + $_GET['id'] = $_GET['device']; } elseif($_GET['if']) { - $device_id = getifhost($_GET['if']); - $ifIndex = getifindexbyid($_GET['if']); + $_GET['id'] = $_GET['if']; } elseif($_GET['port']) { - $device_id = getifhost($_GET['port']); - $ifIndex = getifindexbyid($_GET['port']); + $_GET['id'] = $_GET['port']; } elseif($_GET['peer']) { - $device_id = getpeerhost($_GET['peer']); + $_GET['id'] = $_GET['peer']; } - if($device_id) { $hostname = gethostbyid($device_id); } - $from = mres($_GET['from']); $to = mres($_GET['to']); $width = mres($_GET['width']); @@ -38,6 +34,8 @@ if($_GET['debug']) { $title = mres($_GET['title']); $vertical = mres($_GET['vertical']); $type = mres($_GET['type']); + $legend = mres($_GET['legend']); + $id = mres($_GET['id']); $graphfile = $config['temp_dir'] . "/" . strgen() . ".png"; @@ -62,6 +60,7 @@ if($_GET['debug']) { if(is_file($graphfile)) { header('Content-type: image/png'); $fd = fopen($graphfile,'r');fpassthru($fd);fclose($fd); + unlink($graphfile); } else { header('Content-type: image/png'); $string = "Graph Generation Error"; @@ -74,23 +73,6 @@ if($_GET['debug']) { } } - if($graph) { -# header('Content-type: image/png'); -# $fd = fopen($graphfile,'r');fpassthru($fd);fclose($fd); - } else { - header('Content-type: image/png'); - $string = "Graph Generation Error"; - $im = imagecreate($width, $height); - $orange = imagecolorallocate($im, 255, 255, 255); - $px = (imagesx($im) - 7.5 * strlen($string)) / 2; - imagestring($im, 3, $px, $height / 2 - 8, $string, imagecolorallocate($im, 128, 0, 0)); - imagepng($im); - imagedestroy($im); - } - - unlink($graphfile); - -# } // End IF ?> diff --git a/html/includes/graphs/device_bits.inc.php b/html/includes/graphs/device_bits.inc.php index 72540626e1..befffad48b 100644 --- a/html/includes/graphs/device_bits.inc.php +++ b/html/includes/graphs/device_bits.inc.php @@ -2,13 +2,9 @@ ## Generate a list of ports and then call the multi_bits grapher to generate from the list -if($_GET['device']) { - $device = device_by_id_cache(mres($_GET['device'])); -} elseif($_GET['id']) { - $device = device_by_id_cache(mres($_GET['id'])); -} +$device = device_by_id_cache($id); -$query = mysql_query("SELECT * FROM `ports` WHERE `device_id` = '".$device['device_id']."'"); +$query = mysql_query("SELECT * FROM `ports` WHERE `device_id` = '".$id."'"); while($int = mysql_fetch_assoc($query)) { $ignore = 0; if(is_array($config['device_traffic_iftype'])) { diff --git a/html/includes/graphs/device_cpu.inc.php b/html/includes/graphs/device_cpu.inc.php index 728e28e618..b9fb212b1a 100644 --- a/html/includes/graphs/device_cpu.inc.php +++ b/html/includes/graphs/device_cpu.inc.php @@ -1,11 +1,13 @@ Observer MySQL Error"; die;