diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index aa5eedaa03..b2ed508ab3 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-220105 +Version: 7.0NG.759-220113 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 07feacaab3..88eef55d92 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-220105" +pandora_version="7.0NG.759-220113" 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 0bd21f041a..bee6aafd05 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 => '220105'; +use constant AGENT_BUILD => '220113'; # 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 933a922ca7..d6c5fcbb89 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 220105 +%define release 220113 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 ec54f4dc77..ad32404e80 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 220105 +%define release 220113 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 abacbae420..7c0718478a 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="220105" +PI_BUILD="220113" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index aa101df1a3..6841bbb5bb 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{220105} +{220113} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index abd4819381..72e0c91c84 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 220105") +#define PANDORA_VERSION ("7.0NG.759 Build 220113") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 9896187251..fc3fe4ac49 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 220105))" + VALUE "ProductVersion", "(7.0NG.759(Build 220113))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 8f84afe6ea..4b0d8190ca 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.759-220105 +Version: 7.0NG.759-220113 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 81f68cb86a..9e31575c18 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-220105" +pandora_version="7.0NG.759-220113" package_pear=0 package_pandora=1 diff --git a/pandora_console/extras/delete_files/delete_files.txt b/pandora_console/extras/delete_files/delete_files.txt index a809818909..f5db52a42a 100644 --- a/pandora_console/extras/delete_files/delete_files.txt +++ b/pandora_console/extras/delete_files/delete_files.txt @@ -115,4 +115,6 @@ enterprise/include/styles/tooltipster.bundle.min.css mobile/include/javascript/jquery.mobile-1.3.1.js mobile/include/style/jquery.mobile-1.3.1.css godmode/alerts/configure_alert_special_days.php -godmode/admin_access_logs.php \ No newline at end of file +godmode/admin_access_logs.php +enterprise/extensions/backup/main.php +enterprise/extensions/backup.php \ No newline at end of file diff --git a/pandora_console/extras/mr/52.sql b/pandora_console/extras/mr/52.sql index 81f1436632..d2d5e1be65 100644 --- a/pandora_console/extras/mr/52.sql +++ b/pandora_console/extras/mr/52.sql @@ -1,5 +1,5 @@ START TRANSACTION; ALTER TABLE `tpolicy_queue` MODIFY COLUMN `progress` int(10) NOT NULL default '0'; - +CREATE INDEX `IDX_tservice_element` ON `tservice_element`(`id_service`,`id_agente_modulo`); COMMIT; \ No newline at end of file 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 6f3596cfa3..53cfa31ecb 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 @@ -480,7 +480,8 @@ CREATE TABLE IF NOT EXISTS `tservice_element` ( `id_agent` int(10) unsigned NOT NULL default 0, `id_service_child` int(10) unsigned NOT NULL default 0, `id_server_meta` int(10) unsigned NOT NULL default 0, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + INDEX `IDX_tservice_element` (`id_service`,`id_agente_modulo`) ) ENGINE=InnoDB COMMENT = 'Table to define the modules and the weights of the modules that define a service' DEFAULT CHARSET=utf8; diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 1c338abda1..7965dbc566 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -2428,7 +2428,7 @@ switch ($tab) { var aget_id_os = ''; - if('' != $('#text-name').val() && + if('' != $('#text-name').val() && '' == 19){ event.preventDefault(); @@ -2462,7 +2462,7 @@ switch ($tab) { var module_type_snmp = ''; - if('' != $('#text-name').val() && ( + if('' != $('#text-name').val() && ( module_type_snmp == 15 || module_type_snmp == 16 || module_type_snmp == 17 || module_type_snmp == 18)){ event.preventDefault(); diff --git a/pandora_console/godmode/agentes/planned_downtime.editor.php b/pandora_console/godmode/agentes/planned_downtime.editor.php index 43cb69b74f..616777ad6e 100644 --- a/pandora_console/godmode/agentes/planned_downtime.editor.php +++ b/pandora_console/godmode/agentes/planned_downtime.editor.php @@ -628,20 +628,20 @@ $table->data[5][1] = " ".ui_get_using_system_timezone_warning().' '.__('Type Periodicity:').' '.html_print_select( - [ - 'weekly' => __('Weekly'), - 'monthly' => __('Monthly'), - ], - 'type_periodicity', - $type_periodicity, - 'change_type_periodicity();', - '', - 0, - true, - false, - true, - '', - $disabled_in_execution + [ + 'weekly' => __('Weekly'), + 'monthly' => __('Monthly'), + ], + 'type_periodicity', + $type_periodicity, + 'change_type_periodicity();', + '', + 0, + true, + false, + true, + '', + $disabled_in_execution )." @@ -661,31 +661,31 @@ $table->data[5][1] = " ".__('From day:').' '.html_print_select( - $days, - 'periodically_day_from', - $periodically_day_from, - '', - '', - 0, - true, - false, - true, - '', - $disabled_in_execution + $days, + 'periodically_day_from', + $periodically_day_from, + '', + '', + 0, + true, + false, + true, + '', + $disabled_in_execution ).' '.__('To day:').' '.html_print_select( - $days, - 'periodically_day_to', - $periodically_day_to, - '', - '', - 0, - true, - false, - true, - '', - $disabled_in_execution + $days, + 'periodically_day_to', + $periodically_day_to, + '', + '', + 0, + true, + false, + true, + '', + $disabled_in_execution ).' '.ui_print_help_tip(__('The end day must be higher than the start day'), true).' @@ -694,26 +694,26 @@ $table->data[5][1] = " '.__('From hour:').' '.html_print_input_text( - 'periodically_time_from', - $periodically_time_from, - '', - 7, - 7, - true, - $disabled_in_execution + 'periodically_time_from', + $periodically_time_from, + '', + 7, + 7, + true, + $disabled_in_execution ).ui_print_help_tip( __('The end time must be higher than the start time'), true ).' '.__('To hour:').' '.html_print_input_text( - 'periodically_time_to', - $periodically_time_to, - '', - 7, - 7, - true, - $disabled_in_execution + 'periodically_time_to', + $periodically_time_to, + '', + 7, + 7, + true, + $disabled_in_execution ).ui_print_help_tip( __('The end time must be higher than the start time'), true @@ -947,9 +947,7 @@ if (empty($downtimes_agents)) { if (!$running) { $data[5] = ''; - if ($type_downtime != 'disable_agents_alerts' - && $type_downtime != 'disable_agents' - ) { + if ($type_downtime !== 'disable_agents') { $data[5] = ''.html_print_image('images/config.png', true, ['border' => '0', 'alt' => __('Delete'), 'class' => 'invert_filter']).''; } @@ -999,13 +997,13 @@ $table->data['module'][1] = " ".''.html_print_image( - 'images/cross.png', - true, - [ - 'border' => '0', - 'alt' => __('Delete'), - 'class' => 'invert_filter', - ] + 'images/cross.png', + true, + [ + 'border' => '0', + 'alt' => __('Delete'), + 'class' => 'invert_filter', + ] ).''." diff --git a/pandora_console/godmode/alerts/alert_list.list.php b/pandora_console/godmode/alerts/alert_list.list.php index 8e20aeaab7..95ace7d345 100644 --- a/pandora_console/godmode/alerts/alert_list.list.php +++ b/pandora_console/godmode/alerts/alert_list.list.php @@ -1134,7 +1134,7 @@ function show_add_action(id_alert) { }, open: function() { $(`#add_action-div-${id_alert}`).css('overflow', 'hidden'); - $("#action_select, #action_select").select2({ + $("select[id^='action_select'], select[id^='action_select']").select2({ tags: true, dropdownParent: $("#add_action-div-" + id_alert) }); diff --git a/pandora_console/godmode/alerts/configure_alert_action.php b/pandora_console/godmode/alerts/configure_alert_action.php index fd0f90d115..c8efca1f00 100644 --- a/pandora_console/godmode/alerts/configure_alert_action.php +++ b/pandora_console/godmode/alerts/configure_alert_action.php @@ -694,10 +694,19 @@ $(document).ready (function () { } } else { + var is_element_select = $("[name=field" + i + "_value]").is("select"); + $("[name=field" + i + "_value]").val(old_value); - $("[name=field" + i + "_value]").trigger('change'); + if (is_element_select === true) { + $("[name=field" + i + "_value]").trigger('change'); + } + + $("[name=field" + i + "_recovery_value]").val(old_recovery_value); - $("[name=field" + i + "_recovery_value]").trigger('change'); + + if (is_element_select === true) { + $("[name=field" + i + "_recovery_value]").trigger('change'); + } } } else { diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 16bf0f256e..de991dcfe2 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -406,6 +406,7 @@ if (check_acl($config['id_user'], 0, 'PM') || check_acl($config['id_user'], 0, ' $sub['extensions/dbmanager']['text'] = __('DB Interface'); $sub['extensions/dbmanager']['id'] = 'DB Interface'; $sub['extensions/dbmanager']['sec'] = 'gbman'; + enterprise_hook('dbBackupManager'); enterprise_hook('elasticsearch_interface_menu'); } } diff --git a/pandora_console/include/ajax/visual_console.ajax.php b/pandora_console/include/ajax/visual_console.ajax.php index 59d08a92c8..cb7e016283 100644 --- a/pandora_console/include/ajax/visual_console.ajax.php +++ b/pandora_console/include/ajax/visual_console.ajax.php @@ -36,6 +36,7 @@ $ajax = true; $render_map = (bool) get_parameter('render_map', false); $graph_javascript = (bool) get_parameter('graph_javascript', false); +$force_remote_check = (bool) get_parameter('force_remote_check', false); if ($render_map) { $width = (int) get_parameter('width', '400'); @@ -55,3 +56,36 @@ if ($render_map) { ); return; } + +if ($force_remote_check) { + $id_layout = (int) get_parameter('id_layout', false); + $data = db_get_all_rows_sql( + sprintf( + 'SELECT id_agent FROM tlayout_data WHERE id_layout = %d AND id_agent <> 0', + $id_layout + ) + ); + + if (empty($data)) { + echo '0'; + } else { + $ids = []; + foreach ($data as $key => $value) { + $ids[] = $value['id_agent']; + } + + $sql = sprintf( + 'UPDATE `tagente_modulo` SET flag = 1 WHERE `id_agente` IN (%s)', + implode(',', $ids) + ); + + $result = db_process_sql($sql); + if ($result) { + echo true; + } else { + echo '0'; + } + } + + return; +} diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index f4e3ecc90a..e43acb377c 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC220105'; +$build_version = 'PC220113'; $pandora_version = 'v7.0NG.759'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/db/mysql.php b/pandora_console/include/db/mysql.php index 8ded979b77..0c100f93d6 100644 --- a/pandora_console/include/db/mysql.php +++ b/pandora_console/include/db/mysql.php @@ -874,10 +874,10 @@ function mysql_db_format_array_where_clause_sql($values, $join='AND', $prefix=fa * * @return the first value of the first row of a table result from query. */ -function mysql_db_get_value_sql($sql, $dbconnection=false) +function mysql_db_get_value_sql($sql, $dbconnection=false, $search_history_db=false) { $sql .= ' LIMIT 1'; - $result = mysql_db_get_all_rows_sql($sql, false, true, $dbconnection); + $result = mysql_db_get_all_rows_sql($sql, $search_history_db, true, $dbconnection); if ($result === false) { return false; diff --git a/pandora_console/include/db/oracle.php b/pandora_console/include/db/oracle.php index 5000aaf719..bdf1411600 100644 --- a/pandora_console/include/db/oracle.php +++ b/pandora_console/include/db/oracle.php @@ -977,10 +977,10 @@ function oracle_recode_query($sql, $values, $join='AND', $return=true) * * @return the first value of the first row of a table result from query. */ -function oracle_db_get_value_sql($sql, $dbconnection=false) +function oracle_db_get_value_sql($sql, $dbconnection=false, $search_history_db=false) { $sql = 'SELECT * FROM ('.$sql.') WHERE rownum < 2'; - $result = oracle_db_get_all_rows_sql($sql, false, true, $dbconnection); + $result = oracle_db_get_all_rows_sql($sql, $search_history_db, true, $dbconnection); if ($result === false) { return false; diff --git a/pandora_console/include/db/postgresql.php b/pandora_console/include/db/postgresql.php index cfacdad7d6..8617920dd9 100644 --- a/pandora_console/include/db/postgresql.php +++ b/pandora_console/include/db/postgresql.php @@ -686,10 +686,10 @@ function postgresql_db_format_array_where_clause_sql($values, $join='AND', $pref * * @return the first value of the first row of a table result from query. */ -function postgresql_db_get_value_sql($sql, $dbconnection=false) +function postgresql_db_get_value_sql($sql, $dbconnection=false, $search_history_db=false) { $sql .= ' LIMIT 1'; - $result = postgresql_db_get_all_rows_sql($sql, false, true, $dbconnection); + $result = postgresql_db_get_all_rows_sql($sql, $search_history_db, true, $dbconnection); if ($result === false) { return false; diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index c87f1f62b4..6dbac49957 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -162,9 +162,13 @@ function agents_locate_agent(string $field) * * @return array|boolean Agents ids or false if error. */ -function agents_get_agent_id_by_alias($alias) +function agents_get_agent_id_by_alias($alias, $is_metaconsole=false) { - return db_get_all_rows_sql("SELECT id_agente FROM tagente WHERE upper(alias) LIKE upper('%$alias%')"); + if ($is_metaconsole === true) { + return db_get_all_rows_sql("SELECT id_tagente FROM tmetaconsole_agent WHERE upper(alias) LIKE upper('%$alias%')"); + } else { + return db_get_all_rows_sql("SELECT id_agente FROM tagente WHERE upper(alias) LIKE upper('%$alias%')"); + } } diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index bfdc8c712e..0c44c4ca12 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -9925,12 +9925,19 @@ function otherParameter2Filter($other, $return_as_array=false, $use_agent_name=f if (isset($other['data'][2]) && $other['data'][2] != '') { if ($use_agent_name === false) { - $idAgents = agents_get_agent_id_by_alias($other['data'][2]); + $idAgents = agents_get_agent_id_by_alias($other['data'][2], is_metaconsole()); if (!empty($idAgents)) { $idAgent = []; + + $id_agent_field = 'id_agente'; + + if (is_metaconsole() === true) { + $id_agent_field = 'id_tagente'; + } + foreach ($idAgents as $key => $value) { - $idAgent[] .= $value['id_agente']; + $idAgent[] .= $value[$id_agent_field]; } $filter[] = 'id_agente IN ('.implode(',', $idAgent).')'; @@ -9985,6 +9992,10 @@ function otherParameter2Filter($other, $return_as_array=false, $use_agent_name=f } } + if (isset($idTemplate) && $idTemplate != '') { + $filter['id_alert_template'] = $idTemplate; + } + if (isset($other['data'][5]) && $other['data'][5] != '') { $filter['id_usuario'] = $other['data'][5]; } @@ -11434,7 +11445,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db global $config; $table_events = 'tevento'; - if (defined('METACONSOLE')) { + if (is_metaconsole() === true) { $table_events = 'tmetaconsole_event'; } @@ -11451,10 +11462,9 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db $event_view_hr = 0; $tag = ''; $group_rep = 0; - $offset = 0; - $pagination = 40; $utimestamp_upper = 0; $utimestamp_bottom = 0; + $id_alert_template = -1; $use_agent_name = ($other['data'][16] === '1') ? true : false; @@ -11469,7 +11479,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db } if (isset($filter['id_agentmodule'])) { - $id_agentmodule = $filter['id_agentmodule']; + $id_agentmodule = $filter['id_agentmodule'][0]; } if (isset($filter['id_alert_am'])) { @@ -11488,12 +11498,8 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db $search = $filter['evento']; } - if (isset($filter['limit'])) { - $pagination = $filter['limit']; - } - - if (isset($filter['offset'])) { - $offset = $filter['offset']; + if (isset($filter['id_alert_template'])) { + $id_alert_template = $filter['id_alert_template']; } $id_group = (int) $filter['id_group']; @@ -11611,10 +11617,6 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db $sql_post .= ' AND id_agentmodule = '.$id_agentmodule; } - if ($id_alert_am != -1) { - $sql_post .= ' AND id_alert_am = '.$id_alert_am; - } - if ($id_event != -1) { $sql_post .= ' AND id_evento = '.$id_event; } @@ -11647,6 +11649,21 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db $sql_post .= ' AND ('.$filter['sql'].') '; } + // Inject agent ID filter (it is set as the first numeric key in filter array). + if (isset($filter[0]) === true) { + $sql_post .= ' AND '.$filter[0]; + } + + if ($id_alert_template !== -1) { + $sql_post .= ' AND talert_template_modules.id_alert_template = '.$id_alert_template; + } + + $alert_join = ''; + + if ($id_alert_template !== -1) { + $alert_join = ' INNER JOIN talert_template_modules ON '.$table_events.'.id_alert_am=talert_template_modules.id'; + } + if ($group_rep == 0) { switch ($config['dbtype']) { case 'mysql': @@ -11661,7 +11678,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db ORDER BY criticity DESC LIMIT 1'; } else { - if (defined('METACONSOLE')) { + if (is_metaconsole() === true) { $sql = 'SELECT *, (SELECT t2.nombre FROM tgrupo t2 @@ -11669,10 +11686,9 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db (SELECT t2.icon FROM tgrupo t2 WHERE t2.id_grupo = '.$table_events.'.id_grupo) AS group_icon - FROM '.$table_events.' + FROM '.$table_events.$alert_join.' WHERE 1=1 '.$sql_post.' - ORDER BY utimestamp DESC - LIMIT '.$offset.','.$pagination; + ORDER BY utimestamp DESC'; } else { $sql = 'SELECT *, (SELECT t1.alias @@ -11690,10 +11706,9 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db SELECT tagente_modulo.id_modulo FROM tagente_modulo WHERE tagente_modulo.id_agente_modulo=tevento.id_agentmodule)) AS module_name - FROM '.$table_events.' + FROM '.$table_events.$alert_join.' WHERE 1=1 '.$sql_post.' - ORDER BY utimestamp DESC - LIMIT '.$offset.','.$pagination; + ORDER BY utimestamp DESC'; } } break; @@ -11718,15 +11733,12 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db WHERE tagente_modulo.id_agente_modulo=tevento.id_agentmodule)) AS module_name FROM tevento WHERE 1=1 '.$sql_post.' - ORDER BY utimestamp DESC - LIMIT '.$pagination.' OFFSET '.$offset; + ORDER BY utimestamp DESC'; break; case 'oracle': // TODO TOTAL $set = []; - $set['limit'] = $pagination; - $set['offset'] = $offset; $sql = 'SELECT *, (SELECT t1.alias @@ -11764,8 +11776,7 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db FROM ".$table_events.' WHERE 1=1 '.$sql_post.' GROUP BY evento, id_agentmodule - ORDER BY timestamp_rep DESC - LIMIT '.$offset.','.$pagination; + ORDER BY timestamp_rep DESC'; break; case 'postgresql': @@ -11776,14 +11787,11 @@ function get_events_with_user($trash1, $trash2, $other, $returnType, $user_in_db FROM ".$table_events.' WHERE 1=1 '.$sql_post.' GROUP BY evento, id_agentmodule - ORDER BY timestamp_rep DESC - LIMIT '.$pagination.' OFFSET '.$offset; + ORDER BY timestamp_rep DESC'; break; case 'oracle': $set = []; - $set['limit'] = $pagination; - $set['offset'] = $offset; // TODO: Remove duplicate user comments $sql = 'SELECT a.*, b.event_rep, b.timestamp_rep FROM (SELECT * @@ -11971,7 +11979,7 @@ function api_set_event($id_event, $unused1, $params, $unused2, $unused3) * @param $returnType * @param $user_in_db */ -function api_get_events($trash1, $trash2, $other, $returnType, $user_in_db=null) +function api_get_events($node_id, $trash2, $other, $returnType, $user_in_db=null) { if ($user_in_db !== null) { $correct = get_events_with_user( @@ -12016,6 +12024,10 @@ function api_get_events($trash1, $trash2, $other, $returnType, $user_in_db=null) } if (is_metaconsole()) { + if ((int) $node_id !== 0) { + $filterString .= ' AND server_id = '.$node_id; + } + $dataRows = db_get_all_rows_filter('tmetaconsole_event', $filterString); } else { $dataRows = db_get_all_rows_filter('tevento', $filterString); diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 34bb53ef26..cbcc645fdb 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -414,21 +414,21 @@ function db_get_value_filter($field, $table, $filter, $where_join='AND', $search * * @return mixed the first value of the first row of a table result from query. */ -function db_get_value_sql($sql, $dbconnection=false) +function db_get_value_sql($sql, $dbconnection=false, $search_history_db=false) { global $config; switch ($config['dbtype']) { case 'mysql': - return mysql_db_get_value_sql($sql, $dbconnection); + return mysql_db_get_value_sql($sql, $dbconnection, $search_history_db); break; case 'postgresql': - return postgresql_db_get_value_sql($sql, $dbconnection); + return postgresql_db_get_value_sql($sql, $dbconnection, $search_history_db); break; case 'oracle': - return oracle_db_get_value_sql($sql, $dbconnection); + return oracle_db_get_value_sql($sql, $dbconnection, $search_history_db); break; } diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index b15c6216a0..2fe2372675 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -609,24 +609,15 @@ function groups_get_groups_tree_recursive($groups, $trash=0, $trash2=0) * * @return integer Status of the agents. */ -function groups_get_status($id_group=0, $strict_user=false) +function groups_get_status($id_group=0, $ignore_alerts=false) { global $config; include_once $config['homedir'].'/include/functions_reporting.php'; - if ($strict_user) { - $acltags = tags_get_user_groups_and_tags($config['id_user'], 'AR', $strict_user); - $group_status = group_get_data($config['id_user'], $strict_user, $acltags, false, 'group'); - $data['monitor_alerts_fired'] = $groups_status['_monitors_alerts_fired_']; - $data['agent_critical'] = $groups_status['_agents_critical_']; - $data['agent_warning'] = $groups_status['_agents_warning_']; - $data['agent_unknown'] = $groups_status['_agents_unknown_']; - } else { - $data = reporting_get_group_stats_resume($id_group); - } + $data = reporting_get_group_stats_resume($id_group); - if ($data['monitor_alerts_fired'] > 0) { + if ($data['monitor_alerts_fired'] > 0 && $ignore_alerts == false) { return AGENT_STATUS_ALERT_FIRED; } else if ($data['agent_critical'] > 0) { return AGENT_STATUS_CRITICAL; diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 0873ba072a..4b388b0014 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -2425,6 +2425,38 @@ function html_print_div( } +/** + * Render an
 tag for show code.
