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'];
|
||||
$dyn_height = $style['dyn_height'];
|
||||
$type = $item['type'];
|
||||
$name = $item['name'];
|
||||
$name = $style['name_label'];
|
||||
|
||||
switch ($type) {
|
||||
case 'event_report_log':
|
||||
|
|
|
@ -1,18 +1,35 @@
|
|||
<?php
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 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.
|
||||
/**
|
||||
* Extension to manage a list of gateways and the node address where they should
|
||||
* point to.
|
||||
*
|
||||
* @category Reporting
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* 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;
|
||||
|
||||
// Login check
|
||||
// Login check.
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'RW')) {
|
||||
|
@ -39,12 +56,16 @@ switch ($config['dbtype']) {
|
|||
'type'
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
|
||||
$report_w = check_acl($config['id_user'], 0, 'RW');
|
||||
$report_m = check_acl($config['id_user'], 0, 'RM');
|
||||
|
||||
if ($config['metaconsole'] == 1 and defined('METACONSOLE')) {
|
||||
if (is_metaconsole()) {
|
||||
$agents = [];
|
||||
$agents = metaconsole_get_report_agents($idReport);
|
||||
$modules = [];
|
||||
|
@ -52,7 +73,7 @@ if ($config['metaconsole'] == 1 and defined('METACONSOLE')) {
|
|||
$types = [];
|
||||
$types = metaconsole_get_report_types($idReport);
|
||||
} else {
|
||||
// FORM FILTER
|
||||
// FORM FILTER.
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
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)
|
||||
WHERE t4.id_report = '.$idReport
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -124,6 +148,10 @@ if ($config['metaconsole'] == 1 and defined('METACONSOLE')) {
|
|||
WHERE t1.id_report = '.$idReport
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
|
||||
if ($rows === false) {
|
||||
|
@ -135,8 +163,8 @@ if ($config['metaconsole'] == 1 and defined('METACONSOLE')) {
|
|||
$modules[$row['id_agent_module']] = $row['nombre'];
|
||||
}
|
||||
|
||||
// Filter report items created from metaconsole in normal console list and the opposite
|
||||
if (defined('METACONSOLE') and $config['metaconsole'] == 1) {
|
||||
// Filter report items created from metaconsole in normal console list and the opposite.
|
||||
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\'))';
|
||||
} else {
|
||||
$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][2] = __('Type');
|
||||
$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 .= html_print_table($table, true);
|
||||
$form .= '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
|
@ -265,9 +292,9 @@ if ($moduleFilter != 0) {
|
|||
$where .= ' AND id_agent_module = '.$moduleFilter;
|
||||
}
|
||||
|
||||
// Filter report items created from metaconsole in normal console list and the opposite
|
||||
if (defined('METACONSOLE') and $config['metaconsole'] == 1) {
|
||||
$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\'))';
|
||||
// Filter report items created from metaconsole in normal console list and the opposite.
|
||||
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\',\'group_report\'))';
|
||||
} else {
|
||||
$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',
|
||||
false
|
||||
);
|
||||
// Delete rnum row generated by oracle_recode_query() function
|
||||
// Delete rnum row generated by oracle_recode_query() function.
|
||||
if ($items !== false) {
|
||||
for ($i = 0; $i < count($items); $i++) {
|
||||
unset($items[$i]['rnum']);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Default.
|
||||
break;
|
||||
}
|
||||
|
||||
$countItems = db_get_sql(
|
||||
|
@ -421,29 +452,30 @@ foreach ($items as $item) {
|
|||
|
||||
$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'];
|
||||
|
||||
if (($config['metaconsole'] == 1) && ($server_name != '') && defined('METACONSOLE')) {
|
||||
if (is_metaconsole()) {
|
||||
$connection = metaconsole_get_connection($server_name);
|
||||
if (metaconsole_load_external_db($connection) != NOERR) {
|
||||
// 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) {
|
||||
$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)) {
|
||||
$row[2] = '';
|
||||
$row[3] = '';
|
||||
} 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) {
|
||||
$external_source = json_decode($item['external_source'], true);
|
||||
$agents = $external_source['id_agents'];
|
||||
|
@ -522,7 +554,7 @@ foreach ($items as $item) {
|
|||
|
||||
$table->data[] = $row;
|
||||
$count++;
|
||||
// Restore db connection
|
||||
// Restore db connection.
|
||||
if (($config['metaconsole'] == 1) && ($server_name != '') && defined('METACONSOLE')) {
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
|
|
@ -3595,6 +3595,11 @@ function graph_custom_sql_graph(
|
|||
|
||||
$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);
|
||||
if ($id != null) {
|
||||
$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']);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (($config['metaconsole'] == 1) && defined('METACONSOLE')) {
|
||||
if (is_metaconsole()) {
|
||||
enterprise_hook('metaconsole_restore_db');
|
||||
}
|
||||
|
||||
|
|
|
@ -282,6 +282,15 @@ function reporting_make_reporting_data(
|
|||
$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'])) {
|
||||
// Add macros name.
|
||||
$items_label = [];
|
||||
|
@ -294,14 +303,6 @@ function reporting_make_reporting_data(
|
|||
$metaconsole_on = is_metaconsole();
|
||||
$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(
|
||||
$content['id_agent']
|
||||
);
|
||||
|
@ -2824,13 +2825,12 @@ function reporting_group_report($report, $content)
|
|||
$content['name'] = __('Group Report');
|
||||
}
|
||||
|
||||
if ($config['metaconsole']) {
|
||||
$id_meta = metaconsole_get_id_server($content['server_name']);
|
||||
|
||||
$server = metaconsole_get_connection_by_id($id_meta);
|
||||
metaconsole_connect($server);
|
||||
if (is_metaconsole()) {
|
||||
$server = metaconsole_get_connection_names();
|
||||
$connection = metaconsole_get_connection($server);
|
||||
}
|
||||
|
||||
$return['server_name'] = $server[0];
|
||||
$return['title'] = $content['name'];
|
||||
$return['subtitle'] = groups_get_name($content['id_group'], true);
|
||||
$return['description'] = $content['description'];
|
||||
|
@ -3488,7 +3488,7 @@ function reporting_network_interfaces_report($report, $content, $type='dinamic',
|
|||
$return['failed'] = null;
|
||||
$return['data'] = [];
|
||||
|
||||
if ($config['metaconsole']) {
|
||||
if (is_metaconsole()) {
|
||||
$server_names = metaconsole_get_connection_names();
|
||||
if (isset($server_names) && is_array($server_names)) {
|
||||
foreach ($server_names as $key => $value) {
|
||||
|
@ -3505,7 +3505,8 @@ function reporting_network_interfaces_report($report, $content, $type='dinamic',
|
|||
$content,
|
||||
$report,
|
||||
$fullscale,
|
||||
$pdf
|
||||
$pdf,
|
||||
$id_meta
|
||||
);
|
||||
metaconsole_restore_db();
|
||||
}
|
||||
|
|
|
@ -357,17 +357,7 @@ function hbar_graph(
|
|||
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
|
||||
|
||||
if (empty($chart_data)) {
|
||||
return html_print_image(
|
||||
$no_data_image,
|
||||
true,
|
||||
[
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
'title' => __('No data to show'),
|
||||
],
|
||||
false,
|
||||
true
|
||||
);
|
||||
return graph_nodata_image($width, $height, 'hbar');
|
||||
}
|
||||
|
||||
if ($ttl == 2) {
|
||||
|
|
Loading…
Reference in New Issue