Merge branch 'ent-10144-modo-centralizado-impide-ver-en-que-agentes-se-usan-los-plugins' into 'develop'

Ent 10144 modo centralizado impide ver en que agentes se usan los plugins

See merge request artica/pandorafms!6004
This commit is contained in:
Matias Didier 2023-06-28 10:10:48 +00:00
commit 3c748d2520
1 changed files with 115 additions and 67 deletions

View File

@ -57,21 +57,9 @@ if (is_ajax()) {
$network_components = [];
}
$modules = db_get_all_rows_filter(
'tagente_modulo',
[
'delete_pending' => 0,
'id_plugin' => $id_plugin,
]
);
if (empty($modules)) {
$modules = [];
}
$table = new stdClass();
$table->width = '100%';
$table->head[0] = __('Network Components');
// $table->data = [];
foreach ($network_components as $net_comp) {
$table->data[] = [$net_comp['name']];
}
@ -80,6 +68,67 @@ if (is_ajax()) {
html_print_table($table);
}
if (is_metaconsole() === true) {
$connection_names = metaconsole_get_connection_names();
$modules = [];
foreach ($connection_names as $connection_name) {
$connected = metaconsole_connect(metaconsole_get_connection($connection_name));
if ($connected != NOERR) {
continue;
}
$modules_node = db_get_all_rows_filter(
'tagente_modulo',
[
'delete_pending' => 0,
'id_plugin' => $id_plugin,
]
);
if (empty($modules_node) === false) {
foreach ($modules_node as $key => $mod) {
$modules_node[$key]['name_agent'] = modules_get_agentmodule_agent_alias($mod['id_agente_modulo']);
}
$modules[$connection_name] = $modules_node;
}
metaconsole_restore_db();
}
} else {
$modules = db_get_all_rows_filter(
'tagente_modulo',
[
'delete_pending' => 0,
'id_plugin' => $id_plugin,
]
);
}
if (empty($modules)) {
$modules = [];
}
if (is_metaconsole() === true) {
foreach ($modules as $name_server => $modules_node) {
$table = new stdClass();
$table->width = '100%';
$table->head[0] = $name_server.' - '.__('Agent');
$table->head[1] = $name_server.' - '.__('Module');
foreach ($modules_node as $mod) {
$server = metaconsole_get_servers(metaconsole_get_id_server($name_server));
$agent_name = '<a href="'.$server['server_url'].'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$mod['id_agente'].'">'.$mod['name_agent'].'</a>';
$table->data[] = [
$agent_name,
$mod['nombre'],
];
}
if (!empty($table->data)) {
html_print_table($table);
}
}
} else {
$table = new stdClass();
$table->width = '100%';
$table->head[0] = __('Agent');
@ -99,6 +148,7 @@ if (is_ajax()) {
if (!empty($table->data)) {
html_print_table($table);
}
}
return;
}
@ -991,16 +1041,7 @@ if (empty($create) === false || empty($view) === false) {
$pluginTable->data = [];
foreach ($rows as $k => $row) {
if ($management_allowed === true) {
$tableActionButtons = [];
$pluginNameContent = html_print_anchor(
[
'href' => 'index.php?sec=$sec&sec2=godmode/servers/plugin&view='.$row['id'].'&tab=plugins&pure='.$config['pure'],
'content' => $row['name'],
],
true
);
// Show it is locket.
$modules_using_plugin = db_get_value_filter(
'count(*)',
@ -1032,6 +1073,15 @@ if (empty($create) === false || empty($view) === false) {
);
}
if ($management_allowed === true) {
$pluginNameContent = html_print_anchor(
[
'href' => 'index.php?sec=$sec&sec2=godmode/servers/plugin&view='.$row['id'].'&tab=plugins&pure='.$config['pure'],
'content' => $row['name'],
],
true
);
$tableActionButtons[] = html_print_anchor(
[
'href' => 'index.php?sec=$sec&sec2=godmode/servers/plugin&tab=$tab&view='.$row['id'].'&tab=plugins&pure='.$config['pure'],
@ -1072,7 +1122,6 @@ if (empty($create) === false || empty($view) === false) {
$pluginTable->data[$k][1] = ((int) $row['plugin_type'] === 0) ? __('Standard') : __('Nagios');
$pluginTable->data[$k][2] = $row['execute'];
if ($management_allowed === true) {
$pluginTable->data[$k][3] = html_print_div(
[
'class' => 'table_action_buttons',
@ -1081,7 +1130,6 @@ if (empty($create) === false || empty($view) === false) {
true
);
}
}
html_print_table($pluginTable);
} else {