From 718aaa550802e91d6809ba864b425a71306365d4 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Mon, 13 Jun 2011 11:12:32 +0000 Subject: [PATCH] 2011-06-13 Sergio Martin * include/functions_graph.php include/graphs/functions_pchart.php include/graphs/functions_gd.php include/graphs/fgraph.php include/graphs/functions_utils.php include/functions_reporting.php include/functions_visual_map.php include/ajax/visual_console_builder.ajax.php include/config_process.php include/include_graph_dependencies.php operation/agentes/stat_win.php operation/reporting/reporting_xml.php: Fixed missed parameters in sparse graph functions. Fixed graph includes and bugs git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4432 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 17 +++++++++++ .../ajax/visual_console_builder.ajax.php | 4 +-- pandora_console/include/config_process.php | 2 +- pandora_console/include/functions_graph.php | 6 +++- .../include/functions_reporting.php | 4 +-- .../include/functions_visual_map.php | 6 ++-- pandora_console/include/graphs/fgraph.php | 1 - .../include/graphs/functions_gd.php | 9 +++--- .../include/graphs/functions_pchart.php | 2 +- .../include/graphs/functions_utils.php | 29 ++++++++++++++----- .../include/include_graph_dependencies.php | 2 +- .../operation/agentes/stat_win.php | 2 +- .../operation/reporting/reporting_xml.php | 4 +-- 13 files changed, 61 insertions(+), 27 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 045d195599..835860e6dc 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,20 @@ +2011-06-13 Sergio Martin + + * include/functions_graph.php + include/graphs/functions_pchart.php + include/graphs/functions_gd.php + include/graphs/fgraph.php + include/graphs/functions_utils.php + include/functions_reporting.php + include/functions_visual_map.php + include/ajax/visual_console_builder.ajax.php + include/config_process.php + include/include_graph_dependencies.php + operation/agentes/stat_win.php + operation/reporting/reporting_xml.php: Fixed missed parameters + in sparse graph functions. + Fixed graph includes and bugs + 2011-06-10 Ramon Novoa * include/functions_api.php, pandoradb.sql, diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php index fe809b86d3..4bbe9ba28c 100644 --- a/pandora_console/include/ajax/visual_console_builder.ajax.php +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -69,7 +69,7 @@ switch ($action) { break; case 'get_image_sparse': $img = grafico_modulo_sparse2($id_agent_module, - $period, false, $width, $height, '', null, false, 0, false, 0, 0, 0, + $period, false, $width, $height, '', null, false, 0, false, 0, '', 0, 0, true, true); preg_match("/src='(.*)'/", $img, $matches); @@ -334,4 +334,4 @@ if ($get_image_path_status){ echo json_encode($result); } -?> \ No newline at end of file +?> diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 139c3dc8f4..a95d88bf83 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -157,6 +157,6 @@ db_connect(); require_once("include_graph_dependencies.php"); //require_once("include/fgraph.php"); -include_graphs_dependencies(); +include_graphs_dependencies($config['homedir'].'/'); ?> diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 6df3e20977..6de26c6531 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -28,7 +28,7 @@ define("GRAPH_STACKED_LINE", 3); function grafico_modulo_sparse2 ($agent_module_id, $period, $show_events, $width, $height , $title = '', $unit_name = null, $show_alerts = false, $avg_only = 0, $pure = false, - $date = 0, $unit, $baseline = 0, $return_data = 0, $show_title = true, + $date = 0, $unit = '', $baseline = 0, $return_data = 0, $show_title = true, $only_image = false, $homeurl = '') { global $config; global $graphic_type; @@ -795,6 +795,10 @@ function progress_bar2($progress, $width, $height, $title = '', $mode = 1) { $out_of_lim_str = __("Out of limits"); $title = ""; + + require_once("include_graph_dependencies.php"); + include_graphs_dependencies("/var/www/pandora/"); + return "" . $title . ""; } diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 02ecef366b..69f8003ebe 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -2053,7 +2053,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $data[0] = grafico_modulo_sparse2($content['id_agent_module'], $content['period'], false, $sizgraph_w, $sizgraph_h, '', '', false, true, true, - $report["datetime"], 0, 0, true, true); + $report["datetime"], '', 0, 0, true, true); array_push ($table->data, $data); @@ -2079,7 +2079,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f $data = array (); $data[0] = grafico_modulo_sparse2($layout_data['id_agente_modulo'], $content['period'], false, $sizgraph_w, $sizgraph_h, '', '', false, true, true, - $report["datetime"], true, 0, true, true); + $report["datetime"], '', true, 0, true, true); array_push ($table->data, $data); break; diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 030c28f3f0..8e1d685555 100644 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -123,7 +123,7 @@ function visual_map_print_item($layoutData) { break; case MODULE_GRAPH: $img = grafico_modulo_sparse2($id_module, $period, 0, $width, - $height, '', null, false, 0, false, 0, 0, 0, true, true); + $height, '', null, false, 0, false, 0, '', 0, 0, true, true); $img = str_replace('>', 'class="image" id="image_' . $id . '" />', $img); echo '
'; @@ -794,12 +794,12 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line echo grafico_modulo_sparse2 ($layout_data['id_agente_modulo'], $layout_data['period'], false, ((integer)($proportion * $layout_data['width'])), ((integer)($proportion * $layout_data['height'])), - '', null, false, 0, false, 0, 0, 0, true, true); + '', null, false, 0, false, 0, '', 0, 0, true, true); } else { echo grafico_modulo_sparse2 ($layout_data['id_agente_modulo'], $layout_data['period'], false, $layout_data['width'], $layout_data['height'], - '', null, false, 0, false, 0, 0, 0, true, true); + '', null, false, 0, false, 0, '', 0, 0, true, true); } echo ""; echo "
"; diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index df580a5fda..b9b3673ae3 100755 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -47,7 +47,6 @@ include_once('functions_fsgraph.php'); include_once('functions_utils.php'); */ - if (isset($_GET['homeurl'])) { $homeurl = $_GET['homeurl']; } diff --git a/pandora_console/include/graphs/functions_gd.php b/pandora_console/include/graphs/functions_gd.php index 32c5aaf4d6..b4d59df312 100755 --- a/pandora_console/include/graphs/functions_gd.php +++ b/pandora_console/include/graphs/functions_gd.php @@ -21,14 +21,15 @@ if(file_exists('include/functions.php')) { else if(file_exists('../functions.php')) { include_once('../functions.php'); include_once('../functions_html.php'); - include_once('../functions_html.php'); include_once('functions_utils.php'); } + +$types = array('histogram', 'progressbar'); $id_graph = get_parameter('id_graph', false); +$graph_type = get_parameter('graph_type', ''); -if($id_graph) { - +if($id_graph && in_array($graph_type, $types)) { if (!$id_graph) { exit; @@ -44,8 +45,6 @@ if($id_graph) { $graph['fontsize'] = 6; } - $graph_type = get_parameter('graph_type', ''); - switch($graph_type) { case 'histogram': gd_histogram ($graph['width'], diff --git a/pandora_console/include/graphs/functions_pchart.php b/pandora_console/include/graphs/functions_pchart.php index 72703abd17..61decd6ae4 100755 --- a/pandora_console/include/graphs/functions_pchart.php +++ b/pandora_console/include/graphs/functions_pchart.php @@ -12,6 +12,7 @@ // GNU General Public License for more details. include_once('functions_utils.php'); +include_once('../functions_io.php'); include_once('../functions.php'); include_once('../functions_html.php'); @@ -48,7 +49,6 @@ $graph_type = get_parameter('graph_type', ''); $id_graph = get_parameter('id_graph', false); - if (!$id_graph) { exit; } diff --git a/pandora_console/include/graphs/functions_utils.php b/pandora_console/include/graphs/functions_utils.php index ed8bc002e0..4db58b8ac1 100644 --- a/pandora_console/include/graphs/functions_utils.php +++ b/pandora_console/include/graphs/functions_utils.php @@ -10,15 +10,15 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -function serialize_in_temp($array = array(), $serial_id = null) { +function serialize_in_temp($array = array(), $serial_id = null, $ttl = 1) { $json = json_encode($array); if ($serial_id === null) { $serial_id = uniqid(); } - - $file_path = sys_get_temp_dir()."/pandora_serialize_".$serial_id; - + + $file_path = sys_get_temp_dir()."/pandora_serialize_".$serial_id."__1__".$ttl; + if (file_put_contents($file_path, $json) === false) { return false; } @@ -26,12 +26,21 @@ function serialize_in_temp($array = array(), $serial_id = null) { return $serial_id; } -function unserialize_in_temp($serial_id = null, $delete = true) { +function unserialize_in_temp($serial_id = null, $delete = true, $ttl = 1) { if ($serial_id === null) { return false; } - $file_path = sys_get_temp_dir()."/pandora_serialize_".$serial_id; + $volume = -1; + + for($i = 1 ; $i <= $ttl ; $i++) { + $file_path = sys_get_temp_dir()."/pandora_serialize_".$serial_id."__".$i."__".$ttl; + + if(file_exists($file_path)) { + $volume = $i; + break; + } + } $content = file_get_contents($file_path); @@ -42,7 +51,13 @@ function unserialize_in_temp($serial_id = null, $delete = true) { $array = json_decode($content, true); if ($delete) { - unlink($file_path); + if($volume == $ttl) { + unlink($file_path); + } + else { + $next_volume = $volume++; + rename($file_path, sys_get_temp_dir()."/pandora_serialize_".$serial_id."__".$next_volume."__".$ttl); + } } return $array; diff --git a/pandora_console/include/include_graph_dependencies.php b/pandora_console/include/include_graph_dependencies.php index 1ba35a2538..8ed67cafe2 100644 --- a/pandora_console/include/include_graph_dependencies.php +++ b/pandora_console/include/include_graph_dependencies.php @@ -21,7 +21,7 @@ $ttl = $serialize_ttl; $homeurl = $home_url; - + include_once($homeurl . 'include/functions_io.php'); include_once($homeurl . 'include/functions.php'); include_once($homeurl . 'include/functions_html.php'); diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php index 60c159af5a..e0cc57eb89 100644 --- a/pandora_console/operation/agentes/stat_win.php +++ b/pandora_console/operation/agentes/stat_win.php @@ -153,7 +153,7 @@ switch ($graph_type) { break; case 'sparse': echo grafico_modulo_sparse2 ($id, $period, $draw_events, $width, $height, - $label, null, $draw_alerts, $avg_only, false, $date, $baseline, + $label, null, $draw_alerts, $avg_only, false, $date, '', $baseline, 0, true, false, $urlImage); break; case 'string': diff --git a/pandora_console/operation/reporting/reporting_xml.php b/pandora_console/operation/reporting/reporting_xml.php index 26b1acfcb3..e004e13ea8 100644 --- a/pandora_console/operation/reporting/reporting_xml.php +++ b/pandora_console/operation/reporting/reporting_xml.php @@ -194,7 +194,7 @@ foreach ($contents as $content) { $img = grafico_modulo_sparse2($content['id_agent_module'], $content['period'], 0, 720, - 230, '', null, false, true, false, $datetime, 0, 0, true, true); + 230, '', null, false, true, false, $datetime, '', 0, 0, true, true); preg_match("/src='(.*)'/", $img, $matches); $url = $matches[1]; @@ -207,7 +207,7 @@ foreach ($contents as $content) { $img = grafico_modulo_sparse2($content['id_agent_module'], $content['period'], 0, 720, - 230, '', null, false, true, false, ($datetime + $content['period']), true, 0, true, true); + 230, '', null, false, true, false, ($datetime + $content['period']), '', true, 0, true, true); preg_match("/src='(.*)'/", $img, $matches); $url = $matches[1];