diff --git a/pandora_console/include/lib/Dashboard/Widgets/top_n.php b/pandora_console/include/lib/Dashboard/Widgets/top_n.php index 599bef0b0b..1125ca41ab 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/top_n.php +++ b/pandora_console/include/lib/Dashboard/Widgets/top_n.php @@ -414,10 +414,32 @@ class TopNWidget extends Widget $quantity ); - $modules = @db_get_all_rows_sql( - $sql, - $search_in_history_db - ); + if (is_metaconsole() === true) { + $servers = metaconsole_get_servers(); + + $modules = []; + + foreach ($servers as $server) { + if (metaconsole_connect(null, $server['id']) !== NOERR) { + continue; + } + + $modules = array_merge( + $modules, + @db_get_all_rows_sql( + $sql, + $search_in_history_db + ) + ); + + metaconsole_restore_db(); + } + } else { + $modules = @db_get_all_rows_sql( + $sql, + $search_in_history_db + ); + } if (empty($modules) === true) { $output .= '
'; diff --git a/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php b/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php index aa4f64ca79..42cd059dc5 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php +++ b/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_group.php @@ -367,6 +367,8 @@ class TopNEventByGroupWidget extends Widget $this->values['groupId'] = explode(',', $this->values['groupId'][0]); + $event_table = (is_metaconsole() === true) ? 'tmetaconsole_event' : 'tevento'; + if (empty($this->values['groupId']) === true) { $output .= '
'; $output .= \ui_print_info_message( @@ -388,12 +390,13 @@ class TopNEventByGroupWidget extends Widget if ($all_group === false) { $sql = sprintf( 'SELECT id_agente, COUNT(*) AS count - FROM tevento + FROM %s WHERE utimestamp >= %d AND id_grupo IN (%s) GROUP BY id_agente ORDER BY count DESC LIMIT %d', + $event_table, $timestamp, implode(',', $this->values['groupId']), $this->values['amountShow'] @@ -401,11 +404,12 @@ class TopNEventByGroupWidget extends Widget } else { $sql = sprintf( 'SELECT id_agente, COUNT(*) AS count - FROM tevento + FROM %s WHERE utimestamp >= %d GROUP BY id_agente ORDER BY count DESC LIMIT %d', + $event_table, $timestamp, $this->values['amountShow'] ); @@ -428,9 +432,18 @@ class TopNEventByGroupWidget extends Widget if ($row['id_agente'] == 0) { $name = __('System'); } else { - $name = io_safe_output( - agents_get_alias($row['id_agente']) - ); + if (is_metaconsole() === true) { + $name = (string) db_get_value( + 'alias', + 'tmetaconsole_agent', + 'id_tagente', + (int) $row['id_agente'] + ); + } else { + $name = io_safe_output( + agents_get_alias($row['id_agente']) + ); + } } $name .= ' ('.$row['count'].')'; diff --git a/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_module.php b/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_module.php index f110c4ea52..0d413d219c 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_module.php +++ b/pandora_console/include/lib/Dashboard/Widgets/top_n_events_by_module.php @@ -365,6 +365,8 @@ class TopNEventByModuleWidget extends Widget $this->values['groupId'] = explode(',', $this->values['groupId'][0]); + $event_table = (is_metaconsole() === true) ? 'tmetaconsole_event' : 'tevento'; + if (empty($this->values['groupId']) === true) { $output = '
'; $output .= \ui_print_info_message( @@ -389,12 +391,13 @@ class TopNEventByModuleWidget extends Widget id_agentmodule, event_type, COUNT(*) AS count - FROM tevento + FROM %s WHERE utimestamp >= %d AND id_grupo IN (%s) GROUP BY id_agentmodule, event_type ORDER BY count DESC LIMIT %d', + $event_table, $timestamp, implode(',', $this->values['groupId']), $this->values['amountShow'] @@ -405,11 +408,12 @@ class TopNEventByModuleWidget extends Widget id_agentmodule, event_type, COUNT(*) AS count - FROM tevento + FROM %s WHERE utimestamp >= %d GROUP BY id_agentmodule, event_type ORDER BY count DESC LIMIT %d', + $event_table, $timestamp, $this->values['amountShow'] );