add fullscale combined and custom graph

This commit is contained in:
daniel 2018-01-03 12:13:00 +01:00
parent 6c48e6544a
commit ead1161e0b
10 changed files with 58 additions and 27 deletions

View File

@ -2,7 +2,6 @@ START TRANSACTION;
ALTER TABLE tsnmp_filter ADD unified_filters_id int(10) NOT NULL DEFAULT 0;
ALTER TABLE treport_content_template ADD COLUMN hide_no_data tinyint(1) DEFAULT 0;
ALTER TABLE treport_content ADD COLUMN hide_no_data tinyint(1) DEFAULT 0;
ALTER TABLE tgraph_source ADD COLUMN `field_order` int(10) NOT NULL default 0;
UPDATE tgraph_source c, (SELECT @n := 0) m SET c.field_order = @n := @n + 1;

View File

@ -5,4 +5,8 @@ ALTER TABLE `tlayout` ADD `is_favourite` int(1) NOT NULL DEFAULT 0;
SELECT max(unified_filters_id) INTO @max FROM tsnmp_filter;
UPDATE tsnmp_filter tsf,(SELECT @max:= @max) m SET tsf.unified_filters_id = @max:= @max + 1 where tsf.unified_filters_id=0;
ALTER TABLE tgraph ADD COLUMN `fullscale` tinyint(1) UNSIGNED NOT NULL default '0';
ALTER TABLE treport_content ADD COLUMN hide_no_data tinyint(1) DEFAULT 0;
COMMIT;

View File

@ -1265,6 +1265,7 @@ ALTER TABLE tgraph ADD COLUMN `percentil` int(4) unsigned default '0';
ALTER TABLE tgraph ADD COLUMN `summatory_series` tinyint(1) UNSIGNED NOT NULL default '0';
ALTER TABLE tgraph ADD COLUMN `average_series` tinyint(1) UNSIGNED NOT NULL default '0';
ALTER TABLE tgraph ADD COLUMN `modules_series` tinyint(1) UNSIGNED NOT NULL default '0';
ALTER TABLE tgraph ADD COLUMN `fullscale` tinyint(1) UNSIGNED NOT NULL default '0';
-- ---------------------------------------------------------------------
-- Table `tnetflow_filter`

View File

