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][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] .= ''; + +$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 '
'; +$url = 'index.php?sec=gmassive&sec2=godmode/massive/massive_operations&option=delete_agents'; +if (is_metaconsole() === true) { + $url = 'index.php?sec=advanced&sec2=advanced/massive_operations&tab=massive_agents&pure=0&option=delete_agents'; +} + +echo ''; html_print_table($table); -if (is_management_allowed() === true) { + +if (is_metaconsole() === true || is_management_allowed() === true) { attachActionButton('delete', 'delete', $table->width); } @@ -227,25 +340,34 @@ ui_require_jquery_file('pandora.controls'); diff --git a/pandora_console/godmode/massive/massive_edit_agents.php b/pandora_console/godmode/massive/massive_edit_agents.php index b54cf575b2..d750e684b3 100755 --- a/pandora_console/godmode/massive/massive_edit_agents.php +++ b/pandora_console/godmode/massive/massive_edit_agents.php @@ -38,13 +38,13 @@ if (! check_acl($config['id_user'], 0, 'AW')) { return; } -require_once 'include/functions_agents.php'; -require_once 'include/functions_ui.php'; -require_once 'include/functions_alerts.php'; -require_once 'include/functions_modules.php'; -require_once 'include/functions_servers.php'; -require_once 'include/functions_gis.php'; -require_once 'include/functions_users.php'; +require_once $config['homedir'].'/include/functions_agents.php'; +require_once $config['homedir'].'/include/functions_ui.php'; +require_once $config['homedir'].'/include/functions_alerts.php'; +require_once $config['homedir'].'/include/functions_modules.php'; +require_once $config['homedir'].'/include/functions_servers.php'; +require_once $config['homedir'].'/include/functions_gis.php'; +require_once $config['homedir'].'/include/functions_users.php'; enterprise_include_once('include/functions_config_agents.php'); if (is_ajax()) { @@ -171,7 +171,7 @@ if ($update_agents) { } } - // CONF FILE DELETION + // CONF FILE DELETION. if (isset($values['delete_conf'])) { unset($values['delete_conf']); $n_deleted = 0; @@ -345,7 +345,7 @@ if ($update_agents) { } $info = []; - // Update Custom Fields + // Update Custom Fields. foreach ($fields as $field) { $info[$field['id_field']] = $field['name']; $value = get_parameter('customvalue_'.$field['id_field']); @@ -360,7 +360,7 @@ if ($update_agents) { ); if ($old_value === false) { - // Create custom field if not exist + // Create custom field if not exist. $result = db_process_sql_insert( 'tagent_custom_data', [ @@ -418,8 +418,6 @@ if ($update_agents) { $id_group = 0; -$groups = users_get_groups(); - $table = new StdClass(); $table->id = 'delete_table'; $table->class = 'databox filters'; @@ -486,18 +484,22 @@ $table->data[1][3] = html_print_select( __('All'), 2, true, + false, + true, '', - '', - '', - '', + false, 'width:30%;' ); + $table->data[2][0] = __('Agents'); $table->data[2][0] .= ''; -$enabled_agents = agents_get_group_agents(array_keys(users_get_groups($config['id_user'], 'AW', false)), ['disabled' => 0], 'none'); -$all_agents = (agents_get_group_agents(array_keys(users_get_groups($config['id_user'], 'AW', false)), ['disabled' => 1], 'none') + $enabled_agents); +$all_agents = agents_get_group_agents( + array_keys(users_get_groups($config['id_user'], 'AW', false)), + ['disabled' => 2], + 'none' +); $table->data[2][1] = html_print_select( $all_agents, @@ -507,10 +509,27 @@ $table->data[2][1] = html_print_select( '', '', true, + true, + true, + '', + false, + 'min-width: 500px; max-width: 500px; max-height: 100px', + false, + false, + false, + '', + false, + false, + false, + false, + true, + true, true ); -echo ''; +echo ''; +echo html_print_avoid_autocomplete(); + html_print_table($table); $nombre_agente = ''; @@ -540,9 +559,6 @@ $table->size[3] = '35%'; $table->data = []; -$groups = users_get_groups($config['id_user'], 'AW', false); -$agents = agents_get_group_agents(array_keys($groups)); - $modules = db_get_all_rows_sql( 'SELECT id_agente_modulo as id_module, nombre as name FROM tagente_modulo WHERE id_agente = '.$id_parent @@ -627,7 +643,7 @@ $table->data[3][1] .= ' '; $table->data[3][1] .= ui_print_os_icon($id_os, false, true); $table->data[3][1] .= ''; -// Network server +// Network server. $none = ''; if ($server_name == '' && $id_agente) { $none = __('None'); @@ -649,7 +665,7 @@ $table->data[4][1] = html_print_select( 'width: 150px;' ); -// Description +// Description. $table->data[5][0] = __('Description'); $table->data[5][1] = html_print_input_text('description', $description, '', 45, 255, true); @@ -680,27 +696,27 @@ $table->style = []; $table->style[0] = 'font-weight: bold; width: 150px;'; $table->data = []; -// Custom ID +// Custom ID. $table->data[0][0] = __('Custom ID'); $table->data[0][1] = html_print_input_text('custom_id', $custom_id, '', 16, 255, true); -// Learn mode / Normal mode +// Learn mode / Normal mode. $table->data[1][0] = __('Module definition'); $table->data[1][1] = __('No change').' '.html_print_radio_button_extended('mode', -1, '', $mode, false, '', 'class="mrgn_right_40px"', true); $table->data[1][1] .= __('Learning mode').' '.html_print_radio_button_extended('mode', 1, '', $mode, false, '', 'class="mrgn_right_40px"', true); $table->data[1][1] .= __('Normal mode').' '.html_print_radio_button_extended('mode', 0, '', $mode, false, '', 'class="mrgn_right_40px"', true); $table->data[1][1] .= __('Autodisable mode').' '.html_print_radio_button_extended('mode', 2, '', $mode, false, '', 'class="mrgn_right_40px"', true); -// Status (Disabled / Enabled) +// Status (Disabled / Enabled). $table->data[2][0] = __('Status'); $table->data[2][1] = __('No change').' '.html_print_radio_button_extended('disabled', -1, '', $disabled, false, '', 'class="mrgn_right_40px"', true); $table->data[2][1] .= __('Disabled').' '.ui_print_help_tip(__('If the remote configuration is enabled, it will also go into standby mode when disabling it.'), true).' '.html_print_radio_button_extended('disabled', 1, '', $disabled, false, '', 'class="mrgn_right_40px"', true); $table->data[2][1] .= __('Active').' '.html_print_radio_button_extended('disabled', 0, '', $disabled, false, '', 'class="mrgn_right_40px"', true); -// Remote configuration +// Remote configuration. $table->data[3][0] = __('Remote configuration'); -// Delete remote configuration +// Delete remote configuration. $table->data[3][1] = ''; @@ -718,7 +734,7 @@ $path = 'images/gis_map/icons/'; // TODO set better method the path if ($icon_path == '') { $display_icons = 'none'; - // Hack to show no icon. Use any given image to fix not found image errors + // Hack to show no icon. Use any given image to fix not found image errors. $path_without = 'images/spinner.png'; $path_default = 'images/spinner.png'; $path_ok = 'images/spinner.png'; @@ -819,7 +835,8 @@ foreach ($fields as $field) { } if ($field['is_password_type']) { - $data[1] = html_print_input_text_extended( + $data[1] = html_print_input_password_avoid_autocomplete(); + $data[1] .= html_print_input_text_extended( 'customvalue_'.$field['id_field'], $custom_value, 'customvalue_'.$field['id_field'], @@ -882,7 +899,6 @@ var limit_parameters_massive = ").attr("value", 'Any').html('Any')); - } + } }); - + // Fill modules in Safe Operation Mode. function refreshSafeModules(){ var idAgents = Array(); @@ -925,7 +941,7 @@ $(document).ready (function () { "id_agent" : idAgents, "selection_mode": "common" }; - + jQuery.post ("ajax.php", params, function (data, status) { @@ -944,30 +960,26 @@ $(document).ready (function () { ); } - $("#form_agent").submit(function() { var get_parameters_count = window.location.href.slice( window.location.href.indexOf('?') + 1).split('&').length; var post_parameters_count = $("#form_agent").serializeArray().length; - + var count_parameters = get_parameters_count + post_parameters_count; - + if (count_parameters > limit_parameters_massive) { alert(""); return false; } }); - + var disabled; - - $("#disabled").click(function () { - - disabled = this.value; - - $("#id_group").trigger("change"); + $("#disabled").change(function () { + disabled = this.value; + $("#id_group").trigger("change"); }); - + $('#id_agents').on('change', function() { var idAgents = Array(); jQuery.each ($("#id_agents option:selected"), function (i, val) { @@ -998,19 +1010,19 @@ $(document).ready (function () { refreshSafeModules(); } }); - + $("#id_group").change (function () { $("#form_agents").attr("style", "display: none"); }); - + $("select#id_os").pandoraSelectOS (); - + var recursion; $("#checkbox-recursion2").click(function () { recursion = this.checked ? 1 : 0; $("#id_group").trigger("change"); }); - + $("#id_group").pandoraSelectGroupAgent ({ status_agents: function () { return $("#status_agents").val(); @@ -1024,27 +1036,26 @@ $(document).ready (function () { return disabled; } }); - + $("#status_agents").change(function() { $("#id_group").trigger("change"); }); - - + disabled = 2; - $("#id_group").trigger("change"); - + //$("#id_group").trigger("change"); + }); function changeIcons() { var icon = $("#icon_path :selected").val(); - + $("#icon_without_status").attr("src", "images/spinner.png"); $("#icon_default").attr("src", "images/spinner.png"); $("#icon_ok").attr("src", "images/spinner.png"); $("#icon_bad").attr("src", "images/spinner.png"); $("#icon_warning").attr("src", "images/spinner.png"); - + if (icon.length == 0) { $("#icon_without_status").attr("style", "display:none;"); $("#icon_default").attr("style", "display:none;"); diff --git a/pandora_console/godmode/massive/massive_operations.php b/pandora_console/godmode/massive/massive_operations.php index 495dc8f4af..c066816dfd 100755 --- a/pandora_console/godmode/massive/massive_operations.php +++ b/pandora_console/godmode/massive/massive_operations.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 @@ -29,6 +29,8 @@ // Begin. check_login(); +global $config; + if (! check_acl($config['id_user'], 0, 'AW')) { db_pandora_audit( AUDIT_LOG_ACL_VIOLATION, @@ -38,16 +40,20 @@ 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_massive_operations.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_massive_operations.php'; enterprise_include('godmode/massive/massive_operations.php'); $tab = (string) get_parameter('tab', 'massive_agents'); $option = (string) get_parameter('option'); +$url = 'index.php?sec=gmassive&sec2=godmode/massive/massive_operations'; +if (is_metaconsole() === true) { + $url = 'index.php?sec=advanced&sec2=advanced/massive_operations&tab=massive_agents&pure=0'; +} $options_alerts = [ 'add_alerts' => __('Bulk alert add'), @@ -62,6 +68,11 @@ $options_agents = [ 'edit_agents' => __('Bulk agent edit'), 'delete_agents' => __('Bulk agent delete'), ]; +if (is_metaconsole() === true) { + $options_agents = [ + 'delete_agents' => __('Bulk agent delete'), + ]; +} if (check_acl($config['id_user'], 0, 'UM')) { $options_users = [ @@ -114,28 +125,31 @@ if ($options_services === ENTERPRISE_NOT_HOOK) { } -if (in_array($option, array_keys($options_alerts))) { +if (in_array($option, array_keys($options_alerts)) === true) { $tab = 'massive_alerts'; -} else if (in_array($option, array_keys($options_agents))) { +} else if (in_array($option, array_keys($options_agents)) === true) { $tab = 'massive_agents'; -} else if (in_array($option, array_keys($options_users))) { +} else if (in_array($option, array_keys($options_users)) === true) { $tab = 'massive_users'; -} else if (in_array($option, array_keys($options_modules))) { +} else if (in_array($option, array_keys($options_modules)) === true) { $tab = 'massive_modules'; -} else if (in_array($option, array_keys($options_policies))) { +} else if (in_array($option, array_keys($options_policies)) === true) { $tab = 'massive_policies'; -} else if (in_array($option, array_keys($options_snmp))) { +} else if (in_array($option, array_keys($options_snmp)) === true) { $tab = 'massive_snmp'; -} else if (in_array($option, array_keys($options_satellite))) { +} else if (in_array($option, array_keys($options_satellite)) === true) { $tab = 'massive_satellite'; -} else if (in_array($option, array_keys($options_plugins))) { +} else if (in_array($option, array_keys($options_plugins)) === true) { $tab = 'massive_plugins'; -} else if (in_array($option, array_keys($options_services))) { +} else if (in_array($option, array_keys($options_services)) === true) { $tab = 'massive_services'; } -if ($tab == 'massive_agents' && $option == '') { +if ($tab === 'massive_agents' && empty($option) === true) { $option = 'edit_agents'; + if (is_metaconsole() === true) { + $option = 'delete_agents'; + } } if ($tab == 'massive_modules' && $option == '') { @@ -212,7 +226,7 @@ if ($option == '') { } $alertstab = [ - 'text' => ''.html_print_image( + 'text' => ''.html_print_image( 'images/bell.png', true, [ @@ -224,7 +238,7 @@ $alertstab = [ ]; $userstab = [ - 'text' => ''.html_print_image( + 'text' => ''.html_print_image( 'images/user.png', true, [ @@ -236,7 +250,7 @@ $userstab = [ ]; $agentstab = [ - 'text' => ''.html_print_image( + 'text' => ''.html_print_image( 'images/agent.png', true, [ @@ -247,138 +261,116 @@ $agentstab = [ 'active' => $tab == 'massive_agents', ]; - $modulestab = [ - 'text' => ''.html_print_image( - 'images/module.png', - true, - [ - 'title' => __('Modules operations'), - 'class' => 'invert_filter', - ] - ).'', - 'active' => $tab == 'massive_modules', - ]; +$modulestab = [ + 'text' => ''.html_print_image( + 'images/module.png', + true, + [ + 'title' => __('Modules operations'), + 'class' => 'invert_filter', + ] + ).'', + 'active' => $tab == 'massive_modules', +]; - $pluginstab = [ - 'text' => ''.html_print_image( - 'images/plugin.png', - true, - [ - 'title' => __('Plugins operations'), - 'class' => 'invert_filter', - ] - ).'', - 'active' => $tab == 'massive_plugins', - ]; +$pluginstab = [ + 'text' => ''.html_print_image( + 'images/plugin.png', + true, + [ + 'title' => __('Plugins operations'), + 'class' => 'invert_filter', + ] + ).'', + 'active' => $tab == 'massive_plugins', +]; - $policiestab = enterprise_hook('massive_policies_tab'); +$policiestab = enterprise_hook('massive_policies_tab'); - if ($policiestab == ENTERPRISE_NOT_HOOK) { - $policiestab = ''; - } +if ($policiestab == ENTERPRISE_NOT_HOOK) { + $policiestab = ''; +} - $snmptab = enterprise_hook('massive_snmp_tab'); +$snmptab = enterprise_hook('massive_snmp_tab'); - if ($snmptab == ENTERPRISE_NOT_HOOK) { - $snmptab = ''; - } +if ($snmptab == ENTERPRISE_NOT_HOOK) { + $snmptab = ''; +} - $satellitetab = enterprise_hook('massive_satellite_tab'); +$satellitetab = enterprise_hook('massive_satellite_tab'); - if ($satellitetab == ENTERPRISE_NOT_HOOK) { - $satellitetab = ''; - } +if ($satellitetab == ENTERPRISE_NOT_HOOK) { + $satellitetab = ''; +} - $servicestab = enterprise_hook('massive_services_tab'); +$servicestab = enterprise_hook('massive_services_tab'); - if ($servicestab == ENTERPRISE_NOT_HOOK) { - $servicestab = ''; - } +if ($servicestab == ENTERPRISE_NOT_HOOK) { + $servicestab = ''; +} - $onheader = []; - $onheader['massive_agents'] = $agentstab; - $onheader['massive_modules'] = $modulestab; - $onheader['massive_plugins'] = $pluginstab; - if (check_acl($config['id_user'], 0, 'UM')) { - $onheader['user_agents'] = $userstab; - } +$onheader = []; +$onheader['massive_agents'] = $agentstab; +$onheader['massive_modules'] = $modulestab; +$onheader['massive_plugins'] = $pluginstab; +if (check_acl($config['id_user'], 0, 'UM')) { + $onheader['user_agents'] = $userstab; +} - $onheader['massive_alerts'] = $alertstab; - $onheader['policies'] = $policiestab; - $onheader['snmp'] = $snmptab; - $onheader['satellite'] = $satellitetab; - $onheader['services'] = $servicestab; +$onheader['massive_alerts'] = $alertstab; +$onheader['policies'] = $policiestab; +$onheader['snmp'] = $snmptab; +$onheader['satellite'] = $satellitetab; +$onheader['services'] = $servicestab; - /* - Hello there! :) +// Header. +if (is_metaconsole() === false) { + ui_print_page_header( + __('Bulk operations').' » '.$options[$option], + 'images/gm_massive_operations.png', + false, + $help_header, + true, + $onheader, + false, + 'massivemodal' + ); +} else { + massive_meta_print_header(); +} - We added some of what seems to be "buggy" messages to the openSource version recently. This is not to force open-source users to move to the enterprise version, this is just to inform people using Pandora FMS open source that it requires skilled people to maintain and keep it running smoothly without professional support. This does not imply open-source version is limited in any way. If you check the recently added code, it contains only warnings and messages, no limitations except one: we removed the option to add custom logo in header. In the Update Manager section, it warns about the 'danger’ of applying automated updates without a proper backup, remembering in the process that the Enterprise version comes with a human-tested package. Maintaining an OpenSource version with more than 500 agents is not so easy, that's why someone using a Pandora with 8000 agents should consider asking for support. It's not a joke, we know of many setups with a huge number of agents, and we hate to hear that “its becoming unstable and slow” :( +// Checks if the PHP configuration is correctly. +if ((get_cfg_var('max_execution_time') != 0) + || (get_cfg_var('max_input_time') != -1) +) { + echo '
'; + echo __('In order to perform massive operations, PHP needs a correct configuration in timeout parameters. Please, open your PHP configuration file (php.ini) for example: sudo vi /etc/php5/apache2/php.ini;
And set your timeout parameters to a correct value:
max_execution_time = 0 and max_input_time = -1'); + echo '
'; +} - You can of course remove the warnings, that's why we include the source and do not use any kind of trick. And that's why we added here this comment, to let you know this does not reflect any change in our opensource mentality of does the last 14 years. +// Catch all submit operations in this view to display Wait banner. +$submit_action = get_parameter('go'); +$submit_update = get_parameter('updbutton'); +$submit_del = get_parameter('del'); +$submit_template_disabled = get_parameter('id_alert_template_disabled'); +$submit_template_enabled = get_parameter('id_alert_template_enabled'); +$submit_template_not_standby = get_parameter('id_alert_template_not_standby'); +$submit_template_standby = get_parameter('id_alert_template_standby'); +$submit_add = get_parameter('crtbutton'); +// Waiting spinner. +ui_print_spinner(__('Loading')); +// Modal for show messages. +html_print_div( + [ + 'id' => 'massive_modal', + 'content' => '', + ] +); - */ +// Load common JS files. +ui_require_javascript_file('massive_operations'); - ui_print_page_header( - __('Bulk operations').' » '.$options[$option], - 'images/gm_massive_operations.png', - false, - $help_header, - true, - $onheader, - false, - 'massivemodal' - ); - - // Checks if the PHP configuration is correctly. - if ((get_cfg_var('max_execution_time') != 0) - || (get_cfg_var('max_input_time') != -1) - ) { - echo '
'; - echo __('In order to perform massive operations, PHP needs a correct configuration in timeout parameters. Please, open your PHP configuration file (php.ini) for example: sudo vi /etc/php5/apache2/php.ini;
And set your timeout parameters to a correct value:
max_execution_time = 0 and max_input_time = -1'); - echo '
'; - } - - if ($tab == 'massive_policies' && is_management_allowed() === false) { - if (is_metaconsole() === false) { - $url = ''.__('metaconsole').''; - } else { - $url = __('any node'); - } - - ui_print_warning_message( - __( - 'This node is configured with centralized mode. All policies information is read only. Go to %s to manage it.', - $url - ) - ); - return; - } - - // Catch all submit operations in this view to display Wait banner. - $submit_action = get_parameter('go'); - $submit_update = get_parameter('updbutton'); - $submit_del = get_parameter('del'); - $submit_template_disabled = get_parameter('id_alert_template_disabled'); - $submit_template_enabled = get_parameter('id_alert_template_enabled'); - $submit_template_not_standby = get_parameter('id_alert_template_not_standby'); - $submit_template_standby = get_parameter('id_alert_template_standby'); - $submit_add = get_parameter('crtbutton'); - // Waiting spinner. - ui_print_spinner(__('Loading')); - // Modal for show messages. - html_print_div( - [ - 'id' => 'massive_modal', - 'content' => '', - ] - ); - - // Load common JS files. - ui_require_javascript_file('massive_operations'); - - ?> +?> '.__('metaconsole').''; } else { - $url = __('any node'); + $text_warning = __('any node'); } ui_print_warning_message( __( 'This node is configured with centralized mode. To delete agents go to %s', - $url + $text_warning ) ); } echo '
'; -echo ''; +echo ''; echo '
'; echo __('Action'); echo ''; @@ -444,7 +436,7 @@ html_print_select( false, false ); -if ($option == 'edit_agents' || $option == 'edit_modules') { +if ($option === 'edit_agents' || $option === 'edit_modules') { ui_print_help_tip(__('The blank fields will not be updated')); } @@ -454,64 +446,64 @@ echo '
'; switch ($option) { case 'delete_alerts': - include_once 'godmode/massive/massive_delete_alerts.php'; + include_once $config['homedir'].'/godmode/massive/massive_delete_alerts.php'; break; case 'add_alerts': - include_once 'godmode/massive/massive_add_alerts.php'; + include_once $config['homedir'].'/godmode/massive/massive_add_alerts.php'; break; case 'delete_action_alerts': - include_once 'godmode/massive/massive_delete_action_alerts.php'; + include_once $config['homedir'].'/godmode/massive/massive_delete_action_alerts.php'; break; case 'add_action_alerts': - include_once 'godmode/massive/massive_add_action_alerts.php'; + include_once $config['homedir'].'/godmode/massive/massive_add_action_alerts.php'; break; case 'enable_disable_alerts': - include_once 'godmode/massive/massive_enable_disable_alerts.php'; + include_once $config['homedir'].'/godmode/massive/massive_enable_disable_alerts.php'; break; case 'standby_alerts': - include_once 'godmode/massive/massive_standby_alerts.php'; + include_once $config['homedir'].'/godmode/massive/massive_standby_alerts.php'; break; case 'add_profiles': - include_once 'godmode/massive/massive_add_profiles.php'; + include_once $config['homedir'].'/godmode/massive/massive_add_profiles.php'; break; case 'delete_profiles': - include_once 'godmode/massive/massive_delete_profiles.php'; + include_once $config['homedir'].'/godmode/massive/massive_delete_profiles.php'; break; case 'delete_agents': - include_once 'godmode/massive/massive_delete_agents.php'; + include_once $config['homedir'].'/godmode/massive/massive_delete_agents.php'; break; case 'edit_agents': - include_once 'godmode/massive/massive_edit_agents.php'; + include_once $config['homedir'].'/godmode/massive/massive_edit_agents.php'; break; case 'delete_modules': - include_once 'godmode/massive/massive_delete_modules.php'; + include_once $config['homedir'].'/godmode/massive/massive_delete_modules.php'; break; case 'edit_modules': - include_once 'godmode/massive/massive_edit_modules.php'; + include_once $config['homedir'].'/godmode/massive/massive_edit_modules.php'; break; case 'copy_modules': - include_once 'godmode/massive/massive_copy_modules.php'; + include_once $config['homedir'].'/godmode/massive/massive_copy_modules.php'; break; case 'edit_plugins': - include_once 'godmode/massive/massive_edit_plugins.php'; + include_once $config['homedir'].'/godmode/massive/massive_edit_plugins.php'; break; default: if (!enterprise_hook('massive_operations', [$option])) { - include_once 'godmode/massive/massive_config.php'; + include_once $config['homedir'].'/godmode/massive/massive_config.php'; } break; } diff --git a/pandora_console/godmode/reporting/graph_builder.graph_editor.php b/pandora_console/godmode/reporting/graph_builder.graph_editor.php index d322159663..baeb179da5 100644 --- a/pandora_console/godmode/reporting/graph_builder.graph_editor.php +++ b/pandora_console/godmode/reporting/graph_builder.graph_editor.php @@ -327,59 +327,17 @@ echo '
'; // Configuration form. echo ''; -echo ""; +echo ""; echo ""; echo ''; -echo "'; -echo ''; -echo "'; -echo ''; -echo "'; -echo ''; -echo "'; -echo ''; -echo ''; -echo ''; -echo ''; echo ''; echo "
".__('Filter group').'
".html_print_select_groups( - $config['id_user'], - ($report_w == true) ? 'RW' : (($report_m == true) ? 'RM' : 'RW'), - true, - 'group', - '', - 'filterByGroup($(\'#group\').val());', - '', - 0, - true -).'
".__('Agents').ui_print_help_tip( - __('If you select several agents, only the common modules will be displayed'), - true -).'".__('Modules').'
'.html_print_select( - agents_get_group_agents(), - 'id_agents[]', - 0, - false, - '', - '', - true, - true, - true, - 'w100p', - false, - '' -).''.html_print_select( - [], - 'module[]', - 0, - false, - '', - 0, - true, - true, - true, - 'w100p', - false, - '' +echo ''.html_print_input( + [ + 'type' => 'select_multiple_modules_filtered', + 'uniqId' => 'modules', + 'class' => 'flex flex-row', + 'searchBar' => true, + ] ).'
"; @@ -403,52 +361,34 @@ ui_require_jquery_file('autocomplete'); $(document).ready (function () { $(document).data('text_for_module', $("#none_text").html()); - $("#id_agents").change(agent_changed_by_multiple_agents); - $("#submit-add").click(function() { - $('#module').map(function(){ - if ($(this).val() != "0" ) - $(this).prop('selected', true); - }); - - if($('#module')[0].childElementCount == 1 && ($('#module')[0].value == "" || $('#module')[0].value == "0")) { + if($('#filtered-module-modules-modules')[0].value == "" || $('#filtered-module-modules-modules')[0].value == "0") { alert(""); return false; } + + var modules_selected = $( + "#filtered-module-modules-modules" + ).val(); + var agents_selected = $( + "#filtered-module-agents-modules" + ).val(); + + $("#agentmodules").submit( function(eventObj) { + $("").attr("type", "hidden") + .attr("value", agents_selected) + .attr("name", "id_agents") + .appendTo("#agentmodules"); + $("").attr("type", "hidden") + .attr("value", modules_selected) + .attr("name", "id_modules") + .appendTo("#agentmodules"); + return true; + }); }); }); -function filterByGroup(idGroup) { - $('#id_agents').empty (); - $('#module').empty(); - $("#module").append ($("").attr ("value", 0).html ('')); - - jQuery.post ("ajax.php", - {"page" : "godmode/groups/group_list", - "get_group_agents" : 1, - "id_group" : idGroup, - // Add a key prefix to avoid auto sorting in js object conversion - "keys_prefix" : "_" - }, - function (data, status) { - i = 0 - jQuery.each (data, function (id, value) { - // Remove keys_prefix from the index - id = id.substring(1); - - i++; - $("#id_agents").append ($("").attr ("value", id).html (value)); - }); - - if (i == 0) { - $("#id_agents").append ($("").attr ("value", 0).html ('')); - } - }, - "json" - ); -} - function added_ids_sorted_items_to_hidden_input() { var ids = ''; var first = true; diff --git a/pandora_console/godmode/reporting/graph_builder.php b/pandora_console/godmode/reporting/graph_builder.php index 9142265683..391181edf9 100644 --- a/pandora_console/godmode/reporting/graph_builder.php +++ b/pandora_console/godmode/reporting/graph_builder.php @@ -221,17 +221,14 @@ function add_quotes($item) if ($add_module === true) { $id_graph = get_parameter('id'); - $id_modules = get_parameter('module'); - $id_agents = get_parameter('id_agents'); + $id_modules = explode(',', get_parameter('id_modules')); + $id_agents = explode(',', get_parameter('id_agents')); $weight = get_parameter('weight'); // Id modules has double entities conversion. // Safe output remove all entities. io_safe_output_array($id_modules, ''); - // We need to put the entities again - // to browse in db. - io_safe_input_array($id_modules); $id_agent_modules = db_get_all_rows_sql( 'SELECT id_agente_modulo FROM tagente_modulo WHERE id_agente IN ('.implode(',', $id_agents).") AND nombre IN ('".implode("','", $id_modules)."')" diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 424c701429..9c3ebfd4c0 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 = 'PC220131'; +$build_version = 'PC220201'; $pandora_version = 'v7.0NG.759'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index de5195d773..91bdfd2fe1 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -1224,6 +1224,15 @@ function agents_get_group_agents( } } + if ((isset($search['disabled']) === true + && $search['disabled'] === 2) + || (isset($filter['disabled']) === true + && $filter['disabled'] === 2) + ) { + unset($search['disabled']); + unset($filter['disabled']); + } + if (isset($search['all_agents'])) { unset($search['all_agents']); } @@ -1316,17 +1325,20 @@ function agents_get_group_agents( } } - if (is_metaconsole() && isset($search['id_server'])) { - $filter['id_tmetaconsole_setup'] = $search['id_server']; + if (is_metaconsole() === true + && isset($search['id_server']) === true + && empty($search['id_server']) === false + ) { + $filter['ta.id_tmetaconsole_setup'] = $search['id_server']; if ($filter['id_tmetaconsole_setup'] == 0) { // All nodes. unset($filter['id_tmetaconsole_setup']); } - - unset($search['id_server']); } + unset($search['id_server']); + if (!$add_alert_bulk_op) { // Add the rest of the filter from the search array. foreach ($search as $key => $value) { @@ -1339,7 +1351,7 @@ function agents_get_group_agents( $filter['order'] = 'alias'; - if (is_metaconsole()) { + if (is_metaconsole() === true) { $table_name = 'tmetaconsole_agent ta LEFT JOIN tmetaconsole_agent_secondary_group tasg ON ta.id_agente = tasg.id_agent'; if ($meta_fields === true) { diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index fea84beec4..8f5483b6a2 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -17601,6 +17601,35 @@ function api_get_event_mcid($server_id, $console_event_id, $trash2, $returnType) } +/** + * Return whether or not a node is in centralized mode. + * + * @param [string] $server_id server id (node) + * @param [string] $thrash1 don't use + * @param [string] $thrash2 don't use + * @param [string] $returnType + * + * Example + * api.php?op=get&op2=is_centralized&id=3&apipass=1234&user=admin&pass=pandora + * + * @return void + */ +function api_get_is_centralized($server_id, $thrash1, $thrash2, $returnType) +{ + if (is_metaconsole() === true) { + $unified = db_get_value_filter('unified', 'tmetaconsole_setup', ['id' => $server_id]); + + if ($unified !== false) { + returnData($returnType, ['type' => 'string', 'data' => $unified]); + } else { + returnData($returnType, ['type' => 'string', 'data' => 'Node with ID '.$server_id.' does not exist']); + } + } else { + returnData($returnType, ['type' => 'string', 'data' => (int) is_centralized()]); + } +} + + /** * Function to set events in progress status. * diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index 885b239d2c..da12915fc8 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -1480,11 +1480,43 @@ function html_print_select_multiple_modules_filtered(array $data):string 'return' => true, 'nothing' => __('All'), 'nothing_value' => 0, - 'script' => 'fmModuleChange(\''.$uniqId.'\', '.is_metaconsole().')', + 'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')', ] ); $output .= ''; + if (empty($data['searchBar']) === false && $data['searchBar'] === true) { + $output .= '
'; + + $output .= '
'; + $output .= html_print_input( + [ + 'type' => 'text', + 'name' => 'agent-searchBar-'.$uniqId, + 'onKeyUp' => 'searchAgent(\''.$uniqId.'\')', + 'placeholder' => __('Type to search agents'), + 'return' => true, + ] + ); + + $output .= '
'; + + $output .= '
'; + $output .= html_print_input( + [ + 'type' => 'text', + 'name' => 'module-searchBar-'.$uniqId, + 'onKeyUp' => 'searchModule(\''.$uniqId.'\')', + 'return' => true, + 'placeholder' => __('Type to search modules'), + ] + ); + + $output .= '
'; + + $output .= '
'; + } + $output .= '
'; // Agent. $agents = agents_get_group_agents( @@ -1533,7 +1565,7 @@ function html_print_select_multiple_modules_filtered(array $data):string 'return' => true, 'multiple' => true, 'style' => 'min-width: 200px;max-width:200px;', - 'script' => 'fmModuleChange(\''.$uniqId.'\', '.is_metaconsole().')', + 'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')', ] ); @@ -1550,7 +1582,7 @@ function html_print_select_multiple_modules_filtered(array $data):string 'name' => 'filtered-module-show-common-modules-'.$uniqId, 'selected' => $data['mShowCommonModules'], 'return' => true, - 'script' => 'fmModuleChange(\''.$uniqId.'\', '.is_metaconsole().')', + 'script' => 'fmModuleChange(\''.$uniqId.'\', '.(int) is_metaconsole().')', ] ); @@ -4218,6 +4250,33 @@ function html_html2rgb($htmlcolor) } +/** + * Avoid autocomplete. + * + * @return void + */ +function html_print_avoid_autocomplete() +{ + $output = ''; + $output .= ''; + $output .= ''; + + return $output; +} + + +/** + * Input password avoid autocomplete. + * + * @return void + */ +function html_print_input_password_avoid_autocomplete() +{ + $output = ''; + return $output; +} + + /** * Print a magic-ajax control to select the module. * diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index bcea7fbcb1..80b1b81572 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -6868,7 +6868,7 @@ function reporting_advanced_sla( $min_value_warning = $agentmodule_info['min_warning']; $max_value_warning = $agentmodule_info['max_warning']; } else { - $max_values = io_safe_output($agentmodule_info['str_critical']); + $max_value = io_safe_output($agentmodule_info['str_critical']); $max_value_warning = io_safe_output($agentmodule_info['str_warning']); } @@ -7412,23 +7412,25 @@ function reporting_advanced_sla( } // Take notice of $inverse_interval value. - if ($inverse_interval == 0) { - $sla_check_value = $match; + if ($inverse_interval === 1) { + // Is not inverse. + $sla_check_value = ($match === 1) ? false : true; } else { - $sla_check_value = !$match; + // Is inverse. + $sla_check_value = ($match === 1) ? true : false; } // Warning SLA check. if (empty($max_value_warning)) { - $match = preg_match('/^'.$max_value_warning.'$/', $current_data['datos']); + $match2 = preg_match('/^'.$max_value_warning.'$/', $current_data['datos']); } else { - $match = preg_match('/'.$max_value_warning.'/', $current_data['datos']); + $match2 = preg_match('/'.$max_value_warning.'/', $current_data['datos']); } if ($inverse_interval_warning == 0) { - $sla_check_value_warning = $match; + $sla_check_value_warning = $match2; } else { - $sla_check_value_warning = !$match; + $sla_check_value_warning = !$match2; } } else { // OK SLA check. diff --git a/pandora_console/include/javascript/jquery.pandora.controls.js b/pandora_console/include/javascript/jquery.pandora.controls.js index 0158879c6b..cb0312991b 100644 --- a/pandora_console/include/javascript/jquery.pandora.controls.js +++ b/pandora_console/include/javascript/jquery.pandora.controls.js @@ -1,371 +1,355 @@ +/* globals jQuery, js_html_entity_decode */ (function($) { - var dummyFunc = function () { - return true; - }; - - var _pandoraSelectGroupAgent = function (disabled) { - var that = this; - - this.defaults = { - agentSelect: "select#id_agent", - status_agents: -1, - recursion: 0, - filter_agents_json: "", - loading: "#agent_loading", - callbackBefore: dummyFunc, - callbackPre: dummyFunc, - callbackPost: dummyFunc, - callbackAfter: dummyFunc, - debug: false, - disabled: disabled || false, - privilege: "", - }; - - /* public methods */ - this.construct = function (settings) { - return this.each (function() { - this.config = {}; - - this.config = $.extend (this.config, that.defaults, settings); - var config = this.config; - - $(this).change (function () { - var $select = $(config.agentSelect).disable (); - $(config.loading).show (); - $("option[value!=0]", $select).remove (); - if (! config.callbackBefore (this)) - return; + var dummyFunc = function() { + return true; + }; - if (typeof config.recursion === "function") { - // Perform this for those cases where recursion parameter is obtained through a function that returns a variable that is set in the lexical environment where this constructor is called. - var recursion_value = config.recursion(); + var _pandoraSelectGroupAgent = function(disabled) { + var that = this; - if (typeof recursion_value === "boolean") { - recursion_value = recursion_value ? 1 : 0; - } - } else { - var recursion_value = config.recursion; - } + this.defaults = { + agentSelect: "select#id_agent", + status_agents: -1, + recursion: 0, + filter_agents_json: "", + loading: "#agent_loading", + callbackBefore: dummyFunc, + callbackPre: dummyFunc, + callbackPost: dummyFunc, + callbackAfter: dummyFunc, + debug: false, + disabled: disabled || false, + privilege: "", + serialized: false, + serialized_separator: "", + nodes: [] + }; - var opts = { - "page" : "godmode/groups/group_list", - "get_group_agents" : 1, - "id_group" : this.value, - "recursion" : recursion_value, - "filter_agents_json" : config.filter_agents_json, - "disabled" : (typeof config.disabled === "function") - ? (config.disabled()) - : (config.disabled), - "status_agents" : config.status_agents, - "add_alert_bulk_op" : config.add_alert_bulk_op, - "privilege" : config.privilege, - // Add a key prefix to avoid auto sorting in js object conversion - "keys_prefix" : "_" - }; - if(opts['disabled'] == 1 || opts['disabled'] == 0){ - jQuery.post ("ajax.php", - opts, - function (data, status) { - jQuery.each (data, function (id, value) { - // Remove keys_prefix from the index - id = id.substring(1); - if (id !== 'keycount') { - config.callbackPre (); - option = $("") - .attr ("value", id) - .html (value); - config.callbackPost (id, value, option); - $(config.agentSelect).append (option); - } - }); - $(config.loading).hide (); - $select.enable (); - config.callbackAfter (); - }, - "json" - ); - } - else{ - opts['disabled'] = 0; - jQuery.post ("ajax.php", - opts, - function (data, status) { - jQuery.each (data, function (id, value) { - // Remove keys_prefix from the index - id = id.substring(1); - if (id !== 'keycount') { - config.callbackPre (); - option = $("") - .attr ("value", id) - .html (value); - config.callbackPost (id, value, option); - $(config.agentSelect).append (option); - } - }); - $(config.loading).hide (); - $select.enable (); - config.callbackAfter (); - }, - "json" - ); - opts['disabled'] = 1; - jQuery.post ("ajax.php", - opts, - function (data, status) { - jQuery.each (data, function (id, value) { - // Remove keys_prefix from the index - id = id.substring(1); - if (id !== 'keycount') { - config.callbackPre (); - option = $("") - .attr ("value", id) - .html (value); - config.callbackPost (id, value, option); - $(config.agentSelect).append (option); - } - }); - $(config.loading).hide (); - $select.enable (); - config.callbackAfter (); - }, - "json" - ); - - } - - - - }); - }); - }; - }; - - $.extend ({ - pandoraSelectGroupAgent: new _pandoraSelectGroupAgent(), - pandoraSelectGroupAgentDisabled: new _pandoraSelectGroupAgent(true), - }); - - $.extend ({ - pandoraSelectAgentModule: new function() { - this.defaults = { - moduleSelect: "select#id_agent_module", - loading: "#module_loading", - callbackBefore: dummyFunc, - callbackPre: dummyFunc, - callbackPost: dummyFunc, - callbackAfter: dummyFunc, - moduleFilter: { - disabled: 0, - deletePending: 0 - }, - debug: false - }; - - /* public methods */ - this.construct = function (settings) { - return this.each (function() { - this.config = {}; - - this.config = $.extend (this.config, $.pandoraSelectAgentModule.defaults, settings); - - var config = this.config; - $(this).change (function () { - var $select = $(config.moduleSelect).disable (); - $(config.loading).show (); - $("option[value!=0]", $select).remove (); - if (! config.callbackBefore (this)) - return; - - jQuery.post ('ajax.php', - { - "page": "operation/agentes/ver_agente", - "get_agent_modules_json": 1, - "id_agent": this.value, - "disabled": config.moduleFilter.disabled, - "delete_pending": config.moduleFilter.deletePending - }, - function (data) { - jQuery.each (data, function (i, value) { - config.callbackPre (); - // Get the selected item from hidden field - selected = $('#hidden-'+config.moduleSelect.attr('id')+'_selected').val(); - if (selected == i) { - option = $("") - .prop ("selected", true) - .attr ("value", value['id_agente_modulo']) - .html (js_html_entity_decode (value['nombre'])); - } - else { - option = $("") - .attr ("value", value['id_agente_modulo']) - .html (js_html_entity_decode (value['nombre'])); - } - config.callbackPost (i, value, option); - $(config.moduleSelect).append (option); - }); - $(config.loading).hide (); - $select.enable (); - config.callbackAfter (); - }, - "json" - ); - }); - }); - - }; - } - }); - - $.extend ({ - pandoraSelectAgentAlert: new function() { - this.defaults = { - alertSelect: "select#id_agent_module", - loading: "#alert_loading", - callbackBefore: dummyFunc, - callbackPre: dummyFunc, - callbackPost: dummyFunc, - callbackAfter: dummyFunc, - debug: false - }; - - /* public methods */ - this.construct = function (settings) { - return this.each (function() { - this.config = {}; - - this.config = $.extend (this.config, $.pandoraSelectAgentAlert.defaults, settings); - - var config = this.config; - - $(this).change (function () { - var $select = $(config.alertSelect).disable (); - $(config.loading).show (); - $("option[value!=0]", $select).remove (); - if (! config.callbackBefore (this)) - return; - - jQuery.post ('ajax.php', - {"page": "include/ajax/alert_list.ajax", - "get_agent_alerts_simple": 1, - "id_agent": this.value - }, - function (data) { - jQuery.each (data, function (i, value) { - config.callbackPre (); - option = $("") - .attr ("value", value['id']) - .html (js_html_entity_decode (value['template']['name'])) - .append (" ("+js_html_entity_decode (value['module_name'])+")"); - config.callbackPost (i, value, option); - $(config.alertSelect).append (option); - }); - $(config.loading).hide (); - $select.enable (); - config.callbackAfter (); - }, - "json" - ); - }); - }); - }; - } - }); - - $.extend ({ - pandoraSelectOS: new function() { - this.defaults = { - alertSelect: "select#id_os", - spanPreview: "#os_preview", - debug: false - }; - - /* public methods */ - this.construct = function (settings) { - return this.each (function() { - this.config = {}; - this.config = $.extend (this.config, $.pandoraSelectOS.defaults, settings); - - var config = this.config; - - $(this).change (function () { - var id_os = this.value; - - var home_url; - if (typeof(settings) == 'undefined') - home_url = './'; - else - home_url = settings.home_url; - - $(config.spanPreview).fadeOut ('fast', function () { - $("img", config.spanPreview).remove (); - jQuery.post (home_url + 'ajax.php', - {"page": "godmode/setup/setup", - "get_os_icon": 1, - "id_os": id_os - }, - function (data) { - $(config.spanPreview) - .append (data) - .fadeIn ('fast'); - }, - "html" - ); - }); - - }); - }); - }; - } - }); - - $.extend ({ - pandoraSelectGroupIcon: new function() { - this.defaults = { - alertSelect: "select#id_group", - spanPreview: "#group_preview", - debug: false - }; - - /* public methods */ - this.construct = function (settings) { - return this.each (function() { - this.config = {}; - this.config = $.extend (this.config, $.pandoraSelectGroupIcon.defaults, settings); - - var config = this.config; - - $(this).change (function () { - var id_group = this.value; - - $(config.spanPreview).fadeOut ('fast', function () { - $("img", config.spanPreview).remove (); - jQuery.post ('ajax.php', - {"page": "godmode/groups/group_list", - "get_group_json": 1, - "id_group": id_group - }, - function (data) { - img = $("").attr ("src", "images/groups_small/"+data["icon"]+".png"); - $(config.spanPreview) - .append (img) - .fadeIn ('fast'); - }, - "json" - ); - }); - - }); - }); - }; - } - }); - - $.fn.extend({ - pandoraSelectGroupAgent: $.pandoraSelectGroupAgent.construct, - pandoraSelectGroupAgentDisabled: $.pandoraSelectGroupAgentDisabled.construct, - pandoraSelectAgentModule: $.pandoraSelectAgentModule.construct, - pandoraSelectAgentAlert: $.pandoraSelectAgentAlert.construct, - pandoraSelectOS: $.pandoraSelectOS.construct, - pandoraSelectGroupIcon: $.pandoraSelectGroupIcon.construct - }); -}) (jQuery); + /* public methods */ + this.construct = function(settings) { + return this.each(function() { + this.config = {}; + + this.config = $.extend(this.config, that.defaults, settings); + var config = this.config; + + $(this).change(function() { + var $select = $(config.agentSelect).disable(); + $(config.loading).show(); + $("option[value!=0]", $select).remove(); + if (!config.callbackBefore(this)) return; + + var recursion_value; + if (typeof config.recursion === "function") { + // Perform this for those cases where recursion parameter + // is obtained through a function that returns a variable + // that is set in the lexical environment + // where this constructor is called. + recursion_value = config.recursion(); + + if (typeof recursion_value === "boolean") { + recursion_value = recursion_value ? 1 : 0; + } + } else { + recursion_value = config.recursion; + } + + var opts = { + page: "godmode/groups/group_list", + get_group_agents: 1, + id_group: this.value, + recursion: recursion_value, + filter_agents_json: config.filter_agents_json, + disabled: + typeof config.disabled === "function" + ? config.disabled() + : config.disabled, + status_agents: config.status_agents, + add_alert_bulk_op: config.add_alert_bulk_op, + privilege: config.privilege, + // Add a key prefix to avoid auto sorting in js object conversion + keys_prefix: "_", + serialized: config.serialized, + serialized_separator: config.serialized_separator, + nodes: + typeof config.nodes === "function" + ? config.nodes() + : config.disabled + }; + + jQuery.post( + "ajax.php", + opts, + function(data) { + jQuery.each(data, function(id, value) { + // Remove keys_prefix from the index. + id = id.substring(1); + if (id !== "keycount") { + config.callbackPre(); + var option = $("") + .attr("value", id) + .html(value); + config.callbackPost(id, value, option); + $(config.agentSelect).append(option); + } + }); + $(config.loading).hide(); + $select.enable(); + config.callbackAfter(); + }, + "json" + ); + }); + }); + }; + }; + + $.extend({ + pandoraSelectGroupAgent: new _pandoraSelectGroupAgent(), + pandoraSelectGroupAgentDisabled: new _pandoraSelectGroupAgent(true) + }); + + $.extend({ + pandoraSelectAgentModule: new (function() { + this.defaults = { + moduleSelect: "select#id_agent_module", + loading: "#module_loading", + callbackBefore: dummyFunc, + callbackPre: dummyFunc, + callbackPost: dummyFunc, + callbackAfter: dummyFunc, + moduleFilter: { + disabled: 0, + deletePending: 0 + }, + debug: false + }; + + /* public methods */ + this.construct = function(settings) { + return this.each(function() { + this.config = {}; + + this.config = $.extend( + this.config, + $.pandoraSelectAgentModule.defaults, + settings + ); + + var config = this.config; + $(this).change(function() { + var $select = $(config.moduleSelect).disable(); + $(config.loading).show(); + $("option[value!=0]", $select).remove(); + if (!config.callbackBefore(this)) return; + + jQuery.post( + "ajax.php", + { + page: "operation/agentes/ver_agente", + get_agent_modules_json: 1, + id_agent: this.value, + disabled: config.moduleFilter.disabled, + delete_pending: config.moduleFilter.deletePending + }, + function(data) { + jQuery.each(data, function(i, value) { + config.callbackPre(); + // Get the selected item from hidden field + var selected = $( + "#hidden-" + config.moduleSelect.attr("id") + "_selected" + ).val(); + var option; + if (selected == i) { + option = $("") + .prop("selected", true) + .attr("value", value["id_agente_modulo"]) + .html(js_html_entity_decode(value["nombre"])); + } else { + option = $("") + .attr("value", value["id_agente_modulo"]) + .html(js_html_entity_decode(value["nombre"])); + } + config.callbackPost(i, value, option); + $(config.moduleSelect).append(option); + }); + $(config.loading).hide(); + $select.enable(); + config.callbackAfter(); + }, + "json" + ); + }); + }); + }; + })() + }); + + $.extend({ + pandoraSelectAgentAlert: new (function() { + this.defaults = { + alertSelect: "select#id_agent_module", + loading: "#alert_loading", + callbackBefore: dummyFunc, + callbackPre: dummyFunc, + callbackPost: dummyFunc, + callbackAfter: dummyFunc, + debug: false + }; + + /* public methods */ + this.construct = function(settings) { + return this.each(function() { + this.config = {}; + + this.config = $.extend( + this.config, + $.pandoraSelectAgentAlert.defaults, + settings + ); + + var config = this.config; + + $(this).change(function() { + var $select = $(config.alertSelect).disable(); + $(config.loading).show(); + $("option[value!=0]", $select).remove(); + if (!config.callbackBefore(this)) return; + + jQuery.post( + "ajax.php", + { + page: "include/ajax/alert_list.ajax", + get_agent_alerts_simple: 1, + id_agent: this.value + }, + function(data) { + jQuery.each(data, function(i, value) { + config.callbackPre(); + var option = $("") + .attr("value", value["id"]) + .html(js_html_entity_decode(value["template"]["name"])) + .append( + " (" + js_html_entity_decode(value["module_name"]) + ")" + ); + config.callbackPost(i, value, option); + $(config.alertSelect).append(option); + }); + $(config.loading).hide(); + $select.enable(); + config.callbackAfter(); + }, + "json" + ); + }); + }); + }; + })() + }); + + $.extend({ + pandoraSelectOS: new (function() { + this.defaults = { + alertSelect: "select#id_os", + spanPreview: "#os_preview", + debug: false + }; + + /* public methods */ + this.construct = function(settings) { + return this.each(function() { + this.config = {}; + this.config = $.extend( + this.config, + $.pandoraSelectOS.defaults, + settings + ); + + var config = this.config; + + $(this).change(function() { + var id_os = this.value; + + var home_url; + if (typeof settings == "undefined") home_url = "./"; + else home_url = settings.home_url; + + $(config.spanPreview).fadeOut("fast", function() { + $("img", config.spanPreview).remove(); + jQuery.post( + home_url + "ajax.php", + { page: "godmode/setup/setup", get_os_icon: 1, id_os: id_os }, + function(data) { + $(config.spanPreview) + .append(data) + .fadeIn("fast"); + }, + "html" + ); + }); + }); + }); + }; + })() + }); + + $.extend({ + pandoraSelectGroupIcon: new (function() { + this.defaults = { + alertSelect: "select#id_group", + spanPreview: "#group_preview", + debug: false + }; + + /* public methods */ + this.construct = function(settings) { + return this.each(function() { + this.config = {}; + this.config = $.extend( + this.config, + $.pandoraSelectGroupIcon.defaults, + settings + ); + + var config = this.config; + + $(this).change(function() { + var id_group = this.value; + + $(config.spanPreview).fadeOut("fast", function() { + $("img", config.spanPreview).remove(); + jQuery.post( + "ajax.php", + { + page: "godmode/groups/group_list", + get_group_json: 1, + id_group: id_group + }, + function(data) { + var img = $("").attr( + "src", + "images/groups_small/" + data["icon"] + ".png" + ); + $(config.spanPreview) + .append(img) + .fadeIn("fast"); + }, + "json" + ); + }); + }); + }); + }; + })() + }); + + $.fn.extend({ + pandoraSelectGroupAgent: $.pandoraSelectGroupAgent.construct, + pandoraSelectGroupAgentDisabled: + $.pandoraSelectGroupAgentDisabled.construct, + pandoraSelectAgentModule: $.pandoraSelectAgentModule.construct, + pandoraSelectAgentAlert: $.pandoraSelectAgentAlert.construct, + pandoraSelectOS: $.pandoraSelectOS.construct, + pandoraSelectGroupIcon: $.pandoraSelectGroupIcon.construct + }); +})(jQuery); diff --git a/pandora_console/include/javascript/massive_operations.js b/pandora_console/include/javascript/massive_operations.js index 2335c2a305..c0ec1ca744 100644 --- a/pandora_console/include/javascript/massive_operations.js +++ b/pandora_console/include/javascript/massive_operations.js @@ -1,4 +1,4 @@ -/** global $ */ +/* global $, confirmDialog, showSpinner, hideSpinner */ function massiveOperationValidation(contents, totalCount, limit, thisForm) { var output = false; diff --git a/pandora_console/include/javascript/multiselect_filtered.js b/pandora_console/include/javascript/multiselect_filtered.js index 8de92ffcf3..88a0ad8dde 100644 --- a/pandora_console/include/javascript/multiselect_filtered.js +++ b/pandora_console/include/javascript/multiselect_filtered.js @@ -231,7 +231,7 @@ function fmModuleChange(uniqId, isMeta) { if (data) { jQuery.each(data, function(id, value) { var option = $(""); - if (isMeta === true) { + if (isMeta === 1) { option .attr( "value", @@ -251,3 +251,50 @@ function fmModuleChange(uniqId, isMeta) { "json" ); } + +// Function to search in agents select. +function searchAgent(uniqId) { + // Declare variables + var agents = $("#filtered-module-agents-" + uniqId + " option"); + + // Loop through all list items, and hide those who don't match the search query + agents.each(function() { + var filter = $("#text-agent-searchBar-modules") + .val() + .toUpperCase(); + + if ( + $(this) + .text() + .toUpperCase() + .indexOf(filter) > -1 + ) { + $(this).show(); + } else { + $(this).hide(); + } + }); +} + +// Function to search in modules select. +function searchModule(uniqId) { + // Declare variables + var modules = $("#filtered-module-modules-" + uniqId + " option"); + + // Loop through all list items, and hide those who don't match the search query + modules.each(function() { + var filter = $("#text-module-searchBar-modules") + .val() + .toUpperCase(); + if ( + $(this) + .text() + .toUpperCase() + .indexOf(filter) > -1 + ) { + $(this).show(); + } else { + $(this).hide(); + } + }); +} diff --git a/pandora_console/include/lib/Agent.php b/pandora_console/include/lib/Agent.php index c71d8415ce..56a46fe70f 100644 --- a/pandora_console/include/lib/Agent.php +++ b/pandora_console/include/lib/Agent.php @@ -590,15 +590,19 @@ class Agent extends Entity /** * Delete agent from db. * - * @return void + * @return boolean */ public function delete() { // This function also mark modules for deletion. - \agents_delete_agent( + $res = (bool) \agents_delete_agent( $this->fields['id_agente'] ); + if ($res === false) { + return false; + } + // Delete modules. if ($this->modules !== null) { foreach ($this->modules as $module) { @@ -608,6 +612,8 @@ class Agent extends Entity unset($this->fields); unset($this->modules); + + return $res; } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index c457176f49..ba89e2d915 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -8469,3 +8469,40 @@ div#err_msg_centralised { display: flex; flex-direction: row; } + +#select_multiple_modules_filtered > div { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + margin: 5px; + flex-wrap: wrap; + flex: 1 1 320px; +} + +#select_multiple_modules_filtered > div > div { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + flex-wrap: wrap; + width: 250px; +} + +#select_multiple_modules_filtered > div > div > * { + flex: auto; +} + +#select_multiple_modules_filtered > div > div > select { + min-width: 250px !important; +} + +#select_multiple_modules_filtered > div > div > .select2 { + min-width: 250px !important; +} + +#select_multiple_modules_filtered > div > div > input { + max-width: 250px; + width: 95%; + height: 95%; +} diff --git a/pandora_console/install.php b/pandora_console/install.php index cfa8664f21..a52d65cf5a 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -129,7 +129,7 @@
data[] = $row; $row = []; $row[] = __('Search agent'); -$row[] = html_print_input_text('search_agent', $search_agent, '', is_metaconsole() ? 50 : 25, 30, true); +$row[] = html_print_input_text('search_agent', $search_agent, '', 25, 30, true); $row[] = __('Show not init agents'); $row[] = html_print_checkbox('show_not_init_agents', $show_not_init_agents, true, true); +if (is_metaconsole() === true) { + $table->data[] = $row; + $row = []; +} + $row[] = __('Show full hirearchy'); $row[] = html_print_checkbox('serach_hirearchy', $serach_hirearchy, false, true); @@ -241,8 +246,12 @@ $row[] = html_print_select($agent_status_arr, 'status_agent', $status_agent, '', $row[] = html_print_input_hidden('show_not_init_modules_hidden', $show_not_init_modules, true); // Button +if (is_metaconsole() === true) { + $table->data[] = $row; + $row = []; +} + $row[] = html_print_submit_button(__('Filter'), 'uptbutton', false, 'class="sub search"', true); -$table->rowspan[][(count($row) - 1)] = 2; $table->data[] = $row; diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index 8a33477d57..3e7a143b74 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -556,13 +556,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/pandora_console.redhat.spec b/pandora_console/pandora_console.redhat.spec index 53c51e38fe..ba9378a1aa 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 220131 +%define release 220201 # 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 6e65949a39..21bcdb5e94 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 220131 +%define release 220201 # 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 12597a1956..ed02ba1c39 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 220131 +%define release 220201 %define httpd_name httpd # User and Group under which Apache is running %define httpd_name apache2 diff --git a/pandora_server/DEBIAN/control b/pandora_server/DEBIAN/control index f41e82871e..c6e8e66561 100644 --- a/pandora_server/DEBIAN/control +++ b/pandora_server/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-server -Version: 7.0NG.759-220131 +Version: 7.0NG.759-220201 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 a54ba0fac4..82410bd4b4 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-220131" +pandora_version="7.0NG.759-220201" package_cpan=0 package_pandora=1 diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index c6be7d1deb..bdfbec8888 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 = "220131"; +my $pandora_build = "220201"; our $VERSION = $pandora_version." ".$pandora_build; # Setup hash diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 92b48a8711..3136055549 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -1096,12 +1096,12 @@ sub pandora_execute_action ($$$$$$$$$;$$) { my ($field1, $field2, $field3, $field4, $field5, $field6, $field7, $field8, $field9, $field10); my ($field11, $field12, $field13, $field14, $field15, $field16, $field17, $field18, $field19, $field20); - # Check for empty alert fields and assign command field. - my $index = 1; - my @command_fields = split(/,|\[|\]/, $action->{'fields_values'}); - foreach my $field (@command_fields) { + # Check for empty alert fields and assign command field. + my $index = 1; + my @command_fields = split(/,|\[|\]/, $action->{'fields_values'}); + foreach my $field (@command_fields) { unless (defined($action->{'field'.$index}) && $action->{'field'.$index} ne "") { - $action->{'field'.$index} = defined($field) ? $field : "" ; + $action->{'field'.$index} = defined($field) ? $field : "" ; } } @@ -1262,6 +1262,13 @@ sub pandora_execute_action ($$$$$$$$$;$$) { $group = get_db_single_row ($dbh, 'SELECT * FROM tgrupo WHERE id_grupo = ?', $agent->{'id_grupo'}); } + my $agent_status; + if(ref ($module) eq "HASH") { + $agent_status = get_db_single_row ($dbh, 'SELECT * FROM tagente_estado WHERE id_agente_modulo = ?', $module->{'id_agente_modulo'}); + } + + my $time_down = (defined ($agent_status)) ? (time() - $agent_status->{'last_status_change'}) : undef; + if (is_numeric($data)) { my $data_precision = $pa_config->{'graph_precision'}; $data = sprintf("%.$data_precision" . "f", $data); @@ -1269,94 +1276,100 @@ sub pandora_execute_action ($$$$$$$$$;$$) { $data =~ s/\.+$//; } - # Thanks to people of Cordoba univ. for the patch for adding module and + # Thanks to people of Cordoba univ. for the patch for adding module and # id_agent macros to the alert. - + # TODO: Reuse queries. For example, tag data can be extracted with a single query. # Alert macros - my %macros = (_field1_ => $field1, - _field2_ => $field2, - _field3_ => $field3, - _field4_ => $field4, - _field5_ => $field5, - _field6_ => $field6, - _field7_ => $field7, - _field8_ => $field8, - _field9_ => $field9, - _field10_ => $field10, - _field11_ => $field11, - _field12_ => $field12, - _field13_ => $field13, - _field14_ => $field14, - _field15_ => $field15, - _field16_ => $field16, - _field17_ => $field17, - _field18_ => $field18, - _field19_ => $field19, - _field20_ => $field20, - _agentname_ => (defined ($agent)) ? $agent->{'nombre'} : '', - _agentalias_ => (defined ($agent)) ? $agent->{'alias'} : '', - _agent_ => (defined ($agent)) ? ($agent->{'alias'} ? $agent->{'alias'} : $agent->{'nombre'}) : '', - _agentcustomid_ => (defined ($agent)) ? $agent->{'custom_id'} : '', - '_agentcustomfield_\d+_' => undef, - _agentdescription_ => (defined ($agent)) ? $agent->{'comentarios'} : '', - _agentgroup_ => (defined ($group)) ? $group->{'nombre'} : '', - _agentstatus_ => undef, - _agentos_ => (defined ($agent)) ? get_os_name($dbh, $agent->{'id_os'}) : '', - _address_ => (defined ($agent)) ? $agent->{'direccion'} : '', - _timestamp_ => (defined($timestamp)) ? $timestamp : strftime ("%Y-%m-%d %H:%M:%S", localtime()), - _timezone_ => strftime ("%Z", localtime()), - _data_ => $data, - _prevdata_ => undef, - _homeurl_ => $pa_config->{'public_url'}, - _alert_name_ => $alert->{'name'}, - _alert_description_ => $alert->{'description'}, - _alert_threshold_ => $alert->{'time_threshold'}, - _alert_times_fired_ => $alert->{'times_fired'}, - _alert_priority_ => $alert->{'priority'}, - _alert_text_severity_ => get_priority_name($alert->{'priority'}), - _alert_critical_instructions_ => $alert->{'critical_instructions'}, - _alert_warning_instructions_ => $alert->{'warning_instructions'}, - _alert_unknown_instructions_ => $alert->{'unknown_instructions'}, - _groupcontact_ => (defined ($group)) ? $group->{'contact'} : '', - _groupcustomid_ => (defined ($group)) ? $group->{'custom_id'} : '', - _groupother_ => (defined ($group)) ? $group->{'other'} : '', - _module_ => (defined ($module)) ? $module->{'nombre'} : '', - _modulecustomid_ => (defined ($module)) ? $module->{'custom_id'} : '', - _modulegroup_ => undef, - _moduledescription_ => (defined ($module)) ? $module->{'descripcion'} : '', - _modulestatus_ => undef, - _moduletags_ => undef, - '_moduledata_\S+_' => undef, - _id_agent_ => (defined ($module)) ? $module->{'id_agente'} : '', - _id_module_ => (defined ($module)) ? $module->{'id_agente_modulo'} : '', - _id_group_ => (defined ($group)) ? $group->{'id_grupo'} : '', - _id_alert_ => (defined ($alert->{'id_template_module'})) ? $alert->{'id_template_module'} : '', - _interval_ => (defined ($module) && $module->{'module_interval'} != 0) ? $module->{'module_interval'} : (defined ($agent)) ? $agent->{'intervalo'} : '', - _server_ip_ => (defined ($agent)) ? get_db_value($dbh, "SELECT ip_address FROM tserver WHERE name = ?", $agent->{'server_name'}) : '', - _server_name_ => (defined ($agent)) ? $agent->{'server_name'} : '', - _target_ip_ => (defined ($module)) ? $module->{'ip_target'} : '', - _target_port_ => (defined ($module)) ? $module->{'tcp_port'} : '', - _policy_ => (defined ($module)) ? get_db_value ($dbh, "SELECT name FROM tpolicies WHERE id = ?", get_db_value ($dbh, "SELECT id_policy FROM tpolicy_modules WHERE id = ?", $module->{'id_policy_module'})) : '', - _plugin_parameters_ => (defined ($module)) ? $module->{'plugin_parameter'} : '', - _email_tag_ => undef, - _phone_tag_ => undef, - _name_tag_ => undef, - _all_address_ => undef, - '_addressn_\d+_' => undef, - _secondarygroups_ => undef, - ); - + my %macros = ( + _field1_ => $field1, + _field2_ => $field2, + _field3_ => $field3, + _field4_ => $field4, + _field5_ => $field5, + _field6_ => $field6, + _field7_ => $field7, + _field8_ => $field8, + _field9_ => $field9, + _field10_ => $field10, + _field11_ => $field11, + _field12_ => $field12, + _field13_ => $field13, + _field14_ => $field14, + _field15_ => $field15, + _field16_ => $field16, + _field17_ => $field17, + _field18_ => $field18, + _field19_ => $field19, + _field20_ => $field20, + _agentname_ => (defined ($agent)) ? $agent->{'nombre'} : '', + _agentalias_ => (defined ($agent)) ? $agent->{'alias'} : '', + _agent_ => (defined ($agent)) ? ($agent->{'alias'} ? $agent->{'alias'} : $agent->{'nombre'}) : '', + _agentcustomid_ => (defined ($agent)) ? $agent->{'custom_id'} : '', + '_agentcustomfield_\d+_' => undef, + _agentdescription_ => (defined ($agent)) ? $agent->{'comentarios'} : '', + _agentgroup_ => (defined ($group)) ? $group->{'nombre'} : '', + _agentstatus_ => undef, + _agentos_ => (defined ($agent)) ? get_os_name($dbh, $agent->{'id_os'}) : '', + _address_ => (defined ($agent)) ? $agent->{'direccion'} : '', + _timestamp_ => (defined($timestamp)) ? $timestamp : strftime ("%Y-%m-%d %H:%M:%S", localtime()), + _timezone_ => strftime ("%Z", localtime()), + _data_ => $data, + _prevdata_ => undef, + _homeurl_ => $pa_config->{'public_url'}, + _alert_name_ => $alert->{'name'}, + _alert_description_ => $alert->{'description'}, + _alert_threshold_ => $alert->{'time_threshold'}, + _alert_times_fired_ => $alert->{'times_fired'}, + _alert_priority_ => $alert->{'priority'}, + _alert_text_severity_ => get_priority_name($alert->{'priority'}), + _alert_critical_instructions_ => $alert->{'critical_instructions'}, + _alert_warning_instructions_ => $alert->{'warning_instructions'}, + _alert_unknown_instructions_ => $alert->{'unknown_instructions'}, + _groupcontact_ => (defined ($group)) ? $group->{'contact'} : '', + _groupcustomid_ => (defined ($group)) ? $group->{'custom_id'} : '', + _groupother_ => (defined ($group)) ? $group->{'other'} : '', + _module_ => (defined ($module)) ? $module->{'nombre'} : '', + _modulecustomid_ => (defined ($module)) ? $module->{'custom_id'} : '', + _modulegroup_ => undef, + _moduledescription_ => (defined ($module)) ? $module->{'descripcion'} : '', + _modulestatus_ => undef, + _moduletags_ => undef, + '_moduledata_\S+_' => undef, + _id_agent_ => (defined ($module)) ? $module->{'id_agente'} : '', + _id_module_ => (defined ($module)) ? $module->{'id_agente_modulo'} : '', + _id_group_ => (defined ($group)) ? $group->{'id_grupo'} : '', + _id_alert_ => (defined ($alert->{'id_template_module'})) ? $alert->{'id_template_module'} : '', + _interval_ => (defined ($module) && $module->{'module_interval'} != 0) ? $module->{'module_interval'} : (defined ($agent)) ? $agent->{'intervalo'} : '', + _server_ip_ => (defined ($agent)) ? get_db_value($dbh, "SELECT ip_address FROM tserver WHERE name = ?", $agent->{'server_name'}) : '', + _server_name_ => (defined ($agent)) ? $agent->{'server_name'} : '', + _target_ip_ => (defined ($module)) ? $module->{'ip_target'} : '', + _target_port_ => (defined ($module)) ? $module->{'tcp_port'} : '', + _policy_ => (defined ($module)) ? get_db_value ($dbh, "SELECT name FROM tpolicies WHERE id = ?", get_db_value ($dbh, "SELECT id_policy FROM tpolicy_modules WHERE id = ?", $module->{'id_policy_module'})) : '', + _plugin_parameters_ => (defined ($module)) ? $module->{'plugin_parameter'} : '', + _email_tag_ => undef, + _phone_tag_ => undef, + _name_tag_ => undef, + _all_address_ => undef, + '_addressn_\d+_' => undef, + _secondarygroups_ => undef, + _time_down_seconds_ => (defined ($time_down)) ? int($time_down) : '', + _time_down_human_ => seconds_totime($time_down), + _warning_threshold_min_ => (defined ($module->{'min_warning'})) ? $module->{'min_warning'} : '', + _warning_threshold_max_ => (defined ($module->{'max_warning'})) ? $module->{'max_warning'} : '', + _critical_threshold_min_ => (defined ($module->{'min_critical'})) ? $module->{'min_critical'} : '', + _critical_threshold_max_ => (defined ($module->{'max_critical'})) ? $module->{'max_critical'} : '', + ); + if ((defined ($extra_macros)) && (ref($extra_macros) eq "HASH")) { while ((my $macro, my $value) = each (%{$extra_macros})) { $macros{$macro} = $value; } } - + if (defined ($module)) { load_module_macros ($module->{'module_macros'}, \%macros); } - #logger($pa_config, "Clean name ".$clean_name, 10); # User defined alert diff --git a/pandora_server/lib/PandoraFMS/PluginTools.pm b/pandora_server/lib/PandoraFMS/PluginTools.pm index 3ec130bf6b..6dee8649f0 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 = "220131"; +my $pandora_build = "220201"; our $VERSION = $pandora_version." ".$pandora_build; our %EXPORT_TAGS = ( 'all' => [ qw() ] ); diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 2d17d53b80..bcffd78034 100755 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -147,6 +147,7 @@ our @EXPORT = qw( ping resolve_hostname ticks_totime + seconds_totime safe_input safe_output month_have_days @@ -1409,6 +1410,31 @@ sub ticks_totime ($){ return "$days days, $hours hours, $minutes minutes, $seconds seconds"; } + + +################################################################################ +## SUB human_time_readable +# Transform a seconds count in a human readable date +################################################################################ +sub seconds_totime ($){ + my $SECONDS_PER_MINUTE = 60; + my $SECONDS_PER_HOUR = $SECONDS_PER_MINUTE * 60; + my $SECONDS_PER_DAY = $SECONDS_PER_HOUR * 24; + + my $orig_seconds = shift; + + if (!defined($orig_seconds)){ + return ""; + } + + my $seconds = int($orig_seconds) % 60; + my $minutes = int($orig_seconds / $SECONDS_PER_MINUTE) % 60; + my $hours = int($orig_seconds / $SECONDS_PER_HOUR) % 24; + my $days = int($orig_seconds / $SECONDS_PER_DAY); + + return "$days days, $hours hours, $minutes minutes, $seconds seconds"; +} + ################################################################################ =head2 C<< pandora_ping (I<$pa_config>, I<$host>) >> diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index fe4f63d09a..7039e495da 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 220131 +%define release 220201 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index 1a15b60d53..832ffcc978 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 220131 +%define release 220201 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 9aca4fac76..dfcaed77f9 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.759" -PI_BUILD="220131" +PI_BUILD="220201" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 8294f98b0a..dd94f1cf88 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 220131"; +my $version = "7.0NG.759 Build 220201"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index b934bd0533..792a4c2b77 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 220131"; +my $version = "7.0NG.759 Build 220201"; # save program name for logging my $progname = basename($0);