Added the feature to set module charts painting with lines or area. TICKET: #1849

This commit is contained in:
mdtrooper 2015-06-11 21:24:14 +02:00
parent 19f74c8e78
commit 9789eca1e1
4 changed files with 168 additions and 73 deletions

View File

@ -317,6 +317,15 @@ $table->data[$row][1] .= __('No') . ' ' .
html_print_radio_button ('short_module_graph_data', 0, '',
$config["short_module_graph_data"], true);
$row++;
$table->data[$row][0] = __('Type of module charts');
$table->data[$row][1] = __('Area').' ' .
html_print_radio_button ('type_module_charts', 'area', '',
$config["type_module_charts"] == 'area', true).'  ';
$table->data[$row][1] .= __('Line').' ' .
html_print_radio_button ('type_module_charts', 'line', '',
$config["type_module_charts"] != 'area', true);
$row++;
//----------------------------------------------------------------------
@ -326,6 +335,24 @@ $row++;
$table->colspan[$row][0] = 2;
$table->data[$row][0] = __('Other configuration') . '<hr>';
$row++;
if (empty($config["vc_line_thickness"])) $config["vc_line_thickness"] = 2;
$table->data[$row][0] = __('Default line thickness for the Visual Console') . ui_print_help_tip(__('This interval will affect to the lines between elements on the Visual Console'), true);
$table->data[$row][1] = html_print_input_text ('vc_line_thickness', $config["vc_line_thickness"], '', 5, 5, true);
$row++;
// For 5.1 Autohidden menu feature
$table->data['autohidden'][0] = __('Autohidden menu');
$table->data['autohidden'][1] = html_print_checkbox('autohidden_menu',
1, $config['autohidden_menu'], true);
// Juanma (07/05/2014) New feature: Table for custom front page for reports
$table->data[$row][0] = __('Custom report front page') .
ui_print_help_tip(
__('Custom report front page. It will be applied to all reports and templates by default.'), true);
$table->data[$row][1] = html_print_checkbox('custom_report_front', 1,
$config['custom_report_front'], true);
$row++;
//----------------------------------------------------------------------
@ -337,10 +364,6 @@ $row++;
if (empty($config["vc_line_thickness"])) $config["vc_line_thickness"] = 2;
$table->data[$row][0] = __('Default line thickness for the Visual Console') . ui_print_help_tip(__('This interval will affect to the lines between elements on the Visual Console'), true);
$table->data[$row][1] = html_print_input_text ('vc_line_thickness', $config["vc_line_thickness"], '', 5, 5, true);
$row++;
@ -349,23 +372,12 @@ $row++;
// For 5.1 Autohidden menu feature
$table->data['autohidden'][0] = __('Autohidden menu');
$table->data['autohidden'][1] = html_print_checkbox('autohidden_menu',
1, $config['autohidden_menu'], true);
// Juanma (07/05/2014) New feature: Table for custom front page for reports
$table->data[$row][0] = __('Custom report front page') .
ui_print_help_tip(__('Custom report front page. It will be applied to all reports and templates by default.'), true);
$table->data[$row][1] = html_print_checkbox('custom_report_front', 1,
$config['custom_report_front'], true);
$row++;
$dirItems = scandir($config['homedir'] . '/images/custom_logo');
foreach ($dirItems as $entryDir) {
if (strstr($entryDir, '.jpg') !== false) {
$customLogos['images/custom_logo/' . $entryDir] = $entryDir;

View File

@ -459,6 +459,8 @@ function config_update_config () {
$error_update[] = __('Show the group name instead the group icon.');
if (!config_update_value ('custom_graph_width', (int) get_parameter('custom_graph_width', 1)))
$error_update[] = __('Default line thickness for the Custom Graph.');
if (!config_update_value ('type_module_charts', (string) get_parameter('type_module_charts', 'area')))
$error_update[] = __('Default type of module charts.');
if (!config_update_value ('render_proc', (bool) get_parameter('render_proc', false)))
$error_update[] = __('Render data of module type is proc.');
@ -1251,6 +1253,11 @@ function config_process_config () {
if (!isset($config['custom_graph_width'])) {
config_update_value ('custom_graph_width', 1);
}
if (!isset($config['type_module_charts'])) {
config_update_value ('type_module_charts', 'area');
}
if (!isset($config['render_proc'])) {
config_update_value ('render_proc', 0);
}

View File

@ -742,12 +742,12 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$series_suffix_str = ' (' . __('Previous') . ')';
// Build the data of the previous period
grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
$width, $height, $title, $unit_name,
$show_alerts, $avg_only,
$date-$period, $unit, $baseline, $return_data, $show_title,
$projection, $adapt_key, $compare,
$series_suffix, $series_suffix_str, $show_unknown);
grafico_modulo_sparse_data ($agent_module_id, $period,
$show_events, $width, $height, $title, $unit_name,
$show_alerts, $avg_only, $date-$period, $unit, $baseline,
$return_data, $show_title, $projection, $adapt_key,
$compare, $series_suffix, $series_suffix_str,
$show_unknown);
switch ($compare) {
case 'separated':
@ -759,7 +759,8 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$color_prev = $color;
break;
case 'overlapped':
// Store the chart calculated deleting index, because will be over the current period
// Store the chart calculated deleting index,
// because will be over the current period
$chart_prev = array_values($chart);
$legend_prev = $legend;
$series_type_prev = $series_type;
@ -806,26 +807,64 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
if ($compare === 'separated') {
return area_graph($flash_chart, $chart, $width, $height/2, $color, $legend,
$long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", $unit, $homeurl, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl,
$series_type, $chart_extra_data, $warning_min, $critical_min, $adapt_key, false,
$series_suffix_str, $menu, $backgroundColor).
'<br>'.
area_graph($flash_chart, $chart_prev, $width, $height/2, $color_prev, $legend_prev,
$long_index_prev, ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", $unit, $homeurl, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl,
$series_type_prev, $chart_extra_data, $warning_min, $critical_min, $adapt_key, false,
$series_suffix_str, $menu, $backgroundColor);
if ($config['type_module_charts'] === 'area') {
if ($compare === 'separated') {
return
area_graph($flash_chart, $chart, $width, $height/2, $color,
$legend, $long_index,
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", $unit, $homeurl, $water_mark, $config['fontpath'],
$config['font_size'], $unit, $ttl, $series_type,
$chart_extra_data, $warning_min, $critical_min,
$adapt_key, false, $series_suffix_str, $menu,
$backgroundColor).
'<br>'.
area_graph($flash_chart, $chart_prev, $width, $height/2,
$color_prev, $legend_prev, $long_index_prev,
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", $unit, $homeurl, $water_mark, $config['fontpath'],
$config['font_size'], $unit, $ttl, $series_type_prev,
$chart_extra_data, $warning_min, $critical_min,
$adapt_key, false, $series_suffix_str, $menu,
$backgroundColor);
}
else {
// Color commented not to restrict serie colors
return
area_graph($flash_chart, $chart, $width, $height, $color,
$legend, $long_index,
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", $unit, $homeurl, $water_mark, $config['fontpath'],
$config['font_size'], $unit, $ttl, $series_type,
$chart_extra_data, $warning_min, $critical_min,
$adapt_key, false, $series_suffix_str, $menu,
$backgroundColor);
}
}
else {
// Color commented not to restrict serie colors
return area_graph($flash_chart, $chart, $width, $height, $color, $legend,
$long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", $unit, $homeurl, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl,
$series_type, $chart_extra_data, $warning_min, $critical_min, $adapt_key, false,
$series_suffix_str, $menu, $backgroundColor);
elseif ($config['type_module_charts'] === 'line') {
if ($compare === 'separated') {
return
line_graph($flash_chart, $chart, $width, $height/2, $color,
$legend, $long_index,
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", $unit, $water_mark, $config['fontpath'],
$config['font_size'], $unit, $ttl, $homeurl, $backgroundColor).
'<br>'.
line_graph($flash_chart, $chart_prev, $width, $height/2, $color,
$legend, $long_index,
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", $unit, $water_mark, $config['fontpath'],
$config['font_size'], $unit, $ttl, $homeurl, $backgroundColor);
}
else {
// Color commented not to restrict serie colors
return
line_graph($flash_chart, $chart, $width, $height, $color,
$legend, $long_index,
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", $unit, $water_mark, $config['fontpath'],
$config['font_size'], $unit, $ttl, $homeurl, $backgroundColor);
}
}
}
@ -944,7 +983,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
else {
$module_number = count ($module_list);
}
$names_number = count($name_list);
$units_number = count($unit_list);
@ -1008,7 +1047,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
modules_get_agentmodule_name ($agent_module_id));
$module_name = sprintf(__("projection for %s"), $module_name);
$module_name = ui_print_truncate_text($module_name, 'module_small', false, true, false, '...', false);
$module_name_list[$i] = $agent_name ." / ". $module_name;
}
@ -1035,10 +1074,10 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$module_name = io_safe_output(
modules_get_agentmodule_name ($agent_module_id));
$module_name = ui_print_truncate_text($module_name, 'module_small', false, true, false, '...', false);
$module_name_list[$i] = $agent_name . " / " . $module_name;
}
$id_module_type = modules_get_agentmodule_type ($agent_module_id);
$module_type = modules_get_moduletype_name ($id_module_type);
$uncompressed_module = is_module_uncompressed ($module_type);
@ -1228,7 +1267,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$avg = round($avg / $countAvg, 1);
$graph_stats = get_graph_statistics($graph_values[$i]);
if (!isset($config["short_module_graph_data"]))
$config["short_module_graph_data"] = true;
@ -1242,17 +1281,17 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$min = sprintf("%sM", number_format($min / 1000000, 2));
else if ($min > 1000)
$min = sprintf("%sK", number_format($min / 1000, 2));
if ($max > 1000000)
$max = sprintf("%sM", number_format($max / 1000000, 2));
else if ($max > 1000)
$max = sprintf("%sK", number_format($max / 1000, 2));
if ($avg > 1000000)
$avg = sprintf("%sM", number_format($avg / 1000000, 2));
else if ($avg > 1000)
$avg = sprintf("%sK", number_format($avg / 1000, 2));
if ($last > 1000000)
$last = sprintf("%sM", number_format($last / 1000000, 2));
else if ($last > 1000)
@ -1265,7 +1304,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$last = number_format($graph_stats['last'], 2);
}
if (!empty($unit_list) && $units_number == $module_number && isset($unit_list[$i])) {
$unit = $unit_list[$i];
}
@ -3334,25 +3373,52 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("/images/logo_vertical_water.png", false, false, false));
if ($compare === 'separated') {
return area_graph($flash_chart, $chart, $width, $height/2, $color, $legend,
$long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", $unit, $homeurl, $water_mark,
$config['fontpath'], $config['font_size'], $unit, 1, $series_type,
$chart_extra_data, 0, 0, $adapt_key, false, $series_suffix_str, $menu).
'<br>'.
area_graph($flash_chart, $chart_prev, $width, $height/2, $color_prev, $legend_prev,
$long_index_prev, ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", $unit, $homeurl, $water_mark,
$config['fontpath'], $config['font_size'], $unit, 1, $series_type_prev,
$chart_extra_data_prev, 0, 0, $adapt_key, false, $series_suffix_str, $menu);
if ($config['type_module_charts'] === 'area') {
if ($compare === 'separated') {
return area_graph($flash_chart, $chart, $width, $height/2, $color, $legend,
$long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", $unit, $homeurl, $water_mark,
$config['fontpath'], $config['font_size'], $unit, 1, $series_type,
$chart_extra_data, 0, 0, $adapt_key, false, $series_suffix_str, $menu).
'<br>'.
area_graph($flash_chart, $chart_prev, $width, $height/2, $color_prev, $legend_prev,
$long_index_prev, ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", $unit, $homeurl, $water_mark,
$config['fontpath'], $config['font_size'], $unit, 1, $series_type_prev,
$chart_extra_data_prev, 0, 0, $adapt_key, false, $series_suffix_str, $menu);
}
else {
return area_graph($flash_chart, $chart, $width, $height, $color, $legend,
$long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", $unit, $homeurl, $water_mark,
$config['fontpath'], $config['font_size'], $unit, 1, $series_type,
$chart_extra_data, 0, 0, $adapt_key, false, $series_suffix_str, $menu);
}
}
else {
return area_graph($flash_chart, $chart, $width, $height, $color, $legend,
$long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", $unit, $homeurl, $water_mark,
$config['fontpath'], $config['font_size'], $unit, 1, $series_type,
$chart_extra_data, 0, 0, $adapt_key, false, $series_suffix_str, $menu);
elseif ($config['type_module_charts'] === 'line') {
if ($compare === 'separated') {
return
line_graph($flash_chart, $chart, $width, $height/2, $color,
$legend, $long_index,
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", $unit, $water_mark, $config['fontpath'],
$config['font_size'], $unit, $ttl, $homeurl, $backgroundColor).
'<br>'.
line_graph($flash_chart, $chart_prev, $width, $height/2, $color,
$legend, $long_index,
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", $unit, $water_mark, $config['fontpath'],
$config['font_size'], $unit, $ttl, $homeurl, $backgroundColor);
}
else {
// Color commented not to restrict serie colors
return
line_graph($flash_chart, $chart, $width, $height, $color,
$legend, $long_index,
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", $unit, $water_mark, $config['fontpath'],
$config['font_size'], $unit, $ttl, $homeurl, $backgroundColor);
}
}
}
@ -3855,10 +3921,20 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
$water_mark = array('file' => $config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
return area_graph($flash_chart, $chart, $width, $height, $color,
$legend, array(), '', "", $unit, $homeurl,
$water_mark, $config['fontpath'], $config['font_size'], $unit,
1, array(), array(), 0, 0, $adapt_key, true, '', $menu);
if ($config['type_module_charts'] === 'area') {
return area_graph($flash_chart, $chart, $width, $height, $color,
$legend, array(), '', "", $unit, $homeurl,
$water_mark, $config['fontpath'], $config['font_size'], $unit,
1, array(), array(), 0, 0, $adapt_key, true, '', $menu);
}
else {
return
line_graph($flash_chart, $chart, $width, $height, $color,
$legend, $long_index,
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", $unit, $water_mark, $config['fontpath'],
$config['font_size'], $unit, $ttl, $homeurl, $backgroundColor);
}
}
/**

View File

@ -356,7 +356,7 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend,
$labels_long = $labels;
}
if (!empty($legend)) {
$legend = io_safe_output(implode($separator,$legend));
$legend = io_safe_output(implode($separator, $legend));
}
$serie_types = implode($separator, $serie_types2);
$colors = implode($separator, $colors);