@ -69,6 +69,7 @@ if ($edit_graph) {
$summatory_series = $graphInTgraph['summatory_series'];
$average_series = $graphInTgraph['average_series'];
$modules_series = $graphInTgraph['modules_series'];
$fullscale = $graphInTgraph['fullscale'];
if ($stacked == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){
$stacked = CUSTOM_GRAPH_BULLET_CHART;
@ -90,10 +91,14 @@ else {
$summatory_series = 0;
$average_series = 0;
$modules_series = 0;
if($config['full_scale_option'] == 1){
$fullscale = 1;
}
else{
$fullscale = 0;
}
}
// -----------------------
// CREATE/EDIT GRAPH FORM
// -----------------------
@ -172,17 +177,14 @@ $stackeds = array(
);
html_print_select ($stackeds, 'stacked', $stacked);
echo "<div style='float:right' id='thresholdDiv' name='thresholdDiv'>&nbsp;&nbsp;<b>".__('Equalize maximum thresholds')."</b>" .
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 "</div>";
echo "</div></td>";
echo "</div></td></tr>";
echo "<tr><td class='datos2'><b>".__('Percentil')."</b></td>";
echo "<td class='datos2'>" . html_print_checkbox ("percentil", 1, $percentil, true) . "</td></tr>";
echo "<td class='datos2'>" . html_print_checkbox ("percentil", 1, $percentil, true) . "</td>";
echo "<td class='datos2'><div id='thresholdDiv' name='thresholdDiv'><b>".__('Equalize maximum thresholds')."</b>" .
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 "</div></td></tr>";
echo "<tr><td class='datos2'><b>".__('Add summatory series') .
ui_print_help_tip (__("Adds synthetic series to the graph, using all module
values to calculate the summation and/or average in each time interval.
@ -192,7 +194,10 @@ echo "<td class='datos2'>" . html_print_checkbox ("summatory_series", 1, $summat
echo "<td class='datos2'>" . html_print_checkbox ("average_series", 1, $average_series, true) . "</td></tr>";
echo "<tr><td class='datos2'><b>".__('Modules and series')."</b></td>";
echo "<td class='datos2'>" . html_print_checkbox ("modules_series", 1, $modules_series, true) . "</td></tr>";
echo "<td class='datos2'>" . html_print_checkbox ("modules_series", 1, $modules_series, true) . "</td>";
echo "<td class='datos2'><b>".__('Show full scale graph (TIP)') . ui_print_help_tip(__('This option may cause performance issues'), true) . "</td>";
echo "<td class='datos2'>" . html_print_checkbox ("fullscale", 1, $fullscale, true) . "</td>";
echo "</tr>";
echo "</table>";
if ($edit_graph) {

View File

@ -90,6 +90,7 @@ if ($add_graph) {
$summatory_series = get_parameter ("summatory_series", 0);
$average_series = get_parameter ("average_series", 0);
$modules_series = get_parameter ("modules_series", 0);
$fullscale = get_parameter ("fullscale", 0);
if ($threshold == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){
$stacked = $threshold;
@ -109,7 +110,8 @@ if ($add_graph) {
'percentil' => $percentil,
'summatory_series' => $summatory_series,
'average_series' => $average_series,
'modules_series' => $modules_series
'modules_series' => $modules_series,
'fullscale' => $fullscale
);
if (trim($name) != "") {
@ -142,6 +144,7 @@ if ($update_graph) {
$modules_series = get_parameter ("modules_series");
$alerts = get_parameter('alerts');
$threshold = get_parameter('threshold');
$fullscale = get_parameter('fullscale');
if ($threshold == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){
$stacked = $threshold;
@ -153,7 +156,7 @@ if ($update_graph) {
array('name' => $name, 'id_group' => $id_group, 'description' => $description,
'width' => $width, 'height' => $height, 'period' => $period, 'stacked' => $stacked,
'percentil' => $percentil, 'summatory_series' => $summatory_series,
'average_series' => $average_series, 'modules_series' => $modules_series),
'average_series' => $average_series, 'modules_series' => $modules_series, 'fullscale' => $fullscale),
array('id_graph' => $id_graph));
if ($success !== false)
db_pandora_audit("Report management", "Update graph #$id_graph");

View File

@ -164,7 +164,8 @@ function custom_graphs_print($id_graph, $height, $width, $period,
$background_color = 'white', $modules_param = array(), $homeurl = '',
$name_list = array(), $unit_list = array(), $show_last = true,
$show_max = true, $show_min = true, $show_avg = true, $ttl = 1,
$dashboard = false, $vconsole = false, $percentil = null, $from_interface = false,$id_widget_dashboard=false, $fullscale = false) {
$dashboard = false, $vconsole = false, $percentil = null,
$from_interface = false,$id_widget_dashboard=false, $fullscale = false) {
global $config;

View File

@ -1129,8 +1129,10 @@ function graphic_combined_module ($module_list, $weight_list, $period,
global $config;
global $graphic_type;
if(!$fullscale){
if(!$fullscale || $stacked >= 4){
$fullscale = 0;
$time_format_2 = '';
$temp_range = $period;
$unit_list_aux = array();
@ -2378,6 +2380,7 @@ function fullscale_data_combined($module_list, $period, $date, $flash_charts, $p
}
$datelimit = $date - $period;
$count_data_all = 0;
foreach ($module_list as $key_module => $value_module) {
if (!is_null($percentil) && $percentil) {
@ -2385,6 +2388,7 @@ function fullscale_data_combined($module_list, $period, $date, $flash_charts, $p
}
$data_uncompress = db_uncompress_module_data($value_module, $datelimit, $date);
foreach ($data_uncompress as $key_data => $value_data) {
foreach ($value_data['data'] as $k => $v) {
if($flash_charts) {
@ -2401,16 +2405,27 @@ function fullscale_data_combined($module_list, $period, $date, $flash_charts, $p
$data_all[$real_date][$key_module] = $v['datos'];
}
}
if (!is_null($percentil) && $percentil) {
$percentil_value = get_percentile($config['percentil'], $array_percentil);
$percentil_result[$key_module] = array_fill (0, count($data_all), $percentil_value);
if(count($data_all) > $count_data_all){
$count_data_all = count($data_all);
}
}
}
if (!is_null($percentil) && $percentil) {
foreach ($percentil_result as $k => $v){
if(count($v) < $count_data_all){
$percentil_result[$k] = array_fill (0, $count_data_all, $v[0]);
}
}
}
$data_prev = array();
//ksort($data_all);
ksort($data_all);
foreach ($data_all as $key => $value) {
foreach ($module_list as $key_module => $value_module) {
if(!isset($value[$key_module])){

View File

@ -208,7 +208,7 @@ function reporting_make_reporting_data($report = null, $id_report,
}
if(sizeof($content['id_agent_module']) != 1){
$content['style']['name_label'] = str_replace("_module_",sizeof($content['id_agent_module']).__(' modules'),$content['style']['name_label']);
$content['style']['name_label'] = str_replace("_module_",sizeof($content['id_agent_module']).__(' modules'),$content['style']['name_label']);
}
$content['name'] = reporting_label_macro($items_label, $content['style']['name_label']);
@ -6393,7 +6393,7 @@ function reporting_general($report, $content) {
function reporting_custom_graph($report, $content, $type = 'dinamic',
$force_width_chart = null, $force_height_chart = null, $type_report = "custom_graph") {
global $config;
require_once ($config["homedir"] . '/include/functions_graph.php');
@ -6412,7 +6412,7 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
}
$return['title'] = $content['name'];
$return['subtitle'] = $graph['name'];
$return['subtitle'] = io_safe_output($graph['name']);
$return["description"] = $content["description"];
$return["date"] = reporting_get_date_text(
$report,
@ -6520,7 +6520,7 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
$graph["percentil"],
false,
false,
false,
$graph["fullscale"],
$graph["summatory_series"],
$graph["average_series"],
$graph["modules_series"]
@ -6533,7 +6533,7 @@ function reporting_custom_graph($report, $content, $type = 'dinamic',
if ($config['metaconsole'] && $type_report != 'automatic_graph') {
metaconsole_restore_db();
}
return reporting_check_structure_content($return);
}

View File

@ -66,7 +66,7 @@ if ($view_graph) {
$sql="SELECT * FROM tgraph WHERE id_graph = $id_graph";
$graph = db_get_row_sql($sql);
$id_user = $graph["id_user"];
$private = $graph["private"];
$width = $graph["width"];
@ -106,6 +106,7 @@ if ($view_graph) {
$stacked = (int) get_parameter ('stacked', -1);
$percentil = ($graph['percentil']) ? 1 : null;
$check = get_parameter('threshold',false);
$fullscale = ($graph['fullscale']) ? 1 : null;
if($check == CUSTOM_GRAPH_BULLET_CHART_THRESHOLD){
$check = true;
@ -179,7 +180,8 @@ if ($view_graph) {
"images/chart.png", false, "", false, $options);
$graph_return = custom_graphs_print($id_graph, $height, $width, $period, $stacked, true, $unixdate, false, 'white',
array(), '', array(), array(), true, true, true, true, 1, false, false, $percentil, false);
array(), '', array(), array(), true, true, true, true, 1, false, false, $percentil, false, false, $fullscale);
if ($graph_return){
echo "<table class='databox filters' cellpadding='0' cellspacing='0' width='100%'>";
echo "<tr><td>";

View File

@ -1193,6 +1193,7 @@ CREATE TABLE IF NOT EXISTS `tgraph` (
`summatory_series` tinyint(1) UNSIGNED NOT NULL default 0,
`average_series` tinyint(1) UNSIGNED NOT NULL default 0,
`modules_series` tinyint(1) UNSIGNED NOT NULL default 0,
`fullscale` tinyint(1) UNSIGNED NOT NULL default 0,
PRIMARY KEY(`id_graph`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8;