fixed top n widgets in meta

This commit is contained in:
alejandro.campos@artica.es 2021-07-01 15:07:52 +02:00
parent b0c640767e
commit a88a131152
3 changed files with 50 additions and 11 deletions

View File

@ -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 .= '<div class="container-center">';

View File

@ -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 .= '<div class="container-center">';
$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'].')';

View File

@ -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 = '<div class="container-center">';
$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']
);