diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index ccdb829f9c..b59dbc2ee5 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -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': diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index 4eaeeed45b..d47e23e5c2 100755 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -1,18 +1,35 @@ 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 .= html_print_table($table, true); $form .= '
'; @@ -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(); } diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 4ad8294ae1..454d596a62 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -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'); } diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 0cf447eede..4b5ad466a0 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -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(); } diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index d8012c15dd..971ead51a9 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -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) {