Add percentil dinamic custom graph

This commit is contained in:
daniel 2016-12-27 13:10:33 +01:00
parent a376105f97
commit 50c9763720
8 changed files with 52 additions and 42 deletions

View File

@ -65,6 +65,7 @@ if ($edit_graph) {
$width = $graphInTgraph['width']; $width = $graphInTgraph['width'];
$height = $graphInTgraph['height']; $height = $graphInTgraph['height'];
$check = false; $check = false;
$percentil = $graphInTgraph['percentil'];
if ($stacked == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){ if ($stacked == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){
$stacked = CUSTOM_GRAPH_BULLET_CHART; $stacked = CUSTOM_GRAPH_BULLET_CHART;
@ -82,6 +83,7 @@ else {
$factor = 1; $factor = 1;
$stacked = 4; $stacked = 4;
$check = false; $check = false;
$percentil = 0;
} }
@ -170,10 +172,11 @@ echo "<div style='float:right' id='thresholdDiv' name='thresholdDiv'>&nbsp;&nbsp
html_print_checkbox('threshold', CUSTOM_GRAPH_BULLET_CHART_THRESHOLD, $check, false, false, '', false); html_print_checkbox('threshold', CUSTOM_GRAPH_BULLET_CHART_THRESHOLD, $check, false, false, '', false);
echo "</div>"; echo "</div>";
echo "</div></td>"; echo "</div></td>";
echo "<tr><td class='datos2'><b>".__('Type of graph')."</b></td>";
echo "<td class='datos2'>" . html_print_checkbox ("percentil", 1, $percentil, true) . "</td></tr>";
echo "</table>"; echo "</table>";
if ($edit_graph) { if ($edit_graph) {

View File

@ -75,6 +75,7 @@ if ($add_graph) {
$stacked = get_parameter ("stacked", 0); $stacked = get_parameter ("stacked", 0);
$period = get_parameter_post ("period"); $period = get_parameter_post ("period");
$threshold = get_parameter('threshold'); $threshold = get_parameter('threshold');
$percentil = get_parameter ("percentil", 0);
if ($threshold == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){ if ($threshold == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){
$stacked = $threshold; $stacked = $threshold;
@ -90,7 +91,9 @@ if ($add_graph) {
'height' => $height, 'height' => $height,
'private' => 0, 'private' => 0,
'id_group' => $idGroup, 'id_group' => $idGroup,
'stacked' => $stacked); 'stacked' => $stacked,
'percentil' => $percentil
);
if (trim($name) != "") { if (trim($name) != "") {
$id_graph = db_process_sql_insert('tgraph', $values); $id_graph = db_process_sql_insert('tgraph', $values);
@ -116,6 +119,7 @@ if ($update_graph) {
$height = get_parameter('height'); $height = get_parameter('height');
$period = get_parameter('period'); $period = get_parameter('period');
$stacked = get_parameter('stacked'); $stacked = get_parameter('stacked');
$percentil = get_parameter('percentil');
$alerts = get_parameter('alerts'); $alerts = get_parameter('alerts');
$threshold = get_parameter('threshold'); $threshold = get_parameter('threshold');
@ -126,7 +130,7 @@ if ($update_graph) {
if (trim($name) != "") { if (trim($name) != "") {
$success = db_process_sql_update('tgraph', $success = db_process_sql_update('tgraph',
array('name' => $name, 'id_group' => $id_group, 'description' => $description, 'width' => $width, 'height' => $height, 'period' => $period, 'stacked' => $stacked), array('name' => $name, 'id_group' => $id_group, 'description' => $description, 'width' => $width, 'height' => $height, 'period' => $period, 'stacked' => $stacked, 'percentil' => $percentil ),
array('id_graph' => $id_graph)); array('id_graph' => $id_graph));
if ($success !== false) if ($success !== false)
db_pandora_audit("Report management", "Update graph #$id_graph"); db_pandora_audit("Report management", "Update graph #$id_graph");

View File

@ -1743,14 +1743,14 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$temp[$timestamp_point][$graph_group] = $point_value; $temp[$timestamp_point][$graph_group] = $point_value;
} }
$percentile_value = get_percentile($percentil, $point); $percentile_value = get_percentile($config['percentil'], $point);
$percentil_result[$graph_group] = array_fill ( 0, count($point), $percentile_value); $percentil_result[$graph_group] = array_fill ( 0, count($point), $percentile_value);
$series_type[$graph_group] = 'line'; $series_type[$graph_group] = 'line';
$agent_name = io_safe_output( $agent_name = io_safe_output(
modules_get_agentmodule_agent_name ($module_list[$graph_group])); modules_get_agentmodule_agent_name ($module_list[$graph_group]));
$module_name = io_safe_output( $module_name = io_safe_output(
modules_get_agentmodule_name ($module_list[$graph_group])); modules_get_agentmodule_name ($module_list[$graph_group]));
$module_name_list['percentil'.$graph_group] = __('Percentile %dº', $percentil) . __(' of module ') . $agent_name .' / ' . $module_name . ' (' . $percentile_value . ' ' . $unit . ') '; $module_name_list['percentil'.$graph_group] = __('Percentile %dº', $config['percentil']) . __(' of module ') . $agent_name .' / ' . $module_name . ' (' . $percentile_value . ' ' . $unit . ') ';
} }
} }
else { else {
@ -1869,7 +1869,6 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$red_threshold = $compare_critical; $red_threshold = $compare_critical;
} }
} }
switch ($stacked) { switch ($stacked) {
case CUSTOM_GRAPH_AREA: case CUSTOM_GRAPH_AREA:
return area_graph($flash_charts, $graph_values, $width, return area_graph($flash_charts, $graph_values, $width,
@ -1877,7 +1876,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
ui_get_full_url("images/image_problem.opaque.png", false, false, false), ui_get_full_url("images/image_problem.opaque.png", false, false, false),
$title, "", $homeurl, $water_mark, $config['fontpath'], $title, "", $homeurl, $water_mark, $config['fontpath'],
$fixed_font_size, $unit, $ttl, array(), array(), $yellow_threshold, $red_threshold, '', $fixed_font_size, $unit, $ttl, array(), array(), $yellow_threshold, $red_threshold, '',
false, '', true, $background_color,$dashboard, $vconsole); false, '', true, $background_color,$dashboard, $vconsole, 0, $percentil_result);
break; break;
default: default:
case CUSTOM_GRAPH_STACKED_AREA: case CUSTOM_GRAPH_STACKED_AREA:

View File

@ -5607,7 +5607,6 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
} }
$graph = db_get_row ("tgraph", "id_graph", $content['id_gs']); $graph = db_get_row ("tgraph", "id_graph", $content['id_gs']);
$return = array(); $return = array();
$return['type'] = 'custom_graph'; $return['type'] = 'custom_graph';
@ -5684,7 +5683,11 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
true, true,
true, true,
true, true,
$labels); $labels,
false,
false,
$graph["percentil"]
);
break; break;
case 'data': case 'data':
break; break;

View File

@ -770,19 +770,16 @@ function visual_map_print_item($mode = "read", $layoutData,
if ($layoutData['id_custom_graph'] != 0) { if ($layoutData['id_custom_graph'] != 0) {
// Show only avg on the visual console // Show only avg on the visual console
if(get_parameter('action') == 'edit'){ if(get_parameter('action') == 'edit'){
$img = '<img src="images/console/signes/custom_graph.png" style="width:'.$width.'px;height:'.$height.'px;">';
$img = '<img src="images/console/signes/custom_graph.png" style="width:'.$width.'px;height:'.$height.'px;">'; }
}
else{ else{
$img = custom_graphs_print( $img = custom_graphs_print(
$layoutData['id_custom_graph'], $height, $width, $layoutData['id_custom_graph'], $height, $width,
$period, null, true, 0, false, $layoutData['image'], $period, null, true, 0, false, $layoutData['image'],
array(), '', array(), array(), true, array(), '', array(), array(), true,
false, false, true, 1, false, true); false, false, true, 1, false, true, $layoutData['percentil']
);
} }
@ -794,19 +791,15 @@ function visual_map_print_item($mode = "read", $layoutData,
$homeurl = ''; $homeurl = '';
if(get_parameter('action') == 'edit'){ if(get_parameter('action') == 'edit'){
$img = '<img src="images/console/signes/module_graph.png" style="width:'.$width.'px;height:'.$height.'px;">';
$img = '<img src="images/console/signes/module_graph.png" style="width:'.$width.'px;height:'.$height.'px;">'; }
else {
} $img = grafico_modulo_sparse($id_module, $period, 0, $width, $height, '', null,
else{ false, 1, false, 0, '', 0, 0, true, false, '', 1, false,
'', false, false, false, $layoutData['image'], null, true,
$img = grafico_modulo_sparse($id_module, $period, 0,$width,$height, false,$type_graph);
'',null, }
false, 1, false, 0, '', 0, 0, true, false, '', 1, false, }
'', false, false, false, $layoutData['image'], null, true, false,$type_graph);
}
}
//Restore db connection //Restore db connection
if ($layoutData['id_metaconsole'] != 0) { if ($layoutData['id_metaconsole'] != 0) {
@ -2193,7 +2186,12 @@ function visual_map_print_visual_map ($id_layout, $show_links = true,
'proportion_height' => $proportion_height, 'proportion_height' => $proportion_height,
'proportion_width' => $proportion_width); 'proportion_width' => $proportion_width);
} }
if($layout_data['id_custom_graph']){
$layout_data['percentil'] = db_get_value ("percentil", "tgraph",
"id_graph", $layout_data["id_custom_graph"]);
}
switch ($layout_data['type']) { switch ($layout_data['type']) {
case LINE_ITEM: case LINE_ITEM:
visual_map_print_user_lines($layout_data, $proportion); visual_map_print_user_lines($layout_data, $proportion);

View File

@ -219,7 +219,7 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color,
$chart_extra_data = array(), $yellow_threshold = 0, $chart_extra_data = array(), $yellow_threshold = 0,
$red_threshold = 0, $adapt_key = '', $force_integer = false, $red_threshold = 0, $adapt_key = '', $force_integer = false,
$series_suffix_str = '', $menu = true, $backgroundColor = 'white', $series_suffix_str = '', $menu = true, $backgroundColor = 'white',
$dashboard = false, $vconsole = false, $agent_module_id = 0) { $dashboard = false, $vconsole = false, $agent_module_id = 0, $percentil_values = array()) {
include_once('functions_flot.php'); include_once('functions_flot.php');
@ -266,7 +266,9 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color,
$agent_module_id, $agent_module_id,
$font, $font,
$font_size, $font_size,
$xaxisname); $xaxisname,
$percentil_values
);
} }
else { else {
$graph = array(); $graph = array();

View File

@ -118,7 +118,8 @@ function flot_area_simple_graph($chart_data, $width, $height, $color,
$yellow_threshold = 0, $red_threshold = 0, $adapt_key= '', $yellow_threshold = 0, $red_threshold = 0, $adapt_key= '',
$force_integer = false, $series_suffix_str = '', $menu = true, $force_integer = false, $series_suffix_str = '', $menu = true,
$background_color = 'white', $dashboard = false, $vconsole = false, $background_color = 'white', $dashboard = false, $vconsole = false,
$agent_module_id = 0, $font = '', $font_size = 7, $xaxisname = '') { $agent_module_id = 0, $font = '', $font_size = 7, $xaxisname = '',
$percentil_values = array()) {
global $config; global $config;
@ -127,7 +128,7 @@ function flot_area_simple_graph($chart_data, $width, $height, $color,
$water_mark, $serie_types, $chart_extra_data, $yellow_threshold, $water_mark, $serie_types, $chart_extra_data, $yellow_threshold,
$red_threshold, $adapt_key, $force_integer, $series_suffix_str, $red_threshold, $adapt_key, $force_integer, $series_suffix_str,
$menu, $background_color, $dashboard, $vconsole, $menu, $background_color, $dashboard, $vconsole,
$agent_module_id, $font, $font_size, $xaxisname); $agent_module_id, $font, $font_size, $xaxisname, $percentil_values);
} }
function flot_line_stacked_graph($chart_data, $width, $height, $color, function flot_line_stacked_graph($chart_data, $width, $height, $color,

View File

@ -94,6 +94,7 @@ if ($view_graph) {
$events = $graph["events"]; $events = $graph["events"];
$description = $graph["description"]; $description = $graph["description"];
$stacked = (int) get_parameter ('stacked', -1); $stacked = (int) get_parameter ('stacked', -1);
$percentil = (int) get_parameter ('percentil', 0);
$check = get_parameter('threshold',false); $check = get_parameter('threshold',false);
if($check == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){ if($check == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){
@ -164,9 +165,8 @@ if ($view_graph) {
__('Custom graphs') . " - " . $graph['name'], __('Custom graphs') . " - " . $graph['name'],
"images/chart.png", false, "", false, $options); "images/chart.png", false, "", false, $options);
$graph_return = custom_graphs_print($id_graph, $height, $width, $period, $stacked, $graph_return = custom_graphs_print($id_graph, $height, $width, $period, $stacked, true, $unixdate, false, 'white',
true, $unixdate); array(), '', array(), array(), true, true, true, true, 1, false, false, $percentil, false);
if ($graph_return){ if ($graph_return){
echo "<table class='databox filters' cellpadding='0' cellspacing='0' width='100%'>"; echo "<table class='databox filters' cellpadding='0' cellspacing='0' width='100%'>";
echo "<tr><td>"; echo "<tr><td>";