From be79ae83fb85b7c1a7bae4c8eaf04f982e0c88b8 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Mon, 12 Nov 2018 15:32:37 +0100 Subject: [PATCH 1/8] Remove a semaphore that is no longer needed. Thanks fbsanchez! Ref pandora_enterprise#3060. --- pandora_server/lib/PandoraFMS/DataServer.pm | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index d5eb621f0d..3c05ae3fa5 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -52,7 +52,6 @@ my %Agents :shared; my $Sem :shared; my $TaskSem :shared; my $AgentSem :shared; -my $ModuleSem :shared; ######################################################################################## # Data Server class constructor. @@ -69,7 +68,6 @@ sub new ($$;$) { $Sem = Thread::Semaphore->new; $TaskSem = Thread::Semaphore->new (0); $AgentSem = Thread::Semaphore->new (1); - $ModuleSem = Thread::Semaphore->new (1); # Call the constructor of the parent class my $self = $class->SUPER::new($config, DATASERVER, \&PandoraFMS::DataServer::data_producer, \&PandoraFMS::DataServer::data_consumer, $dbh); @@ -677,7 +675,6 @@ sub process_module_data ($$$$$$$$$$) { $module_conf->{'module_macros'} = '' unless defined ($module_conf->{'module_macros'}); # Get module data or create it if it does not exist - $ModuleSem->down (); my $module = get_db_single_row ($dbh, 'SELECT * FROM tagente_modulo WHERE id_agente = ? AND ' . db_text ('nombre') . ' = ?', $agent->{'id_agente'}, safe_input($module_name)); if (! defined ($module)) { @@ -685,14 +682,12 @@ sub process_module_data ($$$$$$$$$$) { # Do not auto create modules #if ($pa_config->{'autocreate'} ne '1') { # logger($pa_config, "Module '$module_name' not found for agent '$agent_name' and module auto-creation disabled.", 10); - # $ModuleSem->up (); # return; #} # Is the agent not learning? if (($agent->{'modo'} == 0) && !($force_processing)) { logger($pa_config, "Learning mode disabled. Skipping module '$module_name' agent '$agent_name'.", 10); - $ModuleSem->up (); return; } @@ -700,7 +695,6 @@ sub process_module_data ($$$$$$$$$$) { $module_conf->{'id_tipo_modulo'} = get_module_id ($dbh, $module_type); if ($module_conf->{'id_tipo_modulo'} <= 0) { logger($pa_config, "Invalid module type '$module_type' for module '$module_name' agent '$agent_name'.", 3); - $ModuleSem->up (); return; } @@ -758,7 +752,6 @@ sub process_module_data ($$$$$$$$$$) { $module = get_db_single_row ($dbh, 'SELECT * FROM tagente_modulo WHERE id_agente = ? AND ' . db_text('nombre') . ' = ?', $agent->{'id_agente'}, safe_input($module_name)); if (! defined ($module)) { logger($pa_config, "Could not create module '$module_name' for agent '$agent_name'.", 3); - $ModuleSem->up (); return; } @@ -816,8 +809,6 @@ sub process_module_data ($$$$$$$$$$) { update_module_configuration ($pa_config, $dbh, $module, $module_conf); } - $ModuleSem->up (); - # Module disabled! if ($module->{'disabled'} eq '1') { logger($pa_config, "Skipping disabled module '$module_name' agent '$agent_name'.", 10); From 75ad60a071820681e13c6b81c5f8e1efa26f562e Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Mon, 12 Nov 2018 15:57:18 +0100 Subject: [PATCH 2/8] removed Assigned node field from admin global profile when creating user from metaconsole --- pandora_console/godmode/users/configure_user.php | 1 - 1 file changed, 1 deletion(-) diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 209817feff..670da39fc2 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -744,7 +744,6 @@ $(document).ready (function () { } else { $('#user_configuration_table-metaconsole_agents_manager').hide(); - $('#user_configuration_table-metaconsole_assigned_server').show(); $('#user_configuration_table-metaconsole_access_node').hide(); } }); From a201262737f41c4a5ac89501c6ae9339e51b35bc Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 12 Nov 2018 16:29:31 +0100 Subject: [PATCH 3/8] Fixed php errors on radial networkmap --- pandora_console/include/functions_graph.php | 2 +- pandora_console/include/functions_groups.php | 4 ++-- pandora_console/operation/agentes/networkmap.dinamic.php | 6 +++--- pandora_console/operation/agentes/pandora_networkmap.php | 1 + 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index e31946894f..cc993331ec 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -4387,7 +4387,7 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { $data_agents[$agent_id]['children'][$module_group_id]['children'][] = $data_module; unset($modules[$module_id]); } - function order_module_group_keys ($value, $key) { + function order_module_group_keys ($value) { $value['children'] = array_merge($value['children']); return $value; } diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index 7e84b167d8..bfc5d3af55 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -1701,7 +1701,7 @@ function groups_get_tree_good (&$groups, $parent = false, &$childs) { if ($parent === false && (!isset($group['parent']) || $group['parent'] == 0 || !in_array($group['parent'], $groups))) { $return[$id] = $group; //unset($groups[$id]); - $children = groups_get_tree_good($groups, $id); + $children = groups_get_tree_good($groups, $id, $noUse); if (!empty($children)) { $return[$id]['children'] = $children; @@ -1713,7 +1713,7 @@ function groups_get_tree_good (&$groups, $parent = false, &$childs) { else if ($parent && isset($group['parent']) && $group['parent'] == $parent) { $return[$id] = $group; //unset($groups[$id]); - $children = groups_get_tree_good($groups, $id); + $children = groups_get_tree_good($groups, $id, $noUse); if (!empty($children)) { $return[$id]['children'] = $children; diff --git a/pandora_console/operation/agentes/networkmap.dinamic.php b/pandora_console/operation/agentes/networkmap.dinamic.php index 3100d03298..9e93ad9cc5 100644 --- a/pandora_console/operation/agentes/networkmap.dinamic.php +++ b/pandora_console/operation/agentes/networkmap.dinamic.php @@ -18,10 +18,11 @@ global $config; check_login (); -if (_id_ != "_id_") { +if (defined('_id_') && _id_ != "_id_") { $id = _id_; } else { + define("_id_", "_id_"); $id = get_parameter('id_networkmap', true); } @@ -36,8 +37,7 @@ if (enterprise_installed()) { $activeTab = $tab; } } - -if (_activeTab_ != "_activeTab_") { +if (defined("_activeTab_") && _activeTab_ != "_activeTab_") { $activeTab = _activeTab_; $tab = $activeTab; } diff --git a/pandora_console/operation/agentes/pandora_networkmap.php b/pandora_console/operation/agentes/pandora_networkmap.php index 922cab8b8f..2f37559b48 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.php +++ b/pandora_console/operation/agentes/pandora_networkmap.php @@ -445,6 +445,7 @@ switch ($tab) { if (enterprise_installed()) { $old_networkmaps_enterprise = db_get_all_rows_sql("SELECT * FROM tnetworkmap_enterprise"); + if ($old_networkmaps_enterprise === false) $old_networkmaps_enterprise = array(); } $old_networkmaps_open = db_get_all_rows_sql("SELECT * FROM tnetwork_map"); From e45dc3a9813aaf6c015eed647d5b5b0f8adb9c9b Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Mon, 12 Nov 2018 18:39:14 +0100 Subject: [PATCH 4/8] Fixed bug in modules deletion: parent id set to 0 in case parent has been deleted --- pandora_server/util/pandora_db.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 0981047598..4dfa70a602 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -297,7 +297,9 @@ sub pandora_purgedb ($$) { my $buffer = 1000; my $id_module = $module->{'id_agente_modulo'}; - + + db_do ($dbh, 'UPDATE tagente_modulo SET parent_module_id=0 WHERE parent_module_id=?', $id_module); + log_message ('', "."); while(1) { From e29160f34d1b8461d2e2fc35c859ebc9611e5cb9 Mon Sep 17 00:00:00 2001 From: artica Date: Tue, 13 Nov 2018 00:01:29 +0100 Subject: [PATCH 5/8] Auto-updated build strings. --- pandora_agents/unix/DEBIAN/control | 2 +- pandora_agents/unix/DEBIAN/make_deb_package.sh | 2 +- pandora_agents/unix/pandora_agent | 2 +- pandora_agents/unix/pandora_agent.redhat.spec | 2 +- pandora_agents/unix/pandora_agent.spec | 2 +- pandora_agents/unix/pandora_agent_installer | 2 +- pandora_agents/win32/installer/pandora.mpi | 2 +- pandora_agents/win32/pandora.cc | 2 +- pandora_agents/win32/versioninfo.rc | 2 +- pandora_console/DEBIAN/control | 2 +- pandora_console/DEBIAN/make_deb_package.sh | 2 +- pandora_console/include/config_process.php | 2 +- pandora_console/install.php | 2 +- pandora_console/pandora_console.redhat.spec | 2 +- pandora_console/pandora_console.spec | 2 +- pandora_server/DEBIAN/control | 2 +- pandora_server/DEBIAN/make_deb_package.sh | 2 +- pandora_server/lib/PandoraFMS/Config.pm | 2 +- pandora_server/lib/PandoraFMS/PluginTools.pm | 2 +- pandora_server/pandora_server.redhat.spec | 2 +- pandora_server/pandora_server.spec | 2 +- pandora_server/pandora_server_installer | 2 +- pandora_server/util/pandora_db.pl | 2 +- pandora_server/util/pandora_manage.pl | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index fe6e873a22..dd40ab43d1 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.728-181112 +Version: 7.0NG.728-181113 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 fbb6748c0d..5405c2e93e 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.728-181112" +pandora_version="7.0NG.728-181113" 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 5971ea884b..aba0856a7a 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.728'; -use constant AGENT_BUILD => '181112'; +use constant AGENT_BUILD => '181113'; # 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 32ed9e7f75..42a174a880 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.728 -%define release 181112 +%define release 181113 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 2b0c71bf6c..d4f8aad316 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.728 -%define release 181112 +%define release 181113 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 1faeaf607e..5bad6fa1cf 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.728" -PI_BUILD="181112" +PI_BUILD="181113" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index 8adf396df1..92ffc7a8c6 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{181112} +{181113} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 33daa693bd..9b4848fb00 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.728(Build 181112)") +#define PANDORA_VERSION ("7.0NG.728(Build 181113)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 9f9b037c4c..eb3eccc555 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.728(Build 181112))" + VALUE "ProductVersion", "(7.0NG.728(Build 181113))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index 3e71004ea0..d47d93efa2 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.728-181112 +Version: 7.0NG.728-181113 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 fcaa0249ce..c5c6cbdf7c 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.728-181112" +pandora_version="7.0NG.728-181113" package_pear=0 package_pandora=1 diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index af4db516fb..7cf500786e 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -22,7 +22,7 @@ /** * Pandora build version and version */ -$build_version = 'PC181112'; +$build_version = 'PC181113'; $pandora_version = 'v7.0NG.728'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/install.php b/pandora_console/install.php index a6352aae45..31b94c1e1e 100755 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -71,7 +71,7 @@
[ qw() ] ); diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index c4f79d0a26..ceab85ccc2 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.728 -%define release 181112 +%define release 181113 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index b16c35b798..3be4505a8c 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.728 -%define release 181112 +%define release 181113 Summary: Pandora FMS Server Name: %{name} diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index 1bc1cd2dc6..8402a2c461 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -9,7 +9,7 @@ # ********************************************************************** PI_VERSION="7.0NG.728" -PI_BUILD="181112" +PI_BUILD="181113" MODE=$1 if [ $# -gt 1 ]; then diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 0981047598..2494752a62 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -34,7 +34,7 @@ use PandoraFMS::Config; use PandoraFMS::DB; # version: define current version -my $version = "7.0NG.728 PS181112"; +my $version = "7.0NG.728 PS181113"; # Pandora server configuration my %conf; diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 173c9f1248..5f35b6a2b3 100644 --- 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.728 PS181112"; +my $version = "7.0NG.728 PS181113"; # save program name for logging my $progname = basename($0); From 2a0d2e6c462bc07ee82770488e675b6e4fe472e0 Mon Sep 17 00:00:00 2001 From: danielmaya Date: Tue, 13 Nov 2018 08:33:47 +0100 Subject: [PATCH 6/8] collection management from metaconsole --- .../include/functions_filemanager.php | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/pandora_console/include/functions_filemanager.php b/pandora_console/include/functions_filemanager.php index a27d7d2ec2..31f65447d1 100644 --- a/pandora_console/include/functions_filemanager.php +++ b/pandora_console/include/functions_filemanager.php @@ -495,17 +495,13 @@ function filemanager_file_explorer($real_directory, $relative_directory, if ($homedir_filemanager === false) { $homedir_filemanager = $config['homedir']; - unset($config['homedir_filemanager']); - config_update_value('homedir_filemanager', - $homedir_filemanager); } - else { - $config['homedir_filemanager'] = $homedir_filemanager; - - } - - - + unset($config['homedir_filemanager']); + config_update_value( + 'homedir_filemanager', + $homedir_filemanager + ); + $hack_metaconsole = ''; if (defined('METACONSOLE')) $hack_metaconsole = '../../'; @@ -743,11 +739,11 @@ function filemanager_file_explorer($real_directory, $relative_directory, //Actions buttons //Delete button $data[4] = ''; - $data[4] .= ''; + $data[4] .= ''; $typefile = array_pop(explode(".",$fileinfo['name'])); if (is_writable ($fileinfo['realpath']) && (! is_dir ($fileinfo['realpath']) || count (scandir ($fileinfo['realpath'])) < 3)) { - $data[4] .= '
'; + $data[4] .= ''; $data[4] .= ''; $data[4] .= html_print_input_hidden ('filename', $fileinfo['realpath'], true); $data[4] .= html_print_input_hidden('hash', md5($fileinfo['realpath'] . $config['dbpass']), true); From c5a0065cbaea059187eb6ec2e00f6425c45d4e59 Mon Sep 17 00:00:00 2001 From: alejandro-campos Date: Tue, 13 Nov 2018 11:50:46 +0100 Subject: [PATCH 7/8] decoded entities when retrieving module name in case SNMP module name is updated --- pandora_console/godmode/agentes/configurar_agente.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 36b67da66f..5f364389ed 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -1943,7 +1943,7 @@ switch ($tab) { var aget_id_os = ''; - if('' != $('#text-name').val() && + if('' != $('#text-name').val() && '' == 19){ event.preventDefault(); @@ -1977,7 +1977,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(); From 4dbcecb951eb8f1799330b22ec330e842b5e682e Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 13 Nov 2018 15:46:44 +0100 Subject: [PATCH 8/8] WIP custom fields view --- pandora_console/extras/mr/22.sql | 13 + .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 15 + .../godmode/users/configure_user.php | 13 +- pandora_console/include/ajax/module.php | 293 +++++++++++++++++- pandora_console/include/functions_agents.php | 29 ++ pandora_console/pandoradb.sql | 15 + 6 files changed, 367 insertions(+), 11 deletions(-) diff --git a/pandora_console/extras/mr/22.sql b/pandora_console/extras/mr/22.sql index d0a099460b..39c18cad6c 100644 --- a/pandora_console/extras/mr/22.sql +++ b/pandora_console/extras/mr/22.sql @@ -2,6 +2,19 @@ START TRANSACTION; ALTER TABLE `tusuario` DROP COLUMN `flash_chart`; +ALTER TABLE `tusuario` ADD COLUMN `default_custom_view` int(10) unsigned NULL default '0'; + ALTER TABLE tlayout_template MODIFY `name` varchar(600) NOT NULL; +CREATE TABLE IF NOT EXISTS `tagent_custom_fields_filter` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(600) NOT NULL, + `id_group` int(10) unsigned default '0', + `id_custom_field` varchar(600) default '', + `id_custom_fields_data` varchar(600) default '', + `id_status` varchar(600) default '', + `module_search` varchar(600) default '', + PRIMARY KEY(`id`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; + COMMIT; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 8980cf0982..a2d81b64d9 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 @@ -1231,6 +1231,7 @@ ALTER TABLE tusuario ADD COLUMN `session_time` int(10) signed NOT NULL default ' alter table tusuario add autorefresh_white_list text not null default ''; ALTER TABLE tusuario ADD COLUMN `time_autorefresh` int(5) unsigned NOT NULL default '30'; ALTER TABLE `tusuario` DROP COLUMN `flash_chart`; +ALTER TABLE `tusuario` ADD COLUMN `default_custom_view` int(10) unsigned NULL default '0'; -- --------------------------------------------------------------------- -- Table `tagente_modulo` @@ -1811,3 +1812,17 @@ ALTER TABLE `trecon_task` ADD COLUMN `snmp_auth_method` varchar(25) NOT NULL def ALTER TABLE `trecon_task` ADD COLUMN `snmp_privacy_method` varchar(25) NOT NULL default ''; ALTER TABLE `trecon_task` ADD COLUMN `snmp_privacy_pass` varchar(255) NOT NULL default ''; ALTER TABLE `trecon_task` ADD COLUMN `snmp_security_level` varchar(25) NOT NULL default ''; + +-- --------------------------------------------------------------------- +-- Table `tagent_custom_fields_filter` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tagent_custom_fields_filter` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(600) NOT NULL, + `id_group` int(10) unsigned default '0', + `id_custom_field` varchar(600) default '', + `id_custom_fields_data` varchar(600) default '', + `id_status` varchar(600) default '', + `module_search` varchar(600) default '', + PRIMARY KEY(`id`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 7334985178..d215485694 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -169,6 +169,7 @@ if ($create_user) { $values['language'] = get_parameter ('language', 'default'); $values['timezone'] = (string) get_parameter('timezone'); $values['default_event_filter'] = (int) get_parameter('default_event_filter'); + $values['default_custom_view'] = (int) get_parameter('default_custom_view'); $dashboard = get_parameter('dashboard', ''); $visual_console = get_parameter('visual_console', ''); @@ -281,6 +282,7 @@ if ($update_user) { $values['language'] = (string) get_parameter ('language'); $values['timezone'] = (string) get_parameter('timezone'); $values['default_event_filter'] = (int) get_parameter('default_event_filter'); + $values['default_custom_view'] = (int) get_parameter('default_custom_view'); $dashboard = get_parameter('dashboard', ''); $visual_console = get_parameter('visual_console', ''); @@ -570,7 +572,16 @@ if (!$meta) { } } -$table->data[11][0] = __('Interactive charts').' '.ui_print_help_tip(__('Whether to use Javascript or static PNG graphs'), true) ; +if($meta){ + $array_filters = get_filters_custom_fields_view(0, true); + $table->data[11][0] = __('Search custom field view').' '.ui_print_help_tip(__('Load by default the selected view in custom field view'), true); + $table->data[11][1] =html_print_select( + $array_filters, 'default_custom_view', + $user_info['default_custom_view'], '', __('None'), 0, + true, false, true, '', false + ); +} + $values = array(-1 => __('Use global conf'), 1 => __('Yes'), 0 => __('No')); $table->data[12][0] = __('Home screen'). diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index 8d4fca2cb8..90df3419e8 100755 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -35,9 +35,15 @@ $get_id_tag = (bool) get_parameter('get_id_tag', 0); $get_type = (bool) get_parameter('get_type', 0); $list_modules = (bool) get_parameter('list_modules', 0); $get_agent_modules_json_by_name = (bool) get_parameter('get_agent_modules_json_by_name', 0); + $get_custom_fields_data = (bool) get_parameter('get_custom_fields_data', 0); $build_table_custom_fields = (bool)get_parameter('build_table_custom_fields', 0); $build_table_child_custom_fields = (bool)get_parameter('build_table_child_custom_fields', 0); +$build_table_save_filter = (bool)get_parameter('build_table_save_filter', 0); +$append_tab_filter = (bool)get_parameter('append_tab_filter', 0); +$create_filter_cf = (bool)get_parameter('create_filter_cf', 0); +$update_filter_cf = (bool)get_parameter('update_filter_cf', 0); +$delete_filter_cf = (bool)get_parameter('delete_filter_cf', 0); if ($get_agent_modules_json_by_name) { $agent_name = get_parameter('agent_name'); @@ -1326,8 +1332,6 @@ if($build_table_child_custom_fields){ $name_where ); - hd($query, true, true); - $modules = db_get_all_rows_sql ($query); $table_modules = new stdClass(); @@ -1335,15 +1339,15 @@ if($build_table_child_custom_fields){ $table_modules->class="databox data"; $table_modules->head = array(); - $table_modules->head[0] = __('Name'); - $table_modules->head[1] = __('Data'); - $table_modules->head[2] = __('Min Warning'); - $table_modules->head[3] = __('Max Warning'); - $table_modules->head[4] = __('Min Critical'); - $table_modules->head[5] = __('Max Critical'); + $table_modules->head[0] = __('Module name'); + $table_modules->head[1] = __('Min Warning'); + $table_modules->head[2] = __('Max Warning'); + $table_modules->head[3] = __('Min Critical'); + $table_modules->head[4] = __('Max Critical'); + $table_modules->head[5] = __('Status'); $table_modules->head[6] = __('Current interval'); $table_modules->head[7] = __('Date'); - $table_modules->head[8] = __('Status'); + $table_modules->head[8] = __('Status'); $table_modules->data = array(); if(isset($modules) && is_array($modules)){ @@ -1355,7 +1359,7 @@ if($build_table_child_custom_fields){ $table_modules->data[$key][4] = $value['min_critical']; $table_modules->data[$key][5] = $value['max_critical']; $table_modules->data[$key][6] = $value['current_interval']; - $table_modules->data[$key][7] = date('d/m/Y h:i:s', $value['utimestamp']); + $table_modules->data[$key][7] = date('d/m/Y h:i:s', $value['utimestamp']); switch ($value['estado']) { case 0: case 300: @@ -1428,6 +1432,275 @@ if($build_table_child_custom_fields){ return; } +if($build_table_save_filter){ + $type_form = get_parameter("type_form", ''); + + if($type_form == 'save'){ + $tabs = '
'; + $tabs .= ""; + + $tabs .= '
'; + $tabs .= '
'; + $tabs .= '
'; + $tabs .= '
'; + $tabs .= "
"; + echo $tabs; + } + else{ + $table = new StdClass; + $table->id = 'save_filter_form'; + $table->width = '100%'; + $table->class = 'databox'; + + $array_filters = get_filters_custom_fields_view(0, true); + $table->data[0][0] = __('Filter name'); + $table->data[0][1] = html_print_select( + $array_filters, 'id_name', + '', '', '', '', + true, false, true, '', false + ); + $table->data[0][3] = html_print_submit_button (__('Load filter'), 'load_filter', false, 'class="sub upd"', true); + + echo ""; + html_print_table($table); + echo ""; + } + return; +} + +if($append_tab_filter){ + $filters = json_decode(io_safe_output(get_parameter("filters", '')), true); + + $table = new StdClass; + $table->id = 'save_filter_form'; + $table->width = '100%'; + $table->class = 'databox'; + + if($filters['id'] == 'extended_create_filter'){ + echo "
"; + $table->data[0][0] = __('Filter name'); + $table->data[0][1] = html_print_input_text('id_name', '', '', 15, 255, true); + $table->data[0][2] = html_print_submit_button (__('Create filter'), 'create_filter', false, 'class="sub upd"', true); + } + else{ + echo "
"; + echo "
"; + $array_filters = get_filters_custom_fields_view(0, true); + $table->data[0][0] = __('Filter name'); + $table->data[0][1] = html_print_select( + $array_filters, 'id_name', + '', '', __('None'), -1, + true, false, true, '', false + ); + $table->data[0][2] = html_print_submit_button (__('Delete filter'), 'delete_filter', false, 'class="sub upd"', true); + $table->data[0][3] = html_print_submit_button (__('Update filter'), 'update_filter', false, 'class="sub upd"', true); + } + + html_print_table($table); + return; +} + +if($create_filter_cf){ + //initialize result + $result_array = array(); + $result_array['error'] = 0; + $result_array['msg'] = ''; + + //initialize vars + $filters = json_decode(io_safe_output(get_parameter("filters", '')), true); + $name_filter = get_parameter("name_filter", ''); + + //check that the name is not empty + if($name_filter == ''){ + $result_array['error'] = 1; + $result_array['msg'] = ui_print_error_message( + __('The name must not be empty'), + '', true + ); + echo json_encode($result_array); + return; + } + + $name_exists = get_filters_custom_fields_view(0, false, $name_filter); + + if($name_exists){ + $result_array['error'] = 1; + $result_array['msg'] = ui_print_error_message( + __('Filter name already exists in the bbdd'), + '', true + ); + echo json_encode($result_array); + return; + } + + //check custom field is not empty + if($filters['id_custom_fields'] == ''){ + $result_array['error'] = 1; + $result_array['msg'] = ui_print_error_message( + __('Please, select a custom field'), + '', true + ); + echo json_encode($result_array); + return; + } + + //insert + $values = array(); + $values['name'] = $name_filter; + $values['id_group'] = $filters['group']; + $values['id_custom_field'] = $filters['id_custom_fields']; + $values['id_custom_fields_data'] = json_encode($filters['id_custom_fields_data']); + $values['id_status'] = json_encode($filters['id_status']); + $values['module_search'] = $filters['module_search']; + + $insert = db_process_sql_insert('tagent_custom_fields_filter', $values); + + //check error insert + if($insert) { + $result_array['error'] = 0; + $result_array['msg'] = ui_print_success_message( + __("Success create filter."), + '', true + ); + } else { + $result_array['error'] = 1; + $result_array['msg'] = ui_print_error_message( + __("Error create filter."), + '', true + ); + } + + echo json_encode($result_array); + return; +} + +if($update_filter_cf){ + //initialize result + $result_array = array(); + $result_array['error'] = 0; + $result_array['msg'] = ''; + + //initialize vars + $filters = json_decode(io_safe_output(get_parameter("filters", '')), true); + $id_filter = get_parameter("id_filter", ''); + + //check selected filter + if($id_filter == -1){ + $result_array['error'] = 1; + $result_array['msg'] = ui_print_error_message( + __('please, select a filter'), + '', true + ); + echo json_encode($result_array); + return; + } + + //array condition update + $condition = array(); + $condition['id'] = $id_filter; + + //check selected custom fields + if($filters['id_custom_fields'] == ''){ + $result_array['error'] = 1; + $result_array['msg'] = ui_print_error_message( + __('please, select a custom field'), + '', true + ); + echo json_encode($result_array); + return; + } + + //array values update + $values = array(); + $values['id_group'] = $filters['group']; + $values['id_custom_field'] = $filters['id_custom_fields']; + $values['id_custom_fields_data'] = json_encode($filters['id_custom_fields_data']); + $values['id_status'] = json_encode($filters['id_status']); + $values['module_search'] = $filters['module_search']; + + //update + $update = db_process_sql_update('tagent_custom_fields_filter', $values, $condition); + + //check error insert + if($update) { + $result_array['error'] = 0; + $result_array['msg'] = ui_print_success_message( + __("Success update filter."), + '', true + ); + } else { + $result_array['error'] = 1; + $result_array['msg'] = ui_print_error_message( + __("Error update filter."), + '', true + ); + } + + echo json_encode($result_array); + return; +} + +if($delete_filter_cf){ + //Initialize result + $result_array = array(); + $result_array['error'] = 0; + $result_array['msg'] = ''; + + //Initialize vars + $filters = json_decode(io_safe_output(get_parameter("filters", '')), true); + $id_filter = get_parameter("id_filter", ''); + + //Check selected filter + if($id_filter == -1){ + $result_array['error'] = 1; + $result_array['msg'] = ui_print_error_message( + __('please, select a filter'), + '', true + ); + echo json_encode($result_array); + return; + } + + //Array condition update + $condition = array(); + $condition['id'] = $id_filter; + + //Delete + $delete = db_process_sql_delete('tagent_custom_fields_filter', $condition); + + //Check error insert + if($delete) { + $result_array['error'] = 0; + $result_array['msg'] = ui_print_success_message( + __("Success delete filter."), + '', true + ); + } else { + $result_array['error'] = 1; + $result_array['msg'] = ui_print_error_message( + __("Error delete filter."), + '', true + ); + } + + echo json_encode($result_array); + return; +} + } ?> diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index fe9972e9db..533d9665a2 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -3204,4 +3204,33 @@ function agent_counters_custom_fields($filters){ return $final_result; } + +function get_filters_custom_fields_view($id = 0, $for_select = false, $name = ""){ + if($for_select){ + $query = "SELECT id, `name` FROM tagent_custom_fields_filter"; + $rs = db_get_all_rows_sql($query); + if(isset($rs) && is_array($rs)){ + foreach ($rs as $key => $value) { + $result[$value['id']] = $value['name']; + } + } + else{ + $result = false; + } + } + else{ + $query = "SELECT * FROM tagent_custom_fields_filter WHERE 1=1"; + + if($id){ + $query .= " AND id = " . $id; + } + + if($name){ + $query .= " AND `name` = '" . $name . "'"; + } + + $result = db_get_all_rows_sql($query); + } + return $result; +} ?> \ No newline at end of file diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 00e1b63aba..66bb3f6f14 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1133,6 +1133,7 @@ CREATE TABLE IF NOT EXISTS `tusuario` ( `default_event_filter` int(10) unsigned NOT NULL default 0, `autorefresh_white_list` text not null default '', `time_autorefresh` int(5) unsigned NOT NULL default '30', + `default_custom_view` int(10) unsigned NULL default '0', CONSTRAINT `fk_filter_id` FOREIGN KEY (`id_filter`) REFERENCES tevent_filter (`id_filter`) ON DELETE SET NULL, UNIQUE KEY `id_user` (`id_user`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -3357,3 +3358,17 @@ CREATE TABLE IF NOT EXISTS `tlog_graph_models` ( `average` tinyint(1) NOT NULL default '0', PRIMARY KEY(`id`) ) ENGINE = InnoDB DEFAULT CHARSET=utf8; + +-- --------------------------------------------------------------------- +-- Table `tagent_custom_fields_filter` +-- --------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tagent_custom_fields_filter` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(600) NOT NULL, + `id_group` int(10) unsigned default '0', + `id_custom_field` varchar(600) default '', + `id_custom_fields_data` varchar(600) default '', + `id_status` varchar(600) default '', + `module_search` varchar(600) default '', + PRIMARY KEY(`id`) +) ENGINE = InnoDB DEFAULT CHARSET=utf8; \ No newline at end of file