From 77a563eb299bf7ca3070b78e72716a12ce342f2f Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Thu, 11 May 2017 14:00:59 +0200 Subject: [PATCH 001/152] Added new general table view to html --- .../reporting_builder.item_editor.php | 19 +++ .../godmode/reporting/reporting_builder.php | 2 + .../include/functions_reporting.php | 9 +- .../include/functions_reporting_html.php | 114 ++++++++++++------ 4 files changed, 101 insertions(+), 43 deletions(-) diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 2e974b85fe..d303802475 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -120,6 +120,7 @@ switch ($action) { $description = null; $sql = null; $show_in_two_columns = 0; + $show_in_same_row = 0; $show_in_landscape = 0; $hide_notinit_agents = 0; $server_name = ''; @@ -158,6 +159,7 @@ switch ($action) { $description = null; $sql = null; $show_in_two_columns = 0; + $show_in_same_row = 0; $show_in_landscape = 0; $hide_notinit_agents = 0; $server_name = ''; @@ -182,6 +184,7 @@ switch ($action) { $style = json_decode(io_safe_output($item['style']), true); + $show_in_same_row = $style['show_in_same_row']; $show_in_two_columns = $style['show_in_two_columns']; $show_in_landscape = $style['show_in_landscape']; $hide_notinit_agents = $style['hide_notinit_agents']; @@ -1468,6 +1471,20 @@ You can of course remove the warnings, that's why we include the source and do n + + + + + + + + + @@ -2579,6 +2596,7 @@ function chooseType() { $("#row_exception_condition_value").hide(); $("#row_exception_condition").hide(); $("#row_show_in_two_columns").hide(); + $("#row_show_in_same_row").hide(); $("#row_show_in_landscape").hide(); $('#row_hide_notinit_agents').hide(); $("#row_module_group").hide(); @@ -2976,6 +2994,7 @@ function chooseType() { $("#row_order_uptodown").show(); $("#row_show_resume").show(); $("#row_show_in_two_columns").show(); + $("#row_show_in_same_row").show(); var checked = $("input[name='last_value']").prop("checked"); diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 8bc38bdc78..b55741d45c 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1139,6 +1139,7 @@ switch ($action) { $style = array(); $style['show_in_two_columns'] = get_parameter('show_in_two_columns', 0); + $style['show_in_same_row'] = get_parameter('show_in_same_row', 0); $style['show_in_landscape'] = get_parameter('show_in_landscape', 0); $style['hide_notinit_agents'] = get_parameter('hide_notinit_agents', 0); @@ -1459,6 +1460,7 @@ switch ($action) { $style = array(); $style['show_in_two_columns'] = get_parameter('show_in_two_columns', 0); + $style['show_in_same_row'] = get_parameter('show_in_same_row', 0); $style['show_in_landscape'] = get_parameter('show_in_landscape', 0); $style['hide_notinit_agents'] = get_parameter('hide_notinit_agents', 0); diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 3d05c2099f..1b852c8b83 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -5471,9 +5471,8 @@ function reporting_availability_graph($report, $content, $pdf=false) { * */ function reporting_general($report, $content) { - global $config; - + $return = array(); $return['type'] = 'general'; $return['subtype'] = $content['group_by_agent']; @@ -5501,6 +5500,7 @@ function reporting_general($report, $content) { $return["max"]["formated_value"] = null; $return["max"]["agent"] = null; $return["max"]["module"] = null; + $return["show_in_same_row"] = $content['style']['show_in_same_row']; if (empty($content['subitems'])) { $generals = db_get_all_rows_filter( @@ -5692,8 +5692,9 @@ function reporting_general($report, $content) { $data = array(); $data['agent'] = $agent_name[$i]; $data['module'] = $module_name[$i]; - - + $data['id_agent_module'] = $id_agent_module[$i]; + $data['id_agent'] = agents_get_agent_id_by_module_id($id_agent_module[$i]); + $data['operator'] = ""; if ($content['period'] != 0) { switch ($operations[$i]) { diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index f6acad7fbe..a05f297312 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2578,50 +2578,86 @@ function get_agent_first_time ($agent_name) { } function reporting_html_general(&$table, $item) { - if (!empty($item["data"])) { + $data_in_same_row = $item['show_in_same_row']; switch ($item['subtype']) { case REPORT_GENERAL_NOT_GROUP_BY_AGENT: - $table1 = new stdClass(); - $table1->width = '99%'; - $table1->data = array (); - $table1->head = array (); - $table1->head[0] = __('Agent'); - $table1->head[1] = __('Module'); - if ($item['date']['period'] != 0) { - $table1->head[2] = __('Operation'); - } - $table1->head[3] = __('Value'); - $table1->style[0] = 'text-align: left'; - $table1->style[1] = 'text-align: left'; - $table1->style[2] = 'text-align: left'; - $table1->style[3] = 'text-align: left'; - - /* Begin - Order by agent */ - - foreach ($item['data'] as $key => $row) { - $aux[$key] = $row['agent']; - } - - array_multisort($aux, SORT_ASC, $item['data']); - - /* End - Order by agent */ - - foreach ($item['data'] as $row) { + if (!$data_in_same_row) { + $table1 = new stdClass(); + $table1->width = '99%'; + $table1->data = array (); + $table1->head = array (); + $table1->head[0] = __('Agent'); + $table1->head[1] = __('Module'); if ($item['date']['period'] != 0) { - $table1->data[] = array( - $row['agent'], - $row['module'], - $row['operator'], - $row['formated_value']); + $table1->head[2] = __('Operation'); } - else { - $table1->data[] = array( - $row['agent'], - $row['module'], - $row['formated_value']); + $table1->head[3] = __('Value'); + $table1->style[0] = 'text-align: left'; + $table1->style[1] = 'text-align: left'; + $table1->style[2] = 'text-align: left'; + $table1->style[3] = 'text-align: left'; + + /* Begin - Order by agent */ + + foreach ($item['data'] as $key => $row) { + $aux[$key] = $row['agent']; + } + + array_multisort($aux, SORT_ASC, $item['data']); + + /* End - Order by agent */ + + foreach ($item['data'] as $row) { + if ($item['date']['period'] != 0) { + $table1->data[] = array( + $row['agent'], + $row['module'], + $row['operator'], + $row['formated_value']); + } + else { + $table1->data[] = array( + $row['agent'], + $row['module'], + $row['formated_value']); + } } } + else { + //html_debug($item['data']); + $order_data = array(); + foreach ($item['data'] as $row) { + $order_data[$row['id_agent']][$row['id_agent_module']][$row['operator']] = $row['formated_value']; + } + + $table1 = new stdClass(); + $table1->width = '99%'; + $table1->data = array (); + $table1->head = array (); + $table1->head[0] = __('Agent'); + $table1->head[1] = __('Module'); + $table1->head[2] = __('Avg'); + $table1->head[3] = __('Max'); + $table1->head[4] = __('Min'); + $table1->style[0] = 'text-align: center'; + $table1->style[1] = 'text-align: center'; + $table1->style[2] = 'text-align: center'; + $table1->style[3] = 'text-align: center'; + $table1->style[4] = 'text-align: center'; + + foreach ($order_data as $id_agent => $row) { + foreach ($row as $id_module => $row2) { + $table1->data[] = array( + agents_get_alias($id_agent), + modules_get_agentmodule_name($id_module), + $row2['Rate'], + $row2['Maximum'], + $row2['Minimum']); + } + } + } + break; case REPORT_GENERAL_GROUP_BY_AGENT: $list_modules = array(); @@ -2639,9 +2675,9 @@ function reporting_html_general(&$table, $item) { $row = array(); $row['agent'] = $agent; - $table1->style['agent'] = 'text-align: left;'; + $table1->style['agent'] = 'text-align: center;'; foreach ($list_modules as $name) { - $table1->style[$name] = 'text-align: right;'; + $table1->style[$name] = 'text-align: center;'; if (isset($modules[$name])) { $row[$name] = $modules[$name]; } From 8653b8530c7dc86a40737d78e9e7d51b2d5ff5a1 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Thu, 11 May 2017 15:12:38 +0200 Subject: [PATCH 002/152] Removed trace --- pandora_console/include/functions_reporting_html.php | 1 - 1 file changed, 1 deletion(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index a05f297312..16a83b6526 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2625,7 +2625,6 @@ function reporting_html_general(&$table, $item) { } } else { - //html_debug($item['data']); $order_data = array(); foreach ($item['data'] as $row) { $order_data[$row['id_agent']][$row['id_agent_module']][$row['operator']] = $row['formated_value']; From 913aa4334be02771dad8703214cbfae4c29612a5 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Thu, 18 May 2017 17:06:49 +0200 Subject: [PATCH 003/152] Save work and continue with more tests --- pandora_console/include/functions_db.php | 15 ++- pandora_console/include/functions_graph.php | 99 ++++++++----------- .../operation/agentes/stat_win.php | 11 ++- 3 files changed, 60 insertions(+), 65 deletions(-) diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index e682e1e138..f2c1627304 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -569,7 +569,13 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f if ((!isset($tstart)) || ($tstart === false)) { // Return data from the begining - $tstart = 0; + // Get first available utimestamp in active DB + $query_first_man_time = " SELECT utimestamp FROM tagente_datos "; + $query_first_man_time .= " WHERE id_agente_modulo = $id_agente_modulo"; + $query_first_man_time .= " ORDER BY utimestamp ASC LIMIT 1"; + + $first_man_time = db_get_all_rows_sql( $query_first_man_time, false); + $tstart = $first_man_time[0]['utimestamp']; } if ((!isset($tend)) || ($tend === false)) { @@ -581,7 +587,6 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f return false; } - $search_historydb = false; $table = "tagente_datos"; @@ -596,13 +601,11 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f $table = "tagente_datos_string"; } - // Get first available utimestamp in active DB $query = " SELECT utimestamp, datos FROM $table "; $query .= " WHERE id_agente_modulo=$id_agente_modulo AND utimestamp < $tstart"; $query .= " ORDER BY utimestamp DESC LIMIT 1"; - $ret = db_get_all_rows_sql( $query , $search_historydb); if ( ( $ret === false ) || (( isset($ret[0]["utimestamp"]) && ($ret[0]["utimestamp"] > $tstart )))) { @@ -610,6 +613,10 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f $search_historydb = true; $ret = db_get_all_rows_sql( $query , $search_historydb); + + if ($ret) { + $tstart = $ret[0]["utimestamp"]; + } } else { $first_data["utimestamp"] = $ret[0]["utimestamp"]; diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 8582655e82..8221d0b7c8 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -239,7 +239,7 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i global $series_type; global $max_value; global $min_value; - + $max_value = 0; $min_value = null; $flash_chart = $config['flash_charts']; @@ -252,12 +252,10 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i // Calculate chart data $last_known = $previous_data; - - + for ($i = 0; $i <= $resolution; $i++) { $timestamp = $datelimit + ($interval * $i); - $total = 0; $count = 0; @@ -458,20 +456,6 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i $series_type['unknown'.$series_suffix] = 'area'; } - //$chart[$timestamp]['count'] = 0; - ///////// - //$chart[$timestamp]['timestamp_bottom'] = $timestamp; - //$chart[$timestamp]['timestamp_top'] = $timestamp + $interval; - ///////// - - //Baseline was replaced by compare graphs feature - /*if ($baseline) { - $chart[$timestamp]['baseline'.$series_suffix] = array_shift ($baseline_data); - if ($chart[$timestamp]['baseline'.$series_suffix] == NULL) { - $chart[$timestamp]['baseline'.$series_suffix] = 0; - } - }*/ - if (!empty($event_ids)) { $chart_extra_data[count($chart)-1]['events'] = implode(',',$event_ids); } @@ -498,7 +482,8 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $show_alerts = false, $avg_only = 0, $date = 0, $unit = '', $baseline = 0, $return_data = 0, $show_title = true, $projection = false, $adapt_key = '', $compare = false, $series_suffix = '', $series_suffix_str = '', - $show_unknown = false, $percentil = null, $dashboard = false, $vconsole = false,$type_graph='area') { + $show_unknown = false, $percentil = null, $dashboard = false, $vconsole = false, + $type_graph='area', $fullscale = false) { global $config; global $chart; @@ -612,7 +597,24 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $min_necessary = 2; } - + + if ($fullscale) { + $all_data = db_uncompress_module_data($agent_module_id, time() - $period); + + $new_uncompress_data = array(); + $index = 0; + foreach ($all_data as $uncompress_data) { + foreach ($uncompress_data['data'] as $mod_data) { + $new_uncompress_data[$index]['datos'] = $mod_data['datos']; + $new_uncompress_data[$index]['utimestamp'] = $mod_data['utimestamp']; + $index++; + } + } + $new_uncompress_data[$index - 1]['id_agente_modulo'] = $agent_module_id; + + $data = $new_uncompress_data; + } + // Check available data if (count ($data) < $min_necessary) { if (!$graphic_type) { @@ -655,6 +657,11 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, if (empty($unit)) { $unit = modules_get_unit($agent_module_id); } + + if ($fullscale) { + $resolution = count($data); //Number of points of the graph + $interval = (int) ($period / $resolution); + } // Calculate chart data grafico_modulo_sparse_data_chart ($chart, $chart_data_extra, $long_index, @@ -663,9 +670,12 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $show_events, $show_alerts, $show_unknown, $baseline, $baseline_data, $events, $series_suffix, $start_unknown, $percentil); - - - + + html_debug("DATA: ", true); + html_debug(count($data), true); + html_debug("CHART: ", true); + html_debug(count($chart), true); + // Return chart data and don't draw if ($return_data == 1) { return $chart; @@ -762,12 +772,6 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, else { $legend['sum'.$series_suffix] = __('Avg').$series_suffix_str.': '.__('Avg').': '.remove_right_zeros(number_format($graph_stats['sum']['avg'], $config['graph_precision'])).' '.$unit.' ; '.__('Max').': '.remove_right_zeros(number_format($graph_stats['sum']['max'], $config['graph_precision'])).' '.$unit.' ; '.__('Min').': '.remove_right_zeros(number_format($graph_stats['sum']['min'], $config['graph_precision'])).' '.$unit; } - //Baseline was replaced by compare graph feature - /*if ($baseline) { - $legend['baseline'.$series_suffix] = __('Baseline'); - }*/ - //$legend['no_data'.$series_suffix] = __('No data').$series_suffix_str; - //$chart_extra_data['legend_no_data'] = $legend['no_data'.$series_suffix_str]; if ($show_unknown) { $legend['unknown'.$series_suffix] = __('Unknown').$series_suffix_str; @@ -790,7 +794,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $only_image = false, $homeurl = '', $ttl = 1, $projection = false, $adapt_key = '', $compare = false, $show_unknown = false, $menu = true, $backgroundColor = 'white', $percentil = null, - $dashboard = false, $vconsole = false, $type_graph = 'area') { + $dashboard = false, $vconsole = false, $type_graph = 'area', $fullscale = false) { global $config; global $graphic_type; @@ -820,7 +824,8 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $show_alerts, $avg_only, $date-$period, $unit, $baseline, $return_data, $show_title, $projection, $adapt_key, $compare, $series_suffix, $series_suffix_str, - $show_unknown, $percentil, $dashboard, $vconsole,$type_graph); + $show_unknown, $percentil, $dashboard, $vconsole,$type_graph, + $fullscale); switch ($compare) { case 'separated': @@ -853,7 +858,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events, $show_alerts, $avg_only, $date, $unit, $baseline, $return_data, $show_title, $projection, $adapt_key, $compare, '', '', $show_unknown, - $percentil, $dashboard, $vconsole,$type_graph); + $percentil, $dashboard, $vconsole, $type_graph, $fullscale); if ($return_data) { @@ -3598,8 +3603,7 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, global $long_index; global $series_type; global $chart_extra_data; - - + $chart = array(); $color = array(); $legend = array(); @@ -3834,13 +3838,6 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, $series_type['alert'.$series_suffix] = 'points'; } - //The order filling the array is very important to get the same colors - //in legends and graphs!!! - //Boolean graph doesn't have max!!! - /*if (!$avg_only) { - $chart[$timestamp]['max'.$series_suffix] = 0; - }*/ - // Data and zeroes (draw a step) if ($zero == 1 && $count > 0) { @@ -3875,11 +3872,6 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, $series_type['sum' . $series_suffix] = 'boolean'; - //Boolean graph doesn't have min!!! - /*if (!$avg_only) { - $chart[$timestamp]['min'.$series_suffix] = 0; - }*/ - if (!empty($event_ids)) { $chart_extra_data[count($chart)-1]['events'] = implode(',',$event_ids); } @@ -3943,17 +3935,7 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, $chart_extra_data['legend_alerts'] = $legend['alert'.$series_suffix]; } - if (!$avg_only) { - //Boolean graph doesn't have max!!! - //$legend['max'.$series_suffix] = __('Max').$series_suffix_str .': '.__('Last').': '.$graph_stats['max']['last'].' '.$unit.' ; '.__('Avg').': '.$graph_stats['max']['avg'].' '.$unit.' ; '.__('Max').': '.$graph_stats['max']['max'].' '.$unit.' ; '.__('Min').': '.$graph_stats['max']['min'].' '.$unit; - $legend['sum'.$series_suffix] = __('Avg').$series_suffix_str.': '.__('Last').': '.remove_right_zeros(number_format($graph_stats['sum']['last'], $config['graph_precision'])).' '.$unit.' ; '.__('Avg').': '.remove_right_zeros(number_format($graph_stats['sum']['avg'], $config['graph_precision'])).' '.$unit.' ; '.__('Max').': '.remove_right_zeros(number_format($graph_stats['sum']['max'], $config['graph_precision'])).' '.$unit.' ; '.__('Min').': '.remove_right_zeros(number_format($graph_stats['sum']['min'], $config['graph_precision'])).' '.$unit; - // Boolean graph doesn't have min!!! - // $legend['min'.$series_suffix] = __('Min').$series_suffix_str .': '.__('Last').': '.number_format($graph_stats['min']['last'], $config['graph_precision']).' '.$unit.' ; '.__('Avg').': '.number_format($graph_stats['min']['avg'], $config['graph_precision']).' '.$unit.' ; '.__('Max').': '.number_format($graph_stats['min']['max'], $config['graph_precision']).' '.$unit.' ; '.__('Min').': '.number_format($graph_stats['min']['min'], $config['graph_precision']).' '.$unit; - } - else { - $legend['sum'.$series_suffix] = __('Avg').$series_suffix_str.': '.__('Last').': '.remove_right_zeros(number_format($graph_stats['sum']['last'], $config['graph_precision'])).' '.$unit.' ; '.__('Avg').': '.remove_right_zeros(number_format($graph_stats['sum']['avg'], $config['graph_precision'])).' '.$unit.' ; '.__('Max').': '.remove_right_zeros(number_format($graph_stats['sum']['max'], $config['graph_precision'])).' '.$unit.' ; '.__('Min').': '.remove_right_zeros(number_format($graph_stats['sum']['min'], $config['graph_precision'])).' '.$unit; - - } + $legend['sum'.$series_suffix] = __('Avg').$series_suffix_str.': '.__('Last').': '.remove_right_zeros(number_format($graph_stats['sum']['last'], $config['graph_precision'])).' '.$unit.' ; '.__('Avg').': '.remove_right_zeros(number_format($graph_stats['sum']['avg'], $config['graph_precision'])).' '.$unit.' ; '.__('Max').': '.remove_right_zeros(number_format($graph_stats['sum']['max'], $config['graph_precision'])).' '.$unit.' ; '.__('Min').': '.remove_right_zeros(number_format($graph_stats['sum']['min'], $config['graph_precision'])).' '.$unit; if ($show_unknown) { $legend['unknown'.$series_suffix] = __('Unknown').$series_suffix_str; @@ -3985,13 +3967,12 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, array('border' => '#999999', 'color' => '#999999', 'alpha' => CHART_DEFAULT_ALPHA); } - //$color['baseline'.$series_suffix] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10); } 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 = '', $adapt_key = '', $compare = false, - $show_unknown = false, $menu = true) { + $show_unknown = false, $menu = true, $fullscale = false) { global $config; global $graphic_type; diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php index 935917c11a..cc22351bcd 100644 --- a/pandora_console/operation/agentes/stat_win.php +++ b/pandora_console/operation/agentes/stat_win.php @@ -167,6 +167,7 @@ $alias = db_get_value ("alias","tagente","id_agente",$id_agent); $time_compare_separated = get_parameter ("time_compare_separated", 0); $time_compare_overlapped = get_parameter ("time_compare_overlapped", 0); $unknown_graph = get_parameter_checkbox ("unknown_graph", 1); + $fullscale = get_parameter ("fullscale", 0); // To avoid the horizontal overflow $width -= 20; @@ -211,7 +212,7 @@ $alias = db_get_value ("alias","tagente","id_agente",$id_agent); $width, $height, $label_graph, $unit, $draw_alerts, $avg_only, false, $date, false, $urlImage, 'adapter_' . $graph_type, $time_compare, - $unknown_graph); + $unknown_graph, true, $fullscale); echo '
'; if ($show_events_graph) echo graphic_module_events($id, $width, $height, @@ -226,7 +227,7 @@ $alias = db_get_value ("alias","tagente","id_agente",$id_agent); 'adapter_' . $graph_type, $time_compare, $unknown_graph, true, 'white', (($show_percentil)? $config['percentil'] : null), - false, false, $config['type_module_charts']); + false, false, $config['type_module_charts'], $fullscale); echo '
'; if ($show_events_graph) echo graphic_module_events($id, $width, $height, @@ -398,6 +399,12 @@ $alias = db_get_value ("alias","tagente","id_agente",$id_agent); $table->rowclass[] = ''; break; } + + $data = array(); + $data[0] = __('Show full scale graph (TIP)'); + $data[1] = html_print_checkbox ("fullscale", 1, (bool) $fullscale, true); + $table->data[] = $data; + $table->rowclass[] = ''; $form_table = html_print_table($table, true); From 5807e554593d8207137d182489d55d886c62a976 Mon Sep 17 00:00:00 2001 From: Hirofumi Kosaka Date: Fri, 19 May 2017 16:49:54 +0900 Subject: [PATCH 004/152] Modified SNMP Console to prefer agent aliases as SNMP agent if registered. #149 --- pandora_console/operation/snmpconsole/snmp_view.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandora_console/operation/snmpconsole/snmp_view.php b/pandora_console/operation/snmpconsole/snmp_view.php index 26fb5d102c..202933d082 100755 --- a/pandora_console/operation/snmpconsole/snmp_view.php +++ b/pandora_console/operation/snmpconsole/snmp_view.php @@ -162,7 +162,7 @@ $severities = get_priorities (); $alerted = array (__('Not fired'), __('Fired')); foreach ($all_traps as $trap) { $agent = agents_get_agent_with_ip ($trap['source']); - $agents[$trap["source"]] = $agent !== false ? $agent["nombre"] : $trap["source"]; + $agents[$trap["source"]] = $agent !== false ? ($agent["alias"] ? $agent["alias"] : $agent["nombre"]) : $trap["source"]; $oid = enterprise_hook ('get_oid', array ($trap)); if ($oid === ENTERPRISE_NOT_HOOK) { $oid = $trap["oid"]; @@ -678,7 +678,7 @@ if ($traps !== false) { continue; } $data[1] = ''; - $data[1] .= ''.$agent["nombre"].ui_print_help_tip($trap['source'], true, "images/tip-blanco.png");''; + $data[1] .= ''.($agent["alias"] ? $agent["alias"] : $agent["nombre"]).ui_print_help_tip($trap['source'], true, "images/tip-blanco.png");''; } //OID @@ -1014,4 +1014,4 @@ echo '
 
'; } } - \ No newline at end of file + From 16fe10d1afb4d73d4c1dd0e431b8d283e2602d3a Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Fri, 19 May 2017 12:04:54 +0200 Subject: [PATCH 005/152] Added fullscale to boolean charts. Continue with the tests. --- pandora_console/include/functions_graph.php | 33 +++++++++++++++------ 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 8221d0b7c8..833dac6517 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -671,11 +671,6 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $baseline_data, $events, $series_suffix, $start_unknown, $percentil); - html_debug("DATA: ", true); - html_debug(count($data), true); - html_debug("CHART: ", true); - html_debug(count($chart), true); - // Return chart data and don't draw if ($return_data == 1) { return $chart; @@ -3594,7 +3589,8 @@ function fs_error_image ($width = 300, $height = 110) { function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, $unit_name, $show_alerts, $avg_only = 0, - $date = 0, $series_suffix = '', $series_suffix_str = '', $show_unknown = false) { + $date = 0, $series_suffix = '', $series_suffix_str = '', $show_unknown = false, + $fullscale = false) { global $config; global $chart; @@ -3660,6 +3656,26 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, if ($data === false) { $data = array (); } + + if ($fullscale) { + $all_data = db_uncompress_module_data($agent_module_id, time() - $period); + + $new_uncompress_data = array(); + $index = 0; + foreach ($all_data as $uncompress_data) { + foreach ($uncompress_data['data'] as $mod_data) { + $new_uncompress_data[$index]['datos'] = $mod_data['datos']; + $new_uncompress_data[$index]['utimestamp'] = $mod_data['utimestamp']; + $index++; + } + } + $new_uncompress_data[$index - 1]['id_agente_modulo'] = $agent_module_id; + + $data = $new_uncompress_data; + + $resolution = count($data); //Number of points of the graph + $interval = (int) ($period / $resolution); + } // Uncompressed module data if ($uncompressed_module) { @@ -3993,7 +4009,6 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, else $unit = $unit_name; - $series_suffix_str = ''; if ($compare !== false) { $series_suffix = '2'; @@ -4001,7 +4016,7 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, // Build the data of the previous period grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, $unit_name, $show_alerts, $avg_only, $date-$period, $series_suffix, - $series_suffix_str, $show_unknown); + $series_suffix_str, $show_unknown, $fullscale); switch ($compare) { case 'separated': // Store the chart calculated @@ -4027,7 +4042,7 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events, } grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, - $unit_name, $show_alerts, $avg_only, $date, '', '', $show_unknown); + $unit_name, $show_alerts, $avg_only, $date, '', '', $show_unknown, $fullscale); if ($compare === 'overlapped') { $i = 0; From 61eb5e755e3161142b35992b5980282616e5d4d6 Mon Sep 17 00:00:00 2001 From: enriquecd Date: Fri, 19 May 2017 14:00:47 +0200 Subject: [PATCH 006/152] Fix insert data extension, bad parameters in xml format - #869 --- pandora_console/extensions/insert_data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/extensions/insert_data.php b/pandora_console/extensions/insert_data.php index 33659b0c71..3e52a9138c 100644 --- a/pandora_console/extensions/insert_data.php +++ b/pandora_console/extensions/insert_data.php @@ -38,7 +38,7 @@ function createXMLData($agent, $agentModule, $time, $data) { io_safe_output($agent['os_version']), $agent['intervalo'], io_safe_output($agent['agent_version']), $time, io_safe_output($agent['nombre']), - io_safe_output($agent['alias']), $agent['timezone_offset'], + $agent['timezone_offset'], io_safe_output($agentModule['nombre']), io_safe_output($agentModule['descripcion']), modules_get_type_name($agentModule['id_tipo_modulo']), $data); From d209bd2f4537bd2cbb89c2854a72d945e31c9259 Mon Sep 17 00:00:00 2001 From: Hirofumi Kosaka Date: Mon, 22 May 2017 15:50:49 +0900 Subject: [PATCH 007/152] Bug Fix: SNMP Alert could not refer agents. #150 --- pandora_server/lib/PandoraFMS/Core.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 543ae4e264..855610d82f 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -976,7 +976,9 @@ sub pandora_execute_action ($$$$$$$$$;$) { _field13_ => $field13, _field14_ => $field14, _field15_ => $field15, - _agent_ => (defined ($agent)) ? $agent->{'alias'} : '', + _agentname_ => (defined ($agent)) ? $agent->{'nombre'} : '', + _agentalias_ => (defined ($agent)) ? $agent->{'alias'} : '', + _agent_ => (defined ($agent)) ? ($agent->{'alias'} ? $agent->{'alias'} : $agent->{'nombre'}) : '', _agentcustomid_ => (defined ($agent)) ? $agent->{'custom_id'} : '', '_agentcustomfield_\d+_' => undef, _agentdescription_ => (defined ($agent)) ? $agent->{'comentarios'} : '', @@ -1213,6 +1215,9 @@ sub pandora_execute_action ($$$$$$$$$;$) { } $agent_name = subst_alert_macros ($agent_name, \%macros, $pa_config, $dbh, $agent, $module); my $fullagent = get_agent_from_name ($dbh, $agent_name); + if( ! $fullagent && $macros{'_agentname_'} ) { + $fullagent = get_agent_from_name ($dbh, $macros{'_agentname_'} ); + } # Field 5 (priority) my $priority = $field5; @@ -3423,6 +3428,7 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) { if (defined($this_agent)){ %agent = ( 'nombre' => $this_agent->{'nombre'}, + 'alias' => $this_agent->{'alias'}, 'id_agente' => $this_agent->{'id_agente'}, 'direccion' => $trap_agent, 'id_grupo' => $this_agent->{'id_grupo'}, From 5bb3cd2ad6918e6adfe280da3f83752ec4caa4b7 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Tue, 23 May 2017 15:02:53 +0200 Subject: [PATCH 008/152] Added some code to fullscale graphs --- pandora_console/include/functions_graph.php | 64 ++++++++++++--------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 833dac6517..f2b18646ce 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -232,7 +232,7 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i $projection, $avg_only = false, $uncompressed_module = false, $show_events = false, $show_alerts = false, $show_unknown = false, $baseline = false, $baseline_data = array(), $events = array(), $series_suffix = '', $start_unknown = false, - $percentil = null) { + $percentil = null, $fullscale = false) { global $config; global $chart_extra_data; @@ -350,9 +350,15 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i } elseif ($period < SECONDS_1MONTH) { $time_format = "M \nd H\h"; + if ($fullscale) { + $time_format = "M \nd H:i"; + } } else { $time_format = "M \nd H\h"; + if ($fullscale) { + $time_format = "M \nd H:i"; + } } } else { @@ -368,9 +374,15 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i } elseif ($period < SECONDS_1MONTH) { $time_format = "M d H\h"; + if ($fullscale) { + $time_format = "M d H:i"; + } } else { $time_format = "M d H\h"; + if ($fullscale) { + $time_format = "M d H:i"; + } } } @@ -550,13 +562,30 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, } // Get module data - $data = db_get_all_rows_filter ('tagente_datos', - array ('id_agente_modulo' => (int)$agent_module_id, - "utimestamp > $datelimit", - "utimestamp < $date", - 'order' => 'utimestamp ASC'), - array ('datos', 'utimestamp'), 'AND', $search_in_history_db); - + if ($fullscale) { + $uncompress_data = db_uncompress_module_data((int)$agent_module_id, $datelimit, get_system_time()); + + $new_data = array(); + $index = 0; + foreach ($uncompress_data as $key => $u_data) { + foreach ($u_data['data'] as $key2 => $u_data2) { + if ($u_data2['datos'] != "") { + $new_data[$index]['datos'] = $u_data2['datos']; + $new_data[$index]['utimestamp'] = $u_data2['utimestamp']; + $index++; + } + } + } + $data = $new_data; + } + else { + $data = db_get_all_rows_filter ('tagente_datos', + array ('id_agente_modulo' => (int)$agent_module_id, + "utimestamp > $datelimit", + "utimestamp < $date", + 'order' => 'utimestamp ASC'), + array ('datos', 'utimestamp'), 'AND', $search_in_history_db); + } // Get module warning_min and critical_min $warning_min = db_get_value('min_warning','tagente_modulo','id_agente_modulo',$agent_module_id); @@ -598,23 +627,6 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $min_necessary = 2; } - if ($fullscale) { - $all_data = db_uncompress_module_data($agent_module_id, time() - $period); - - $new_uncompress_data = array(); - $index = 0; - foreach ($all_data as $uncompress_data) { - foreach ($uncompress_data['data'] as $mod_data) { - $new_uncompress_data[$index]['datos'] = $mod_data['datos']; - $new_uncompress_data[$index]['utimestamp'] = $mod_data['utimestamp']; - $index++; - } - } - $new_uncompress_data[$index - 1]['id_agente_modulo'] = $agent_module_id; - - $data = $new_uncompress_data; - } - // Check available data if (count ($data) < $min_necessary) { if (!$graphic_type) { @@ -669,7 +681,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $projection, $avg_only, $uncompressed_module, $show_events, $show_alerts, $show_unknown, $baseline, $baseline_data, $events, $series_suffix, $start_unknown, - $percentil); + $percentil, $fullscale); // Return chart data and don't draw if ($return_data == 1) { From 53f4c6edb84b47de729aaa7a809b4d24ad786291 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Tue, 23 May 2017 15:15:28 +0200 Subject: [PATCH 009/152] Added fullscale setting in boolean chart --- pandora_console/include/functions_graph.php | 22 +++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index f2b18646ce..8e67ed7935 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -3670,15 +3670,17 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, } if ($fullscale) { - $all_data = db_uncompress_module_data($agent_module_id, time() - $period); + $all_data = db_uncompress_module_data($agent_module_id, $datelimit, $date); $new_uncompress_data = array(); $index = 0; foreach ($all_data as $uncompress_data) { foreach ($uncompress_data['data'] as $mod_data) { - $new_uncompress_data[$index]['datos'] = $mod_data['datos']; - $new_uncompress_data[$index]['utimestamp'] = $mod_data['utimestamp']; - $index++; + if ($mod_data['datos'] != "") { + $new_uncompress_data[$index]['datos'] = $mod_data['datos']; + $new_uncompress_data[$index]['utimestamp'] = $mod_data['utimestamp']; + $index++; + } } } $new_uncompress_data[$index - 1]['id_agente_modulo'] = $agent_module_id; @@ -3834,9 +3836,15 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, } elseif ($period < SECONDS_1MONTH) { $time_format = 'M d H\h'; + if ($fullscale) { + $time_format = 'M d H:i'; + } } else { $time_format = 'M d H\h'; + if ($fullscale) { + $time_format = 'M d H:i'; + } } $timestamp_short = date($time_format, $timestamp); @@ -3944,9 +3952,15 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, } elseif ($period < SECONDS_1MONTH) { $time_format = 'M d H\h'; + if ($fullscale) { + $time_format = 'M d H:i'; + } } else { $time_format = 'M d H\h'; + if ($fullscale) { + $time_format = 'M d H:i'; + } } // Flash chart From d744cb92205bceae5f23389418ac31737c7afb6b Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Tue, 23 May 2017 15:16:34 +0200 Subject: [PATCH 010/152] Added end date to fullscale chart view --- pandora_console/include/functions_graph.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 8e67ed7935..48496def25 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -563,7 +563,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, // Get module data if ($fullscale) { - $uncompress_data = db_uncompress_module_data((int)$agent_module_id, $datelimit, get_system_time()); + $uncompress_data = db_uncompress_module_data((int)$agent_module_id, $datelimit, $date); $new_data = array(); $index = 0; From 6bf672a8466463fbb31aab551870a6e4edbaa1b9 Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Fri, 26 May 2017 14:47:37 +0200 Subject: [PATCH 011/152] Added changes --- pandora_console/extensions/pandora_logs.php | 10 ++++---- .../godmode/setup/setup_general.php | 24 +++++++++++-------- pandora_console/include/functions_config.php | 6 +++++ 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/pandora_console/extensions/pandora_logs.php b/pandora_console/extensions/pandora_logs.php index f129f7b45d..f20bcab720 100644 --- a/pandora_console/extensions/pandora_logs.php +++ b/pandora_console/extensions/pandora_logs.php @@ -39,10 +39,9 @@ function view_logfile ($file_name) { echo "

$file_name (" . __("File is too large than PHP memory allocated in the system.") . ")

"; echo "

" . __("The preview file is imposible.") . "

"; } - else if ($file_size > 512000) { - $data = file_get_contents ($file_name, false, NULL, $file_size - 512000); - echo "

$file_name (".__("File is too large (> 500KB)").")

"; - + else if ($file_size > ($config['max_log_size'] * 1000)) { + $data = file_get_contents ($file_name, false, NULL, $file_size - ($config['max_log_size'] * 1000)); + echo "

$file_name (".format_numeric(filesize ($file_name)/1024)." KB)

"; echo "