Fixed bugs in reports
This commit is contained in:
parent
be2148ff26
commit
93bca4673f
|
@ -240,7 +240,7 @@ switch ($action) {
|
||||||
$hide_notinit_agents = $style['hide_notinit_agents'];
|
$hide_notinit_agents = $style['hide_notinit_agents'];
|
||||||
$dyn_height = $style['dyn_height'];
|
$dyn_height = $style['dyn_height'];
|
||||||
$type = $item['type'];
|
$type = $item['type'];
|
||||||
$name = $item['name'];
|
$name = $style['name_label'];
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'event_report_log':
|
case 'event_report_log':
|
||||||
|
|
|
@ -1,18 +1,35 @@
|
||||||
<?php
|
<?php
|
||||||
// Pandora FMS - http://pandorafms.com
|
/**
|
||||||
// ==================================================
|
* Extension to manage a list of gateways and the node address where they should
|
||||||
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
|
* point to.
|
||||||
// Please see http://pandorafms.org for full contribution list
|
*
|
||||||
// This program is free software; you can redistribute it and/or
|
* @category Reporting
|
||||||
// modify it under the terms of the GNU General Public License
|
* @package Pandora FMS
|
||||||
// as published by the Free Software Foundation for version 2.
|
* @subpackage Community
|
||||||
// This program is distributed in the hope that it will be useful,
|
* @version 1.0.0
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* @license See below
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
*
|
||||||
// GNU General Public License for more details.
|
* ______ ___ _______ _______ ________
|
||||||
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||||
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||||
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||||
|
*
|
||||||
|
* ============================================================================
|
||||||
|
* Copyright (c) 2005-2019 Artica Soluciones Tecnologicas
|
||||||
|
* Please see http://pandorafms.org for full contribution list
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation for version 2.
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
* ============================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
// Login check
|
// Login check.
|
||||||
check_login();
|
check_login();
|
||||||
|
|
||||||
if (! check_acl($config['id_user'], 0, 'RW')) {
|
if (! check_acl($config['id_user'], 0, 'RW')) {
|
||||||
|
@ -39,12 +56,16 @@ switch ($config['dbtype']) {
|
||||||
'type'
|
'type'
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Default.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$report_w = check_acl($config['id_user'], 0, 'RW');
|
$report_w = check_acl($config['id_user'], 0, 'RW');
|
||||||
$report_m = check_acl($config['id_user'], 0, 'RM');
|
$report_m = check_acl($config['id_user'], 0, 'RM');
|
||||||
|
|
||||||
if ($config['metaconsole'] == 1 and defined('METACONSOLE')) {
|
if (is_metaconsole()) {
|
||||||
$agents = [];
|
$agents = [];
|
||||||
$agents = metaconsole_get_report_agents($idReport);
|
$agents = metaconsole_get_report_agents($idReport);
|
||||||
$modules = [];
|
$modules = [];
|
||||||
|
@ -52,7 +73,7 @@ if ($config['metaconsole'] == 1 and defined('METACONSOLE')) {
|
||||||
$types = [];
|
$types = [];
|
||||||
$types = metaconsole_get_report_types($idReport);
|
$types = metaconsole_get_report_types($idReport);
|
||||||
} else {
|
} else {
|
||||||
// FORM FILTER
|
// FORM FILTER.
|
||||||
switch ($config['dbtype']) {
|
switch ($config['dbtype']) {
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
case 'postgresql':
|
case 'postgresql':
|
||||||
|
@ -87,7 +108,10 @@ if ($config['metaconsole'] == 1 and defined('METACONSOLE')) {
|
||||||
ON (t4.id_agent = t5.id_agente OR t4.id_agente = t5.id_agente)
|
ON (t4.id_agent = t5.id_agente OR t4.id_agente = t5.id_agente)
|
||||||
WHERE t4.id_report = '.$idReport
|
WHERE t4.id_report = '.$idReport
|
||||||
);
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Default.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +148,10 @@ if ($config['metaconsole'] == 1 and defined('METACONSOLE')) {
|
||||||
WHERE t1.id_report = '.$idReport
|
WHERE t1.id_report = '.$idReport
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Default.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($rows === false) {
|
if ($rows === false) {
|
||||||
|
@ -135,8 +163,8 @@ if ($config['metaconsole'] == 1 and defined('METACONSOLE')) {
|
||||||
$modules[$row['id_agent_module']] = $row['nombre'];
|
$modules[$row['id_agent_module']] = $row['nombre'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter report items created from metaconsole in normal console list and the opposite
|
// Filter report items created from metaconsole in normal console list and the opposite.
|
||||||
if (defined('METACONSOLE') and $config['metaconsole'] == 1) {
|
if (is_metaconsole()) {
|
||||||
$where_types = ' AND ((server_name IS NOT NULL AND length(server_name) != 0) OR '.$type_escaped.' IN (\'general\',\'SLA\',\'exception\',\'top_n\'))';
|
$where_types = ' AND ((server_name IS NOT NULL AND length(server_name) != 0) OR '.$type_escaped.' IN (\'general\',\'SLA\',\'exception\',\'top_n\'))';
|
||||||
} else {
|
} else {
|
||||||
$where_types = ' AND ((server_name IS NULL OR length(server_name) = 0) OR '.$type_escaped.' IN (\'general\',\'SLA\',\'exception\',\'top_n\'))';
|
$where_types = ' AND ((server_name IS NULL OR length(server_name) = 0) OR '.$type_escaped.' IN (\'general\',\'SLA\',\'exception\',\'top_n\'))';
|
||||||
|
@ -184,7 +212,6 @@ if (!defined('METACONSOLE')) {
|
||||||
$table->data[0][1] .= html_print_select($modules, 'module_filter', $moduleFilter, '', __('All'), 0, true);
|
$table->data[0][1] .= html_print_select($modules, 'module_filter', $moduleFilter, '', __('All'), 0, true);
|
||||||
$table->data[0][2] = __('Type');
|
$table->data[0][2] = __('Type');
|
||||||
$table->data[0][2] .= html_print_select($types, 'type_filter', $typeFilter, '', __('All'), 0, true);
|
$table->data[0][2] .= html_print_select($types, 'type_filter', $typeFilter, '', __('All'), 0, true);
|
||||||
// $table->data[1][2] = $table->data[1][3] = '';
|
|
||||||
$form = '<form method="post" action ="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=filter&id_report='.$idReport.'">';
|
$form = '<form method="post" action ="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&tab=list_items&action=filter&id_report='.$idReport.'">';
|
||||||
$form .= html_print_table($table, true);
|
$form .= html_print_table($table, true);
|
||||||
$form .= '<div class="action-buttons" style="width: '.$table->width.'">';
|
$form .= '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||||
|
@ -265,9 +292,9 @@ if ($moduleFilter != 0) {
|
||||||
$where .= ' AND id_agent_module = '.$moduleFilter;
|
$where .= ' AND id_agent_module = '.$moduleFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter report items created from metaconsole in normal console list and the opposite
|
// Filter report items created from metaconsole in normal console list and the opposite.
|
||||||
if (defined('METACONSOLE') and $config['metaconsole'] == 1) {
|
if (is_metaconsole()) {
|
||||||
$where .= ' AND ((server_name IS NOT NULL AND length(server_name) != 0) '.'OR '.$type_escaped.' IN (\'general\', \'SLA\', \'exception\', \'availability\', \'availability_graph\', \'top_n\',\'SLA_monthly\',\'SLA_weekly\',\'SLA_hourly\',\'text\'))';
|
$where .= ' AND ((server_name IS NOT NULL AND length(server_name) != 0) '.'OR '.$type_escaped.' IN (\'general\', \'SLA\', \'exception\', \'availability\', \'availability_graph\', \'top_n\',\'SLA_monthly\',\'SLA_weekly\',\'SLA_hourly\',\'text\',\'group_report\'))';
|
||||||
} else {
|
} else {
|
||||||
$where .= ' AND ((server_name IS NULL OR length(server_name) = 0) '.'OR '.$type_escaped.' IN (\'general\', \'SLA\', \'exception\', \'availability\', \'top_n\'))';
|
$where .= ' AND ((server_name IS NULL OR length(server_name) = 0) '.'OR '.$type_escaped.' IN (\'general\', \'SLA\', \'exception\', \'availability\', \'top_n\'))';
|
||||||
}
|
}
|
||||||
|
@ -306,13 +333,17 @@ switch ($config['dbtype']) {
|
||||||
'AND',
|
'AND',
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
// Delete rnum row generated by oracle_recode_query() function
|
// Delete rnum row generated by oracle_recode_query() function.
|
||||||
if ($items !== false) {
|
if ($items !== false) {
|
||||||
for ($i = 0; $i < count($items); $i++) {
|
for ($i = 0; $i < count($items); $i++) {
|
||||||
unset($items[$i]['rnum']);
|
unset($items[$i]['rnum']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Default.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$countItems = db_get_sql(
|
$countItems = db_get_sql(
|
||||||
|
@ -421,29 +452,30 @@ foreach ($items as $item) {
|
||||||
|
|
||||||
$row[1] = get_report_name($item['type']);
|
$row[1] = get_report_name($item['type']);
|
||||||
|
|
||||||
if ($item['type'] == 'custom_graph') {
|
|
||||||
$custom_graph_name = db_get_row_sql('select name from tgraph where id_graph = '.$item['id_gs']);
|
|
||||||
$row[1] = get_report_name($item['type']).' ('.$custom_graph_name['name'].')';
|
|
||||||
}
|
|
||||||
|
|
||||||
$server_name = $item['server_name'];
|
$server_name = $item['server_name'];
|
||||||
|
|
||||||
if (($config['metaconsole'] == 1) && ($server_name != '') && defined('METACONSOLE')) {
|
if (is_metaconsole()) {
|
||||||
$connection = metaconsole_get_connection($server_name);
|
$connection = metaconsole_get_connection($server_name);
|
||||||
if (metaconsole_load_external_db($connection) != NOERR) {
|
if (metaconsole_load_external_db($connection) != NOERR) {
|
||||||
// ui_print_error_message ("Error connecting to ".$server_name);
|
// ui_print_error_message ("Error connecting to ".$server_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($item['type'] == 'custom_graph') {
|
||||||
|
$custom_graph_name = db_get_row_sql('SELECT name FROM tgraph WHERE id_graph = '.$item['id_gs']);
|
||||||
|
$row[1] = get_report_name($item['type']).' ('.$custom_graph_name['name'].')';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($item['id_agent'] == 0) {
|
if ($item['id_agent'] == 0) {
|
||||||
$is_inventory_item = $item['type'] == 'inventory' || $item['type'] == 'inventory_changes';
|
$is_inventory_item = $item['type'] == 'inventory' || $item['type'] == 'inventory_changes';
|
||||||
|
|
||||||
// Due to SLA or top N or general report items
|
// Due to SLA or top N or general report items.
|
||||||
if (!$is_inventory_item && ($item['id_agent_module'] == '' || $item['id_agent_module'] == 0)) {
|
if (!$is_inventory_item && ($item['id_agent_module'] == '' || $item['id_agent_module'] == 0)) {
|
||||||
$row[2] = '';
|
$row[2] = '';
|
||||||
$row[3] = '';
|
$row[3] = '';
|
||||||
} else {
|
} else {
|
||||||
// The inventory items have the agents and modules in json format in the field external_source
|
// The inventory items have the agents and modules in json format in the field external_source.
|
||||||
if ($is_inventory_item) {
|
if ($is_inventory_item) {
|
||||||
$external_source = json_decode($item['external_source'], true);
|
$external_source = json_decode($item['external_source'], true);
|
||||||
$agents = $external_source['id_agents'];
|
$agents = $external_source['id_agents'];
|
||||||
|
@ -522,7 +554,7 @@ foreach ($items as $item) {
|
||||||
|
|
||||||
$table->data[] = $row;
|
$table->data[] = $row;
|
||||||
$count++;
|
$count++;
|
||||||
// Restore db connection
|
// Restore db connection.
|
||||||
if (($config['metaconsole'] == 1) && ($server_name != '') && defined('METACONSOLE')) {
|
if (($config['metaconsole'] == 1) && ($server_name != '') && defined('METACONSOLE')) {
|
||||||
metaconsole_restore_db();
|
metaconsole_restore_db();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3595,6 +3595,11 @@ function graph_custom_sql_graph(
|
||||||
|
|
||||||
$SQL_GRAPH_MAX_LABEL_SIZE = 20;
|
$SQL_GRAPH_MAX_LABEL_SIZE = 20;
|
||||||
|
|
||||||
|
if (is_metaconsole()) {
|
||||||
|
$server = metaconsole_get_connection_names();
|
||||||
|
$connection = metaconsole_get_connection($server);
|
||||||
|
}
|
||||||
|
|
||||||
$report_content = db_get_row('treport_content', 'id_rc', $id);
|
$report_content = db_get_row('treport_content', 'id_rc', $id);
|
||||||
if ($id != null) {
|
if ($id != null) {
|
||||||
$historical_db = db_get_value_sql('SELECT historical_db from treport_content where id_rc ='.$id);
|
$historical_db = db_get_value_sql('SELECT historical_db from treport_content where id_rc ='.$id);
|
||||||
|
@ -3609,22 +3614,9 @@ function graph_custom_sql_graph(
|
||||||
$sql = io_safe_output($sql['sql']);
|
$sql = io_safe_output($sql['sql']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($config['metaconsole'] == 1) && defined('METACONSOLE')) {
|
|
||||||
$metaconsole_connection = enterprise_hook('metaconsole_get_connection', [$report_content['server_name']]);
|
|
||||||
|
|
||||||
if ($metaconsole_connection === false) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (enterprise_hook('metaconsole_load_external_db', [$metaconsole_connection]) != NOERR) {
|
|
||||||
// ui_print_error_message ("Error connecting to ".$server_name);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$data_result = db_get_all_rows_sql($sql, $historical_db);
|
$data_result = db_get_all_rows_sql($sql, $historical_db);
|
||||||
|
|
||||||
if (($config['metaconsole'] == 1) && defined('METACONSOLE')) {
|
if (is_metaconsole()) {
|
||||||
enterprise_hook('metaconsole_restore_db');
|
enterprise_hook('metaconsole_restore_db');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -282,6 +282,15 @@ function reporting_make_reporting_data(
|
||||||
$agents_to_macro = $content['id_agent'];
|
$agents_to_macro = $content['id_agent'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Metaconsole connection.
|
||||||
|
if (is_metaconsole()) {
|
||||||
|
$server = metaconsole_get_connection_names();
|
||||||
|
$connection = metaconsole_get_connection($server);
|
||||||
|
if (metaconsole_connect($connection) != NOERR) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($content['style']['name_label'])) {
|
if (isset($content['style']['name_label'])) {
|
||||||
// Add macros name.
|
// Add macros name.
|
||||||
$items_label = [];
|
$items_label = [];
|
||||||
|
@ -294,14 +303,6 @@ function reporting_make_reporting_data(
|
||||||
$metaconsole_on = is_metaconsole();
|
$metaconsole_on = is_metaconsole();
|
||||||
$server_name = $content['server_name'];
|
$server_name = $content['server_name'];
|
||||||
|
|
||||||
// Metaconsole connection.
|
|
||||||
if ($metaconsole_on && $server_name != '') {
|
|
||||||
$connection = metaconsole_get_connection($server_name);
|
|
||||||
if (!metaconsole_load_external_db($connection)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$items_label['agent_description'] = agents_get_description(
|
$items_label['agent_description'] = agents_get_description(
|
||||||
$content['id_agent']
|
$content['id_agent']
|
||||||
);
|
);
|
||||||
|
@ -2824,13 +2825,12 @@ function reporting_group_report($report, $content)
|
||||||
$content['name'] = __('Group Report');
|
$content['name'] = __('Group Report');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($config['metaconsole']) {
|
if (is_metaconsole()) {
|
||||||
$id_meta = metaconsole_get_id_server($content['server_name']);
|
$server = metaconsole_get_connection_names();
|
||||||
|
$connection = metaconsole_get_connection($server);
|
||||||
$server = metaconsole_get_connection_by_id($id_meta);
|
|
||||||
metaconsole_connect($server);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$return['server_name'] = $server[0];
|
||||||
$return['title'] = $content['name'];
|
$return['title'] = $content['name'];
|
||||||
$return['subtitle'] = groups_get_name($content['id_group'], true);
|
$return['subtitle'] = groups_get_name($content['id_group'], true);
|
||||||
$return['description'] = $content['description'];
|
$return['description'] = $content['description'];
|
||||||
|
@ -3488,7 +3488,7 @@ function reporting_network_interfaces_report($report, $content, $type='dinamic',
|
||||||
$return['failed'] = null;
|
$return['failed'] = null;
|
||||||
$return['data'] = [];
|
$return['data'] = [];
|
||||||
|
|
||||||
if ($config['metaconsole']) {
|
if (is_metaconsole()) {
|
||||||
$server_names = metaconsole_get_connection_names();
|
$server_names = metaconsole_get_connection_names();
|
||||||
if (isset($server_names) && is_array($server_names)) {
|
if (isset($server_names) && is_array($server_names)) {
|
||||||
foreach ($server_names as $key => $value) {
|
foreach ($server_names as $key => $value) {
|
||||||
|
@ -3505,7 +3505,8 @@ function reporting_network_interfaces_report($report, $content, $type='dinamic',
|
||||||
$content,
|
$content,
|
||||||
$report,
|
$report,
|
||||||
$fullscale,
|
$fullscale,
|
||||||
$pdf
|
$pdf,
|
||||||
|
$id_meta
|
||||||
);
|
);
|
||||||
metaconsole_restore_db();
|
metaconsole_restore_db();
|
||||||
}
|
}
|
||||||
|
|
|
@ -357,17 +357,7 @@ function hbar_graph(
|
||||||
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
|
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
|
||||||
|
|
||||||
if (empty($chart_data)) {
|
if (empty($chart_data)) {
|
||||||
return html_print_image(
|
return graph_nodata_image($width, $height, 'hbar');
|
||||||
$no_data_image,
|
|
||||||
true,
|
|
||||||
[
|
|
||||||
'width' => $width,
|
|
||||||
'height' => $height,
|
|
||||||
'title' => __('No data to show'),
|
|
||||||
],
|
|
||||||
false,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ttl == 2) {
|
if ($ttl == 2) {
|
||||||
|
|
Loading…
Reference in New Issue