diff --git a/pandora_console/godmode/reporting/graph_builder.main.php b/pandora_console/godmode/reporting/graph_builder.main.php index cd6ada0fa1..1464a0f47b 100644 --- a/pandora_console/godmode/reporting/graph_builder.main.php +++ b/pandora_console/godmode/reporting/graph_builder.main.php @@ -64,6 +64,12 @@ if ($edit_graph) { $id_group = $graphInTgraph['id_group']; $width = $graphInTgraph['width']; $height = $graphInTgraph['height']; + $check = false; + + if ($stacked == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){ + $stacked = CUSTOM_GRAPH_BULLET_CHART; + $check = true; + } } else { $id_agent = 0; @@ -74,7 +80,8 @@ else { $height = 210; $period = SECONDS_1DAY; $factor = 1; - $stacked = 0; + $stacked = 4; + $check = false; } @@ -137,7 +144,7 @@ echo ""; html_print_extended_select_for_time ('period', $period, '', '', '0', 10); echo ""; echo "".__('Type of graph').""; -echo ""; +echo "
"; include_once($config["homedir"] . "/include/functions_graph.php"); @@ -153,7 +160,16 @@ $stackeds = array( CUSTOM_GRAPH_PIE => __('Pie') ); html_print_select ($stackeds, 'stacked', $stacked); -echo ""; + +echo "
  ".__('Equalize maximum thresholds')."" . + ui_print_help_tip (__("If an option is selected, all graphs will have the highest value from all modules included in the graph as a maximum threshold"), true); + +html_print_checkbox('threshold', CUSTOM_GRAPH_BULLET_CHART_THRESHOLD, $check, false, false, '', false); +echo "
"; + + + +echo "
"; echo ""; @@ -167,17 +183,31 @@ echo ""; echo ''; -?> \ No newline at end of file +?> diff --git a/pandora_console/godmode/reporting/graph_builder.php b/pandora_console/godmode/reporting/graph_builder.php index e0a713d155..2e128d222b 100644 --- a/pandora_console/godmode/reporting/graph_builder.php +++ b/pandora_console/godmode/reporting/graph_builder.php @@ -74,7 +74,12 @@ if ($add_graph) { $height = get_parameter_post ("height"); $stacked = get_parameter ("stacked", 0); $period = get_parameter_post ("period"); - + $threshold = get_parameter('threshold'); + + if ($threshold == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){ + $stacked = $threshold; + } + // Create graph $values = array( 'id_user' => $config['id_user'], @@ -112,7 +117,12 @@ if ($update_graph) { $period = get_parameter('period'); $stacked = get_parameter('stacked'); $alerts = get_parameter('alerts'); - + $threshold = get_parameter('threshold'); + + if ($threshold == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){ + $stacked = $threshold; + } + if (trim($name) != "") { $success = db_process_sql_update('tgraph', diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index ce0b5738bd..b8ec27f80e 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -430,6 +430,7 @@ define("CUSTOM_GRAPH_GAUGE", 5); define("CUSTOM_GRAPH_HBARS", 6); define("CUSTOM_GRAPH_VBARS", 7); define("CUSTOM_GRAPH_PIE", 8); +define("CUSTOM_GRAPH_BULLET_CHART_THRESHOLD", 9); /* COLLECTIONS */ define("COLLECTION_PENDING_APPLY", 0); diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 57e34f0792..2e510d713f 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -1083,7 +1083,8 @@ function graphic_combined_module ($module_list, $weight_list, $period, $graph_values = array(); $module_name_list = array(); - + $collector = 0; + // Calculate data for each module for ($i = 0; $i < $module_number; $i++) { $automatic_custom_graph_meta = false; @@ -1432,8 +1433,26 @@ function graphic_combined_module ($module_list, $weight_list, $period, $stacked = CUSTOM_GRAPH_BULLET_CHART; switch ($stacked) { + case CUSTOM_GRAPH_BULLET_CHART_THRESHOLD: case CUSTOM_GRAPH_BULLET_CHART: $datelimit = $date - $period; + if($stacked == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){ + $acumulador = 0; + foreach ($module_list as $module_item) { + $module = $module_item; + $query_last_value = sprintf(' + SELECT datos + FROM tagente_datos + WHERE id_agente_modulo = %d + AND utimestamp < %d + ORDER BY utimestamp DESC', + $module, $date); + $temp_data = db_get_value_sql($query_last_value); + if ($acumulador < $temp_data){ + $acumulador = $temp_data; + } + } + } foreach ($module_list as $module_item) { $automatic_custom_graph_meta = false; if ($config['metaconsole']) { @@ -1486,7 +1505,12 @@ function graphic_combined_module ($module_list, $weight_list, $period, $temp_max = reporting_get_agentmodule_data_max($module,$period,$date); if ($temp_max < 0) $temp_max = 0; - $temp[$module]['max'] = ($temp_max === false) ? 0 : $temp_max; + if (isset($acumulador)){ + $temp[$module]['max'] = $acumulador; + }else{ + $temp[$module]['max'] = ($temp_max === false) ? 0 : $temp_max; + } + $temp_min = reporting_get_agentmodule_data_min($module,$period,$date); if ($temp_min < 0) $temp_min = 0; @@ -1788,6 +1812,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, "", "", $water_mark, $config['fontpath'], $fixed_font_size, "", $ttl, $homeurl, $background_color,$dashboard, $vconsole); break; + case CUSTOM_GRAPH_BULLET_CHART_THRESHOLD: case CUSTOM_GRAPH_BULLET_CHART: return stacked_bullet_chart($flash_charts, $graph_values, $width, $height, $color, $module_name_list, $long_index, diff --git a/pandora_console/operation/reporting/graph_viewer.php b/pandora_console/operation/reporting/graph_viewer.php index 64ca88e595..6a2d6aa15f 100644 --- a/pandora_console/operation/reporting/graph_viewer.php +++ b/pandora_console/operation/reporting/graph_viewer.php @@ -94,10 +94,16 @@ if ($view_graph) { $events = $graph["events"]; $description = $graph["description"]; $stacked = (int) get_parameter ('stacked', -1); + $check = get_parameter('threshold',false); + + if($check == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){ + $check = true; + $stacked = CUSTOM_GRAPH_BULLET_CHART_THRESHOLD; + } if ($stacked == -1) $stacked = $graph["stacked"]; - - if ($stacked == CUSTOM_GRAPH_BULLET_CHART ) + + if ($stacked == CUSTOM_GRAPH_BULLET_CHART || $stacked == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD) $height = 50; if ($stacked == CUSTOM_GRAPH_GAUGE ){ @@ -174,7 +180,9 @@ if ($view_graph) { else { ui_print_info_message ( array ( 'no_close' => true, 'message' => __('No data.') ) ); } - + if ($stacked == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){ + $stacked = 4; + } $period_label = human_time_description_raw ($period); echo "
"; echo ""; @@ -214,7 +222,15 @@ if ($view_graph) { $stackeds[CUSTOM_GRAPH_PIE] = __('Pie'); html_print_select ($stackeds, 'stacked', $stacked , '', '', -1, false, false); echo ""; - + + echo ""; + echo "
"; + echo "
  ".__('Equalize maximum thresholds')."" . + ui_print_help_tip (__("If an option is selected, all graphs will have the highest value from all modules included in the graph as a maximum threshold"), true); + + html_print_checkbox('threshold', CUSTOM_GRAPH_BULLET_CHART_THRESHOLD, $check, false, false, '', false); + echo "
"; + echo "
"; $zooms = array(); $zooms[0] = __('Graph defined'); @@ -260,6 +276,26 @@ if ($view_graph) { changeMonth: true, changeYear: true, showAnim: "slideDown"}); + + if ($("#stacked").val() == '4') { + $("#thresholdDiv").show(); + }else{ + $("#thresholdDiv").hide(); + } + + + }); + + $("#stacked").change(function(){ + if ($(this).val() == '4') { + console.log($(this).val()); + $("#thresholdDiv").show(); + $(".stacked").show(); + } else { + $("[name=threshold]").prop("checked", false); + $(".stacked").show(); + $("#thresholdDiv").hide(); + } });