diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index abe88ced7d..a60905eb6d 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.759-220131 +Version: 7.0NG.759-220201 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 3ab9e49185..b3960691f9 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.759-220131" +pandora_version="7.0NG.759-220201" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 54ee88aa27..eaaa5e3b11 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -1015,7 +1015,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.759'; -use constant AGENT_BUILD => '220131'; +use constant AGENT_BUILD => '220201'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index 32ed299fe3..758e081d8e 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.759 -%define release 220131 +%define release 220201 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 07d2dae6ce..13401fc9f2 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.759 -%define release 220131 +%define release 220201 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index dd049d0aaa..fc53727e37 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.759" -PI_BUILD="220131" +PI_BUILD="220201" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 62c227d868..d4b1fb9af9 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{220131} +{220201} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 5011b66ea5..1336fc4a15 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.759 Build 220131") +#define PANDORA_VERSION ("7.0NG.759 Build 220201") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 9173794b62..c660e0abf8 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.759(Build 220131))" + VALUE "ProductVersion", "(7.0NG.759(Build 220201))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index aa5f8e9d60..5440ca40a3 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.759-220131 +Version: 7.0NG.759-220201 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 7b425843c8..6480cde404 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.759-220131" +pandora_version="7.0NG.759-220201" package_pear=0 package_pandora=1 diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index bf96dd1cdd..990b0bac77 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -116,6 +116,7 @@ if (is_ajax() === true) { '|' ); $force_serialized = (bool) get_parameter('force_serialized', false); + $nodes = (array) get_parameter('nodes', []); if ((bool) check_acl($config['id_user'], $id_group, 'AR') === false) { db_pandora_audit( @@ -157,6 +158,10 @@ if (is_ajax() === true) { $filter[$_sql_post] = '1'; } + if (is_metaconsole() === true && empty($nodes) === false) { + $filter['id_server'] = $nodes; + } + $id_groups_get_agents = $id_group; if ($id_group == 0 && $privilege != '') { $groups = users_get_groups($config['id_user'], $privilege, false); diff --git a/pandora_console/godmode/massive/massive_delete_agents.php b/pandora_console/godmode/massive/massive_delete_agents.php index 7fb1122b03..e85a12486d 100755 --- a/pandora_console/godmode/massive/massive_delete_agents.php +++ b/pandora_console/godmode/massive/massive_delete_agents.php @@ -14,7 +14,7 @@ * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * * ============================================================================ - * Copyright (c) 2005-2021 Artica Soluciones Tecnologicas + * Copyright (c) 2005-2022 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 @@ -26,10 +26,13 @@ * ============================================================================ */ +use PandoraFMS\Agent; +use PandoraFMS\Enterprise\Metaconsole\Node; + // Begin. check_login(); -if (! check_acl($config['id_user'], 0, 'AW')) { +if ((bool) check_acl($config['id_user'], 0, 'AW') === false) { db_pandora_audit( AUDIT_LOG_ACL_VIOLATION, 'Trying to access massive agent deletion section' @@ -38,30 +41,63 @@ if (! check_acl($config['id_user'], 0, 'AW')) { return; } -require_once 'include/functions_agents.php'; -require_once 'include/functions_alerts.php'; -require_once 'include/functions_modules.php'; -require_once 'include/functions_users.php'; +require_once $config['homedir'].'/include/functions_agents.php'; +require_once $config['homedir'].'/include/functions_alerts.php'; +require_once $config['homedir'].'/include/functions_modules.php'; +require_once $config['homedir'].'/include/functions_users.php'; +require_once $config['homedir'].'/include/functions_massive_operations.php'; +/** + * Bulk operations Delete. + * + * @param array $id_agents Agents to delete. + * + * @return boolean + */ function process_manage_delete($id_agents) { - if (empty($id_agents)) { + if (empty($id_agents) === true) { ui_print_error_message(__('No agents selected')); return false; } $id_agents = (array) $id_agents; - $copy_modules = (bool) get_parameter('copy_modules'); - $copy_alerts = (bool) get_parameter('copy_alerts'); - - $error = false; $count_deleted = 0; $agent_id_restore = 0; foreach ($id_agents as $id_agent) { - $success = agents_delete_agent($id_agent); - if (! $success) { + if (is_metaconsole() === true) { + $array_id = explode('|', $id_agent); + try { + $node = new Node((int) $array_id[0]); + $node->connect(); + + $agent = new Agent((int) $array_id[1]); + $success = $agent->delete(); + + $node->disconnect(); + + $success = agent_delete_from_metaconsole( + $array_id[1], + $array_id[0] + ); + } catch (\Exception $e) { + // Unexistent agent. + $success = false; + $node->disconnect(); + } + } else { + try { + $agent = new Agent($id_agent); + $success = $agent->delete(); + } catch (\Exception $e) { + // Unexistent agent. + $success = false; + } + } + + if ($success === false) { $agent_id_restore = $id_agent; break; } @@ -69,11 +105,22 @@ function process_manage_delete($id_agents) $count_deleted++; } - if (! $success) { + if ($success === false) { + if (is_metaconsole() === true) { + $array_id = explode('|', $agent_id_restore); + $alias = agents_get_alias_metaconsole( + $array_id[1], + 'none', + $array_id[0] + ); + } else { + $alias = agents_get_alias($agent_id_restore); + } + ui_print_error_message( sprintf( __('There was an error deleting the agent, the operation has been cancelled Could not delete agent %s'), - agents_get_name($agent_id_restore) + $alias ) ); @@ -96,14 +143,14 @@ function process_manage_delete($id_agents) $id_group = (int) get_parameter('id_group'); $id_agents = get_parameter('id_agents'); $recursion = get_parameter('recursion'); - $delete = (bool) get_parameter_post('delete'); -if ($delete) { +if ($delete === true) { $result = process_manage_delete($id_agents); $info = '{"Agent":"'.implode(',', $id_agents).'"}'; - if ($result) { + + if ($result === true) { db_pandora_audit( AUDIT_LOG_MASSIVE_MANAGEMENT, 'Delete agent ', @@ -122,8 +169,7 @@ if ($delete) { } } -$groups = users_get_groups(); - +$table = new stdClass; $table->id = 'delete_table'; $table->class = 'databox filters'; $table->width = '100%'; @@ -189,31 +235,98 @@ $table->data[1][3] = html_print_select( __('All'), 2, true, + false, + true, '', - '', - '', - '', + false, 'width:30%;' ); -$table->data[2][0] = __('Agents'); -$table->data[2][0] .= ''; -$table->data[2][0] .= html_print_image('images/spinner.png', true); -$table->data[2][0] .= ''; -$table->data[2][1] = html_print_select( - agents_get_group_agents(array_keys(users_get_groups($config['id_user'], 'AW', false)), false, 'none'), +if (is_metaconsole() === true) { + $servers = metaconsole_get_servers(); + $server_fields = []; + foreach ($servers as $key => $server) { + $server_fields[$key] = $server['server_name']; + } + + $table->data[2][2] = __('Node'); + $table->data[2][3] = html_print_select( + $server_fields, + 'nodes[]', + 0, + false, + '', + '', + true, + true, + true, + '', + false, + 'min-width: 500px; max-width: 500px; max-height: 100px', + false, + false, + false, + '', + false, + false, + false, + false, + true, + true, + true + ); +} + +$table->data[3][0] = __('Agents'); +$table->data[3][0] .= ''; +$table->data[3][0] .= html_print_image('images/spinner.png', true); +$table->data[3][0] .= ''; + +$agents = agents_get_group_agents( + array_keys(users_get_groups($config['id_user'], 'AW', false)), + ['disabled' => 2], + 'none', + false, + false, + is_metaconsole(), + '|' +); + +$table->data[3][1] = html_print_select( + $agents, 'id_agents[]', 0, false, '', '', true, + true, + true, + '', + false, + 'min-width: 500px; max-width: 500px; max-height: 100px', + false, + false, + false, + '', + false, + false, + false, + false, + true, + true, true ); -echo '