diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index a9a6d3938d..ff7682cad0 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.744-200319 +Version: 7.0NG.744-200324 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 ed7b218c92..c26d75c3d9 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.744-200319" +pandora_version="7.0NG.744-200324" 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 44226ce0e5..1f805cb60b 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -55,7 +55,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.744'; -use constant AGENT_BUILD => '200319'; +use constant AGENT_BUILD => '200324'; # 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 5467e321c4..6bfc78e0b1 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.744 -%define release 200319 +%define release 200324 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 f1bb0556d5..11643033d2 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.744 -%define release 200319 +%define release 200324 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 5ef15ed4fa..4cc67f8f26 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.744" -PI_BUILD="200319" +PI_BUILD="200324" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index b344d704fe..e4d431e67e 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{200319} +{200324} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 4c697a7073..84cf1a3a8b 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.744(Build 200319)") +#define PANDORA_VERSION ("7.0NG.744(Build 200324)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 7b8b9e9061..c5c323f618 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.744(Build 200319))" + VALUE "ProductVersion", "(7.0NG.744(Build 200324))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index fa39d49b93..560e7b251b 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.744-200319 +Version: 7.0NG.744-200324 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 6375f0d81c..4b021ef02a 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.744-200319" +pandora_version="7.0NG.744-200324" package_pear=0 package_pandora=1 diff --git a/pandora_console/extras/mr/37.sql b/pandora_console/extras/mr/37.sql index efd118bdd1..c53f5e3c09 100644 --- a/pandora_console/extras/mr/37.sql +++ b/pandora_console/extras/mr/37.sql @@ -4,5 +4,8 @@ ALTER TABLE `tagente_estado` ADD COLUMN `last_status_change` bigint(20) NOT NULL UPDATE `tconfig` SET `value`='policy,agent,data_type,module_name,server_type,interval,status,last_status_change,graph,warn,data,timestamp' WHERE `token` = 'status_monitor_fields'; +ALTER TABLE `talert_templates` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0; +ALTER TABLE `tevent_alert` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0; +ALTER TABLE `talert_snmp` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0; -COMMIT; \ No newline at end of file +COMMIT; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index bc08477b28..093258fe43 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -666,6 +666,7 @@ CREATE TABLE IF NOT EXISTS `tevent_alert` ( ALTER TABLE `tevent_alert` ADD COLUMN `special_days` tinyint(1) default 0; ALTER TABLE `tevent_alert` MODIFY COLUMN `time_threshold` int(10) NOT NULL default 86400; +ALTER TABLE `tevent_alert` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0; -- ----------------------------------------------------- -- Table `tevent_alert_action` @@ -1239,6 +1240,7 @@ ALTER TABLE talert_templates ADD COLUMN `field12_recovery` TEXT NOT NULL DEFAULT ALTER TABLE talert_templates ADD COLUMN `field13_recovery` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_templates ADD COLUMN `field14_recovery` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_templates ADD COLUMN `field15_recovery` TEXT NOT NULL DEFAULT ""; +ALTER TABLE `talert_templates` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0; -- --------------------------------------------------------------------- -- Table `talert_snmp` @@ -1248,6 +1250,7 @@ ALTER TABLE talert_snmp ADD COLUMN `al_field12` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_snmp ADD COLUMN `al_field13` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_snmp ADD COLUMN `al_field14` TEXT NOT NULL DEFAULT ""; ALTER TABLE talert_snmp ADD COLUMN `al_field15` TEXT NOT NULL DEFAULT ""; +ALTER TABLE `talert_snmp` ADD COLUMN `disable_event` tinyint(1) DEFAULT 0; ALTER TABLE `talert_snmp` MODIFY COLUMN `al_field11` text NOT NULL, MODIFY COLUMN `al_field12` text NOT NULL, MODIFY COLUMN `al_field13` text NOT NULL, diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index d4292bc465..e5a10f0a53 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -227,7 +227,9 @@ if (!$new_agent && $alias != '') { $agent_options_update = 'agent_options_update'; // Delete link from here. - $table_agent_name .= "".html_print_image('images/cross.png', true, ['title' => __('Delete agent')]).''; + if (!is_central_policies_on_node()) { + $table_agent_name .= "".html_print_image('images/cross.png', true, ['title' => __('Delete agent')]).''; + } // Remote configuration available. if (isset($filename)) { diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 3d2db9994a..244e1d8618 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -62,6 +62,10 @@ $onheader = ['view' => $viewtab]; // Header. ui_print_page_header(__('Agents defined in %s', get_product_name()), 'images/agent_mc.png', false, '', true, $onheader); +if (is_central_policies_on_node()) { + ui_print_warning_message(__('This node is configured with centralized mode. To delete an agent go to metaconsole.')); +} + // Perform actions. $agent_to_delete = (int) get_parameter('borrar_agente'); $enable_agent = (int) get_parameter('enable_agent'); @@ -694,7 +698,7 @@ if ($agents !== false) { echo html_print_image('images/lightbulb.png', true, ['alt' => __('Disable agent'), 'title' => __('Disable agent')]).''; } - if ($check_aw) { + if ($check_aw && !is_central_policies_on_node()) { echo " $max, 'min_value' => $min, 'matches_value' => $matches, + 'disable_event' => $disable_event, ]; // Different datetimes format for oracle @@ -532,6 +534,7 @@ if ($id && ! $create_template) { $max_alerts = $template['max_alerts']; $min_alerts = $template['min_alerts']; $min_alerts_reset_counter = $template['min_alerts_reset_counter']; + $disable_event = $template['disable_event']; $threshold = $template['time_threshold']; $fields = []; for ($i = 1; $i <= $config['max_macro_fields']; $i++) { @@ -578,8 +581,7 @@ if ($step == 2) { // Firing conditions and events $table->colspan = []; - $table->colspan[4][1] = 3; - + // $table->colspan[4][1] = 1; $table->data[0][0] = __('Days of week'); $table->data[0][1] = __('Mon'); $table->data[0][1] .= html_print_checkbox('monday', 1, $monday, true); @@ -653,6 +655,9 @@ if ($step == 2) { true ); + $table->data[4][2] = __('Disable event'); + $table->data[4][3] = html_print_checkbox('disable_event', 1, $disable_event, true); + $table->data[5][0] = __('Default action'); $usr_groups = implode(',', array_keys(users_get_groups($config['id_user'], 'LM', true))); switch ($config['dbtype']) { diff --git a/pandora_console/godmode/groups/group_list.php b/pandora_console/godmode/groups/group_list.php index 8cb3c106c1..39fed17c8b 100644 --- a/pandora_console/godmode/groups/group_list.php +++ b/pandora_console/godmode/groups/group_list.php @@ -443,37 +443,140 @@ if (($delete_group) && (check_acl($config['id_user'], 0, 'PM'))) { $usedGroup = groups_check_used($id_group); if (!$usedGroup['return']) { - $group = db_get_row_filter( - 'tgrupo', - ['id_grupo' => $id_group] - ); + $errors_meta = false; + if (is_metaconsole()) { + $group_name = groups_get_name($id_group); + $servers = metaconsole_get_servers(); - db_process_sql_update( - 'tgrupo', - ['parent' => $group['parent']], - ['parent' => $id_group] - ); + $error_counter = 0; + $success_counter = 0; + $success_nodes = []; + $error_nodes = []; + // Check if the group can be deleted or not. + foreach ($servers as $server) { + if (metaconsole_connect($server) == NOERR) { + $result_exist_group = db_get_row_filter('tgrupo', ['nombre' => $group_name, 'id_grupo' => $id_group]); + if ($result_exist_group !== false) { + $used_group = groups_check_used($id_group); + // Save the names of the nodes that are empty and can be deleted, and those that cannot. + if (!$used_group['return']) { + $success_nodes[] .= $server['server_name']; + $success_counter++; + } else { + $error_nodes[] .= $server['server_name']; + $error_counter++; + } + } + } - $result = db_process_sql_delete( - 'tgroup_stat', - ['id_group' => $id_group] - ); + metaconsole_restore_db(); + } - $result = db_process_sql_delete( - 'tgrupo', - ['id_grupo' => $id_group] - ); + if ($error_counter > 0) { + ui_print_error_message( + __('The group %s could not be deleted because it is not empty in the nodes', $group_name).': '.implode(', ', $error_nodes) + ); + $errors_meta = true; + } else { + if ($success_counter > 0) { + $error_deleting_counter = 0; + $success_deleting_counter = 0; + $error_deleting = []; + $success_deleting = []; + $error_connecting_node = []; + // Delete the group in the nodes. + foreach ($servers as $server) { + if (metaconsole_connect($server) == NOERR) { + $group = db_get_row_filter( + 'tgrupo', + ['id_grupo' => $id_group] + ); + + db_process_sql_update( + 'tgrupo', + ['parent' => $group['parent']], + ['parent' => $id_group] + ); + + db_process_sql_delete( + 'tgroup_stat', + ['id_group' => $id_group] + ); + + $result = db_process_sql_delete( + 'tgrupo', + ['id_grupo' => $id_group] + ); + + if ($result === false) { + $error_deleting[] .= $server['server_name']; + $error_deleting_counter++; + } else { + $success_deleting[] .= $server['server_name']; + $success_deleting_counter++; + } + } else { + $error_deleting_counter++; + $error_connecting_node[] .= $server['server_name']; + } + + metaconsole_restore_db(); + } + + // If the group could not be deleted in any node, do not delete it in meta. + if ($error_deleting_counter > 0) { + $errors_meta = true; + if (!empty($error_connecting_node)) { + ui_print_error_message(__('Error connecting to %s', implode(', ', $error_connecting_node).'. The group has not been deleted in the metaconsole.')); + } + + if (!empty($error_deleting)) { + ui_print_error_message( + __('The group has not been deleted in the metaconsole due to an error in the node database').': '.implode(', ', $error_deleting) + ); + } + } + + if ($success_deleting_counter > 0) { + ui_print_success_message(__('The group %s has been deleted in the nodes', $group_name).': '.implode(', ', $success_deleting)); + } + } + } + } + + if ($errors_meta === false) { + $group = db_get_row_filter( + 'tgrupo', + ['id_grupo' => $id_group] + ); + + db_process_sql_update( + 'tgrupo', + ['parent' => $group['parent']], + ['parent' => $id_group] + ); + + $result = db_process_sql_delete( + 'tgroup_stat', + ['id_group' => $id_group] + ); + + $result = db_process_sql_delete( + 'tgrupo', + ['id_grupo' => $id_group] + ); + + if ($result && (!$usedGroup['return'])) { + ui_print_success_message(__('Group successfully deleted')); + } else { + ui_print_error_message(__('There was a problem deleting group')); + } + } } else { ui_print_error_message( sprintf(__('The group is not empty. It is use in %s.'), implode(', ', $usedGroup['tables'])) ); } - - if ($result && (!$usedGroup['return'])) { - ui_print_success_message(__('Group successfully deleted')); - } else { - ui_print_error_message(__('There was a problem deleting group')); - } } @@ -636,7 +739,12 @@ if ($tab == 'tree') { ] ).''; - $confirm_message = __('Are you sure?'); + if (is_metaconsole()) { + $confirm_message = __('Are you sure? This group will also be deleted in all the nodes.'); + } else { + $confirm_message = __('Are you sure?'); + } + if ($group['has_child']) { $confirm_message = __('The child groups will be updated to use the parent id of the deleted group').'. '.$confirm_message; } diff --git a/pandora_console/godmode/massive/massive_delete_agents.php b/pandora_console/godmode/massive/massive_delete_agents.php index c886e11091..299d880336 100755 --- a/pandora_console/godmode/massive/massive_delete_agents.php +++ b/pandora_console/godmode/massive/massive_delete_agents.php @@ -186,11 +186,13 @@ $table->data[2][1] = html_print_select( echo '
'; echo '