+ * For debug purposes, see for `hd()` function.
+ *
+ * @param string  $content    Content of tag.
+ * @param boolean $return     Return the tag string formed.
+ * @param array   $attributes Attributes availables for pre tags.
+ *
+ * @return string
+ */
+function html_print_code(
+    string $content,
+    bool $return=true,
+    array $attributes=[]
+) {
+    $output = ' $value) {
+            $output .= ' '.$attribute.'="'.io_safe_input_html($value).'"';
+        }
+    }
+
+    $output .= sprintf('>%s
', $content); + + if ($return === true) { + return $output; + } else { + echo $output; + } +} + + /** * Render an anchor html element. * diff --git a/pandora_console/include/functions_io.php b/pandora_console/include/functions_io.php index 853fbb330a..f11c49a939 100755 --- a/pandora_console/include/functions_io.php +++ b/pandora_console/include/functions_io.php @@ -545,11 +545,12 @@ function io_input_password($password) * Process the given password read from the Pandora FMS Database, * decrypting it if necessary. * - * @param string password Password read from the DB. + * @param string $password Password read from the DB. + * @param string $wrappedBy Wrap the password with the informed character. * * @return string The processed password. */ -function io_output_password($password) +function io_output_password($password, $wrappedBy='') { global $config; @@ -562,11 +563,14 @@ function io_output_password($password) ] ); - if ($plaintext === ENTERPRISE_NOT_HOOK) { - return io_safe_output($password); - } + $output = ($plaintext === ENTERPRISE_NOT_HOOK) ? $password : $plaintext; - return io_safe_output($plaintext); + return sprintf( + '%s%s%s', + $wrappedBy, + io_safe_output($output), + $wrappedBy + ); } diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 8caca733a5..63e39a652a 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -8775,6 +8775,8 @@ function reporting_increment($report, $content) $return['data'] = []; + $search_in_history_db = db_search_in_history_db($return['from']); + if (is_metaconsole()) { $sql1 = 'SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.' AND utimestamp <= '.(time() - $period).' ORDER BY utimestamp DESC'; @@ -8801,17 +8803,23 @@ function reporting_increment($report, $content) $connection = false; } - $old_data = db_get_value_sql($sql1); + $old_data = db_get_value_sql($sql1, false, $search_in_history_db); - $last_data = db_get_value_sql($sql2); + $last_data = db_get_value_sql($sql2, false, $search_in_history_db); } } else { $old_data = db_get_value_sql( 'SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.' - AND utimestamp <= '.(time() - $period).' ORDER BY utimestamp DESC' + AND utimestamp <= '.(time() - $period).' ORDER BY utimestamp DESC', + false, + $search_in_history_db ); - $last_data = db_get_value_sql('SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.' ORDER BY utimestamp DESC'); + $last_data = db_get_value_sql( + 'SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.' ORDER BY utimestamp DESC', + false, + $search_in_history_db + ); } if (!is_metaconsole()) { diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php index 4f405efb00..cf61fec7a7 100644 --- a/pandora_console/include/functions_servers.php +++ b/pandora_console/include/functions_servers.php @@ -1347,7 +1347,16 @@ function servers_get_server_string_name(int $server) return __('WUX server'); case SERVER_TYPE_ENTERPRISE_SATELLITE: - return __('Satellite'); + return __('Satellite server'); + + case SERVER_TYPE_ENTERPRISE_TRANSACTIONAL: + return __('Transactional server'); + + case SERVER_TYPE_ALERT: + return __('Alert server'); + + case SERVER_TYPE_NCM: + return __('NCM server'); default: return __('N/A'); diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index f553fac7d0..f05d0de6e2 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -3420,7 +3420,7 @@ function visual_map_get_status_element($layoutData) break; case GROUP_ITEM: - $group_status = groups_get_status($layoutData['id_group']); + $group_status = groups_get_status($layoutData['id_group'], true); switch ($group_status) { case AGENT_STATUS_ALERT_FIRED: diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index 6bd2782d3c..13e72bdaca 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -437,25 +437,23 @@ function pandoraFlotHBars( var format = new Array(); for (var i = 0; i < labels_total.length; i++) { var label = labels_total[i][1]; - // var shortLabel = reduceText(label, 25); - var title = label; - if (label.length > 30) { - label = reduceText(label, 30); - } var div_attributes = 'style="font-size:' + font_size + "pt !important;" + - " margin: 0; max-width: 150px;" + - "margin-right:5px"; - +"margin-left: -1.5em"; - +"text-align: right"; + "margin: 0; max-width: 200px;" + + "margin-right:5px;" + + "margin-left: -1.5em" + + "text-align: right" + + "text-overflow: ellipsis;" + + "overflow: hidden;" + + "white-space: pre;"; if (label.indexOf("
") != -1) { div_attributes += "min-height: 2.5em;"; } - div_attributes += '" title="' + title + '" style="overflow: hidden;"'; + div_attributes += '" title="' + label + '" style="overflow: hidden;"'; format.push([i, "
" + label + "
"]); } @@ -3270,5 +3268,6 @@ function reduceText(text, maxLength) { if (text.length <= maxLength) return text; var firstSlideEnd = parseInt((maxLength - 3) / 1.6); var str_cut = text.substr(0, firstSlideEnd); - return str_cut + "...
" + text.substr(-firstSlideEnd - 3); + //return str_cut + "...
" + text.substr(-firstSlideEnd - 3); + return str_cut + "..." + text.substr(-firstSlideEnd - 3); } diff --git a/pandora_console/include/javascript/pandora_dashboards.js b/pandora_console/include/javascript/pandora_dashboards.js index a3cc3b24fc..e223e485d2 100644 --- a/pandora_console/include/javascript/pandora_dashboards.js +++ b/pandora_console/include/javascript/pandora_dashboards.js @@ -389,7 +389,7 @@ function initialiceLayout(data) { widgetId: widgetId }, width: widgetId == 14 || widgetId == 2 || widgetId == 23 ? 750 : 450, - maxHeight: 600, + maxHeight: 610, minHeight: 400 }, onsubmit: { diff --git a/pandora_console/include/javascript/tree/TreeController.js b/pandora_console/include/javascript/tree/TreeController.js index 461066abbc..afa55434c0 100644 --- a/pandora_console/include/javascript/tree/TreeController.js +++ b/pandora_console/include/javascript/tree/TreeController.js @@ -976,6 +976,11 @@ var TreeController = { "" ); + // Avoiding 'undefined' text. + if (typeof element.value === "undefined") { + element.value = ""; + } + // Value. $content.append( '' + element.value + "" diff --git a/pandora_console/include/lib/Dashboard/Widgets/maps_status.php b/pandora_console/include/lib/Dashboard/Widgets/maps_status.php index 34e28dd8f1..2f59a29f0a 100755 --- a/pandora_console/include/lib/Dashboard/Widgets/maps_status.php +++ b/pandora_console/include/lib/Dashboard/Widgets/maps_status.php @@ -323,11 +323,22 @@ class MapsStatusWidget extends Widget $data = []; $url = $config['homeurl']; - $url .= 'index.php?sec=visualc'; - $url .= '&sec2=operation/visual_console/render_view&refr=60'; + if (\is_metaconsole() === true) { + $url .= sprintf( + 'index.php?sec=screen&sec2=screens/screens&action=visualmap&pure=0&refr=%s&id_visualmap=%s', + $config['vc_refr'], + $id_layout + ); + } else { + $url .= sprintf( + 'index.php?sec=visualc&sec2=operation/visual_console/render_view&refr=%s&id=%s', + $config['vc_refr'], + $id_layout + ); + } // This will give us the group name. - $data[0] = '
'; + $data[0] = ''; $data[0] .= $user_layouts[$id_layout]['name']; $data[0] .= ''; diff --git a/pandora_console/include/lib/Dashboard/Widgets/network_map.php b/pandora_console/include/lib/Dashboard/Widgets/network_map.php index ee01c9a83c..c07e09758f 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/network_map.php +++ b/pandora_console/include/lib/Dashboard/Widgets/network_map.php @@ -253,6 +253,14 @@ class NetworkMapWidget extends Widget // Retrieve global - common inputs. $inputs = parent::getFormInputs(); + $inputs[] = [ + 'label' => \ui_print_info_message( + __('It is recommended to have only one such widget in the control panel.'), + '', + true + ), + ]; + // Default values. if (isset($values['xOffset']) === false) { $values['xOffset'] = 0; diff --git a/pandora_console/include/lib/Dashboard/Widgets/top_n.php b/pandora_console/include/lib/Dashboard/Widgets/top_n.php index 446f15af21..24845cec87 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/top_n.php +++ b/pandora_console/include/lib/Dashboard/Widgets/top_n.php @@ -455,6 +455,7 @@ class TopNWidget extends Widget $data_hbar = []; foreach ($modules as $module) { + $module['aliasAgent'] = ui_print_truncate_text($module['aliasAgent'], 20); $item_name = ''; $item_name = $module['aliasAgent'].' - '.$module['nameModule']; $data_hbar[$item_name]['g'] = $module[$display]; diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php b/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php index 885721cda6..286d766c14 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/Group.php @@ -346,9 +346,7 @@ final class Group extends Item $countStatus = \db_get_row_sql($sql); - if ($countStatus['fired'] > 0) { - $status = AGENT_STATUS_ALERT_FIRED; - } else if ($countStatus['critical'] > 0) { + if ($countStatus['critical'] > 0) { $status = AGENT_STATUS_CRITICAL; } else if ($countStatus['warning'] > 0) { $status = AGENT_STATUS_WARNING; @@ -359,7 +357,7 @@ final class Group extends Item } } else { // Get the status img src. - $status = \groups_get_status($groupId); + $status = \groups_get_status($groupId, true); } $imagePath = \visual_map_get_image_status_element($data, $status); diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index ca46e46291..5ff90674f4 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -8435,6 +8435,12 @@ div.stat-win-spinner img { font-size: 12px; } +/* For backups dt, can be useful for others */ +#backups_list > thead > tr > th:last-child, +#backups_list > tbody > tr > td:last-child { + text-align: center; +} + /* err_msg_centralised */ div#err_msg_centralised div { margin-top: 1em; diff --git a/pandora_console/index.php b/pandora_console/index.php index b9e3585579..7828b2c700 100755 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -424,6 +424,8 @@ if (! isset($config['id_user'])) { // Process logout. include 'general/logoff.php'; } + + $validatedCSRF = true; } else { // process_user_login is a virtual function which should be defined in each auth file. // It accepts username and password. The rest should be internal to the auth file. diff --git a/pandora_console/install.php b/pandora_console/install.php index 8a49ebdac7..bad3470acd 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
var treeController = TreeController.getController(); - + processTreeSearch(); $("form#tree_search").submit(function(e) { diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index 6c93b10a71..0a682d3046 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -186,6 +186,8 @@ if (isset($_GET['modified']) && !$view_mode) { } else { if (!empty($password_new) && !empty($password_confirm)) { $success_msg = __('Password successfully updated'); + } else if ($upd_info['id_skin'] !== $user_info['id_skin']) { + $success_msg = __('Skin successfully updated'); } else { $return = false; $error_msg = __('No changes have been made'); @@ -549,13 +551,13 @@ $table_ichanges = '
'.html_print_image( - 'images/darrowright_green.png', - true, - [ - 'id' => 'right_autorefreshlist', - 'alt' => __('Push selected pages into autorefresh list'), - 'title' => __('Push selected pages into autorefresh list'), - ] + 'images/darrowright_green.png', + true, + [ + 'id' => 'right_autorefreshlist', + 'alt' => __('Push selected pages into autorefresh list'), + 'title' => __('Push selected pages into autorefresh list'), + ] ).' '.html_print_image( 'images/darrowleft_green.png', diff --git a/pandora_console/operation/visual_console/view.php b/pandora_console/operation/visual_console/view.php index 33a860ef22..8b51d0a8f6 100644 --- a/pandora_console/operation/visual_console/view.php +++ b/pandora_console/operation/visual_console/view.php @@ -398,6 +398,17 @@ if ($pure === false) { echo '
'; if ($aclWrite === true || $aclManage === true) { + if (!is_metaconsole()) { + echo ''.html_print_image( + 'images/target.png', + true, + [ + 'title' => __('Force remote checks'), + 'class' => 'invert_filter', + ] + ).''; + } + echo html_print_checkbox_switch('edit-mode', 1, false, true); } @@ -671,12 +682,14 @@ if ($edit_capable === true) { if ($(this).prop('checked')) { visualConsoleManager.visualConsole.enableEditMode(); visualConsoleManager.changeUpdateInterval(0); + $('#force_check').hide(); $('#edit-controls').css('visibility', ''); } else { visualConsoleManager.visualConsole.disableEditMode(); visualConsoleManager.visualConsole.unSelectItems(); visualConsoleManager.changeUpdateInterval(); // To ms. $('#edit-controls').css('visibility', 'hidden'); + $('#force_check').show(); } }); '; + $.ajax({ + type: "GET", + url: "ajax.php", + dataType: "json", + data: { + page: "include/ajax/visual_console.ajax", + force_remote_check: true, + id_layout: id_layout + }, + success: function (data) { + if (data == 1) { + visualConsoleManager.changeUpdateInterval(5000); + setTimeout(resetInterval, 6000); + } else { + resetInterval(); + } + }, + error: function (data) { + resetInterval(); + } + }); + }); + + function resetInterval() { + visualConsoleManager.changeUpdateInterval(); + } + /** * Process ajax responses and shows a dialog with results. */ diff --git a/pandora_console/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index d56eb17253..97807397a1 100644 --- a/pandora_console/pandora_console.redhat.spec +++ b/pandora_console/pandora_console.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.759 -%define release 220105 +%define release 220113 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.rhel7.spec b/pandora_console/pandora_console.rhel7.spec index 6f0ce7e5c9..3256cbcfd8 100644 --- a/pandora_console/pandora_console.rhel7.spec +++ b/pandora_console/pandora_console.rhel7.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.759 -%define release 220105 +%define release 220113 # User and Group under which Apache is running %define httpd_name httpd diff --git a/pandora_console/pandora_console.spec b/pandora_console/pandora_console.spec index 363f64caed..8a7899ec92 100644 --- a/pandora_console/pandora_console.spec +++ b/pandora_console/pandora_console.spec @@ -3,7 +3,7 @@ # %define name pandorafms_console %define version 7.0NG.759 -%define release 220105 +%define release 220113 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 62cb177d3e..0f766eea65 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -2856,7 +2856,8 @@ CREATE TABLE IF NOT EXISTS `tservice_element` ( `id_service_child` int(10) unsigned NOT NULL default 0, `id_server_meta` int(10) unsigned NOT NULL default 0, `rules` text, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + INDEX `IDX_tservice_element` (`id_service`,`id_agente_modulo`) ) ENGINE=InnoDB COMMENT = 'Table to define the modules and the weights of the modules that define a service' DEFAULT CHARSET=utf8; diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index 475d1951a6..33c12ca9e0 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.759-220105 +Version: 7.0NG.759-220113 Architecture: all Priority: optional Section: admin diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index 59c9eb7e3c..cf3a7e7c27 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/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-220105" +pandora_version="7.0NG.759-220113" package_cpan=0 package_pandora=1 diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new index 7e53d28c39..7dc311915c 100644 --- a/pandora_server/conf/pandora_server.conf.new +++ b/pandora_server/conf/pandora_server.conf.new @@ -348,6 +348,9 @@ fsnmp /usr/bin/pandorafsnmp autocreate_group 10 +# Works like autocreate_group, except the name of the group is specified (instead of its id). Do not set both. +#autocreate_group_name Unknown + # If set to 1, new agents will be added to the group specified by autocreate_group (the group specified by the agent will be used as fallback). # If set to 0, new agents will be added to the group specified by the agent (the group specified by autocreate_group will be used as fallback). diff --git a/pandora_server/conf/pandora_server.conf.windows b/pandora_server/conf/pandora_server.conf.windows index 9d953cfa94..0a2717793c 100644 --- a/pandora_server/conf/pandora_server.conf.windows +++ b/pandora_server/conf/pandora_server.conf.windows @@ -274,6 +274,9 @@ dataserver_threads 2 autocreate_group 10 +# Works like autocreate_group, except the name of the group is specified (instead of its id). Do not set both. +#autocreate_group_name Unknown + # If set to 1, new agents will be added to the group specified by autocreate_group (the group specified by the agent will be used as fallback). # If set to 0, new agents will be added to the group specified by the agent (the group specified by autocreate_group will be used as fallback). diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 1c38f4a355..4c20438422 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -46,7 +46,7 @@ our @EXPORT = qw( # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.759"; -my $pandora_build = "220105"; +my $pandora_build = "220113"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash @@ -398,6 +398,7 @@ sub pandora_load_config { $pa_config->{'autocreate_group'} = -1; $pa_config->{'autocreate_group_force'} = 1; + $pa_config->{'autocreate_group_name'} = ''; $pa_config->{'autocreate'} = 1; # max log size (bytes) @@ -942,6 +943,9 @@ sub pandora_load_config { elsif ($parametro =~ m/^autocreate_group_force\s+([0-1])/i) { $pa_config->{'autocreate_group_force'}= clean_blank($1); } + elsif ($parametro =~ m/^autocreate_group_name\s(.*)/i) { + $pa_config->{'autocreate_group_name'}= clean_blank($1); + } elsif ($parametro =~ m/^discovery_threads\s+([0-9]*)/i) { $pa_config->{'discovery_threads'}= clean_blank($1); } diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 9058d83e96..9d1736266f 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -3846,7 +3846,8 @@ sub pandora_get_agent_group { my ($pa_config, $dbh, $agent_name, $agent_group, $agent_group_password) = @_; my $group_id; - my @groups = $pa_config->{'autocreate_group_force'} == 1 ? ($pa_config->{'autocreate_group'}, $agent_group) : ($agent_group, $pa_config->{'autocreate_group'}); + my $auto_group = $pa_config->{'autocreate_group_name'} ne '' ? $pa_config->{'autocreate_group_name'} : $pa_config->{'autocreate_group'}; + my @groups = $pa_config->{'autocreate_group_force'} == 1 ? ($auto_group, $agent_group) : ($agent_group, $auto_group); foreach my $group (@groups) { next unless defined($group); diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index f3b6fd63aa..2bd398cfda 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -89,11 +89,20 @@ sub new ($$;$) { } } - if ($config->{'autocreate_group'} > 0 && !defined(get_group_name ($dbh, $config->{'autocreate_group'}))) { - my $msg = "Group id " . $config->{'autocreate_group'} . " does not exist (check autocreate_group config token)."; - logger($config, $msg, 3); - print_message($config, $msg, 1); - pandora_event ($config, $msg, 0, 0, 0, 0, 0, 'error', 0, $dbh); + if ($config->{'autocreate_group_name'} ne '') { + if (get_group_id($dbh, $config->{'autocreate_group_name'}) == -1) { + my $msg = "Group '" . $config->{'autocreate_group_name'} . "' does not exist (check autocreate_group_name config token)."; + logger($config, $msg, 3); + print_message($config, $msg, 1); + pandora_event ($config, $msg, 0, 0, 0, 0, 0, 'error', 0, $dbh); + } + } elsif ($config->{'autocreate_group'} > 0) { + if (!defined(get_group_name ($dbh, $config->{'autocreate_group'}))) { + my $msg = "Group id " . $config->{'autocreate_group'} . " does not exist (check autocreate_group config token)."; + logger($config, $msg, 3); + print_message($config, $msg, 1); + pandora_event ($config, $msg, 0, 0, 0, 0, 0, 'error', 0, $dbh); + } } bless $self, $class; diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index ca12f4e204..13121c0a90 100644 --- a/pandora_server/lib/PandoraFMS/PluginTools.pm +++ b/pandora_server/lib/PandoraFMS/PluginTools.pm @@ -34,7 +34,7 @@ our @ISA = qw(Exporter); # version: Defines actual version of Pandora Server for this module only my $pandora_version = "7.0NG.759"; -my $pandora_build = "220105"; +my $pandora_build = "220113"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index 607e4c5f2f..c826a174c9 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.759 -%define release 220105 +%define release 220113 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 36961c491b..bd72417d4c 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -3,7 +3,7 @@ # %define name pandorafms_server %define version 7.0NG.759 -%define release 220105 +%define release 220113 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 86ed18ed21..193a048ff7 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.759" -PI_BUILD="220105" +PI_BUILD="220113" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 737d7acaf3..b073a3623b 100755 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -35,7 +35,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.759 Build 220105"; +my $version = "7.0NG.759 Build 220113"; # Pandora server configuration my %conf; @@ -391,11 +391,11 @@ sub pandora_purgedb ($$) { # Delete old log data log_message ('PURGE', "Deleting old network configuration manager data."); - if (defined($conf->{'days_purge_ncm'}) && $conf->{'days_purge_ncm'} > 0) { - log_message ('PURGE', 'Deleting NCM data older than ' . $conf->{'days_purge_ncm'} . ' days.'); - enterprise_hook ('pandora_purge_ncm', [$dbh, \&log_message, $conf->{'days_purge_ncm'}, $conf->{'_history_db_step'}, $conf->{'_history_db_delay'}]); + if (defined($conf->{'_days_purge'}) && $conf->{'_days_purge'} > 0) { + log_message ('PURGE', 'Deleting NCM data older than ' . $conf->{'_days_purge'} . ' days.'); + enterprise_hook ('pandora_purge_ncm', [$dbh, \&log_message, $conf->{'_days_purge'}, $conf->{'_history_db_step'}, $conf->{'_history_db_delay'}]); } else { - log_message ('PURGE', 'days_purge_ncm is set to 0. Old network configuration manager data will not be deleted.'); + log_message ('PURGE', '_days_purge is set to 0. Old network configuration manager data will not be deleted.'); } # Delete old special days diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 6163c0fef7..3b3a173061 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -36,7 +36,7 @@ use Encode::Locale; Encode::Locale::decode_argv; # version: define current version -my $version = "7.0NG.759 Build 220105"; +my $version = "7.0NG.759 Build 220113"; # save program name for logging my $progname = basename($0);