diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 1159c20418..9f7007de6b 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2012-03-08 Sergio Martin + + * include/functions_graph.php + include/graphs/functions_flot.php + include/graphs/flot/pandora.flot.js + include/graphs/fgraph.php + operation/agentes/stat_win.php: Adapted events slice graph to + the sparse/boolean/string graph. Fix some bugs on menu and legend + graphs + 2012-03-07 Miguel de Dios * godmode/alerts/alert_list.builder.php, diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index c531d989bd..dc56acc5e2 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -29,7 +29,7 @@ function grafico_modulo_sparse ($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, - $only_image = false, $homeurl = '', $ttl = 1, $projection = false) { + $only_image = false, $homeurl = '', $ttl = 1, $projection = false, $adapt_key = '') { global $config; global $graphic_type; @@ -388,7 +388,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $long_index, "images/image_problem.opaque.png", "", "", $homeurl, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, $series_type, - $chart_extra_data, $warning_min, $critical_min); + $chart_extra_data, $warning_min, $critical_min, $adapt_key); } function graph_get_formatted_date($timestamp, $format1, $format2) { @@ -1729,7 +1729,7 @@ function fs_error_image () { function grafico_modulo_boolean ($agent_module_id, $period, $show_events, $width, $height , $title, $unit_name, $show_alerts, $avg_only = 0, $pure=0, - $date = 0, $only_image = false, $homeurl = '') { + $date = 0, $only_image = false, $homeurl = '', $adapt_key) { global $config; global $graphic_type; @@ -2028,7 +2028,8 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, return area_graph($flash_chart, $chart, $width, $height, $color, $legend, $long_index, "images/image_problem.opaque.png", "", $unit, $homeurl, $water_mark, - $config['fontpath'], $config['font_size'], $unit); + $config['fontpath'], $config['font_size'], $unit, 1, array(), + array(), 0, 0, $adapt_key); } @@ -2206,7 +2207,7 @@ function graph_netflow_aggregate_pie ($data, $aggregate) { */ function grafico_modulo_string ($agent_module_id, $period, $show_events, $width, $height , $title, $unit_name, $show_alerts, $avg_only = 0, $pure=0, - $date = 0, $only_image = false, $homeurl = '') { + $date = 0, $only_image = false, $homeurl = '', $adapt_key) { global $config; global $graphic_type; @@ -2415,7 +2416,7 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events, return vbar_graph($flash_chart, $chart, $width, $height, $color, $legend, "", $unit, $homeurl, $water_mark, - $config['fontpath'], $config['font_size'], true, true, 1, true); + $config['fontpath'], $config['font_size'], true, 1, true, $adapt_key); } function grafico_modulo_log4x ($id_agente_modulo, $periodo, $show_event, @@ -2793,8 +2794,9 @@ function grafico_modulo_log4x_format_y_axis ( $number , $decimals=2, $dec_point= * @param integer period time period * @param string homeurl Home url if the complete path is needed * @param int Zoom factor over the graph + * @param string adaptation width and margin left key (could be adapter_[something] or adapted_[something]) */ -function graphic_module_events ($id_module, $width, $height, $period = 0, $homeurl = '', $zoom = 0) { +function graphic_module_events ($id_module, $width, $height, $period = 0, $homeurl = '', $zoom = 0, $adapt_key = '') { global $config; global $graphic_type; @@ -2882,7 +2884,7 @@ function graphic_module_events ($id_module, $width, $height, $period = 0, $homeu // Draw slicebar graph if($config['flash_charts']) { - echo flot_slicesbar_graph($data, $period, $width, 15, $legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl); + echo flot_slicesbar_graph($data, $period, $width, 15, $legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl, '', $adapt_key); } else { echo slicesbar_graph($data, $period, $width, 15, $colors, $config['fontpath'], $config['round_corner'], $homeurl); diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index acbc87fa63..816f47772a 100755 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -182,12 +182,13 @@ function slicesbar_graph($chart_data, $period, $width, $height, $colors, $font, function vbar_graph($flash_chart, $chart_data, $width, $height, $color = array(), $legend = array(), $xaxisname = "", $yaxisname = "", $homedir="", - $water_mark = '', $font = '', $font_size = '', $force_steps = true, $ttl = 1, $reduce_data_columns = false) { + $water_mark = '', $font = '', $font_size = '', $force_steps = true, $ttl = 1, $reduce_data_columns = false, + $adapt_key) { setup_watermark($water_mark, $water_mark_file, $water_mark_url); if($flash_chart) { - return flot_vcolumn_chart ($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url, $homedir, $reduce_data_columns); + return flot_vcolumn_chart ($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url, $homedir, $reduce_data_columns, $adapt_key); } else { $graph = array(); @@ -209,6 +210,7 @@ function vbar_graph($flash_chart, $chart_data, $width, $height, $color = array() } } +// NOT USED ACTUALLY function threshold_graph($flash_chart, $chart_data, $width, $height, $ttl = 1) { if($flash_chart) { return flot_area_simple_graph($chart_data, $width, $height); @@ -221,7 +223,7 @@ function threshold_graph($flash_chart, $chart_data, $width, $height, $ttl = 1) { function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend, $long_index, $no_data_image, $xaxisname = "", $yaxisname = "", $homeurl="", $water_mark = "", $font = '', $font_size = '', $unit = '', $ttl = 1, $series_type = array(), - $chart_extra_data = array(), $yellow_threshold = 0, $red_threshold = 0) { + $chart_extra_data = array(), $yellow_threshold = 0, $red_threshold = 0, $adapt_key = '') { setup_watermark($water_mark, $water_mark_file, $water_mark_url); @@ -235,7 +237,7 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend, } if($flash_chart) { - return flot_area_simple_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url, $series_type, $chart_extra_data, $yellow_threshold, $red_threshold); + return flot_area_simple_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url, $series_type, $chart_extra_data, $yellow_threshold, $red_threshold, $adapt_key); } else { $graph = array(); diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index 9565876779..98426838f2 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -241,7 +241,7 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors, }); } - labels = labels.split(separator).reverse(); + labels = labels.split(separator); var stack = 0, bars = true, lines = false, steps = false; @@ -356,6 +356,9 @@ function pandoraFlotSlicebar(graph_id, values, datacolor, labels, legend, acumul acumulate_data = acumulate_data.split(separator); datacolor = datacolor.split(separator); + // Check possible adapt_keys on classes + check_adaptions(graph_id); + var datas = new Array(); for(i=0;i

"; - $return .= "
"; + $return .= "
"; $return .= ""; $return .= ""; @@ -211,7 +203,7 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend, $long_in if($menu) { $threshold = false; - if($yellow_threshold != '' && $red_threshold != '') { + if($yellow_threshold != 0 || $red_threshold != 0) { $threshold = true; } @@ -431,7 +423,7 @@ function flot_hcolumn_chart ($graph_data, $width, $height, $water_mark) { } // Returns a 3D column chart -function flot_vcolumn_chart ($graph_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark, $homedir, $reduce_data_columns) { +function flot_vcolumn_chart ($graph_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark, $homedir, $reduce_data_columns, $adapt_key) { global $config; include_javascript_dependencies_flot_graph(); @@ -444,7 +436,7 @@ function flot_vcolumn_chart ($graph_data, $width, $height, $color, $legend, $lon $graph_id2 = uniqid('graph_'); // Set some containers to legend, graph, timestamp tooltip, etc. - $return .= "
"; + $return .= "
"; $return .= ""; if($water_mark != '') { @@ -536,9 +528,9 @@ function flot_vcolumn_chart ($graph_data, $width, $height, $color, $legend, $lon return $return; } -function flot_slicesbar_graph ($graph_data, $period, $width, $height, $legend, $colors, $fontpath, $round_corner, $homeurl, $watermark = '') { +function flot_slicesbar_graph ($graph_data, $period, $width, $height, $legend, $colors, $fontpath, $round_corner, $homeurl, $watermark = '', $adapt_key = '') { global $config; - + include_javascript_dependencies_flot_graph(); $height+= 20; @@ -549,7 +541,7 @@ function flot_slicesbar_graph ($graph_data, $period, $width, $height, $legend, $ $graph_id = uniqid('graph_'); // Set some containers to legend, graph, timestamp tooltip, etc. - $return = "
"; + $return = "
"; $return .= ""; // Set a weird separator to serialize and unserialize passing data from php to javascript @@ -577,6 +569,10 @@ function flot_slicesbar_graph ($graph_data, $period, $width, $height, $legend, $ } $fontsize = 7; + + $extra_height = 15; + + $return .= ""; $maxticks = (int) ($width / ($fontsize * $leg_max_length)); diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php index 198c1da744..e1418a0268 100644 --- a/pandora_console/operation/agentes/stat_win.php +++ b/pandora_console/operation/agentes/stat_win.php @@ -167,29 +167,29 @@ echo "
"; switch ($graph_type) { case 'boolean': echo grafico_modulo_boolean ($id, $period, $draw_events, $width, $height, - $label, null, $draw_alerts, $avg_only, false, $date, false, $urlImage); + $label, null, $draw_alerts, $avg_only, false, $date, false, $urlImage, 'adapter_'.$graph_type); echo '


'; if ($show_events_graph) - echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom); + echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom, 'adapted_'.$graph_type); break; case 'sparse': echo grafico_modulo_sparse ($id, $period, $draw_events, $width, $height, $label, null, $draw_alerts, $avg_only, false, $date, '', $baseline, - 0, true, false, $urlImage); + 0, true, false, $urlImage, 1, false, 'adapter_'.$graph_type); echo '


'; if ($show_events_graph) - echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom); + echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom, 'adapted_'.$graph_type); break; case 'string': echo grafico_modulo_string ($id, $period, $draw_events, $width, $height, - $label, null, $draw_alerts, 1, false, $date, false, $urlImage); + $label, null, $draw_alerts, 1, false, $date, false, $urlImage, 'adapter_'.$graph_type); echo '


'; if ($show_events_graph) - echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom); + echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom, 'adapted_'.$graph_type); break; case 'log4x': echo grafico_modulo_log4x ($id, $period, $draw_events, $width, $height, - $label, $unit_name, $draw_alerts, 1, $pure, $date, 1); + $label, $unit_name, $draw_alerts, 1, $pure, $date); echo '


'; if ($show_events_graph) echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom);