diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 91c6395b96..6f2747de19 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -1,22 +1,38 @@ '; } else { echo '
'; @@ -73,25 +89,31 @@ echo '
'; $network_available = db_get_sql( 'SELECT count(*) FROM tserver - WHERE server_type = 1' + WHERE server_type = '.SERVER_TYPE_NETWORK ); // POSTGRESQL AND ORACLE COMPATIBLE. $wmi_available = db_get_sql( 'SELECT count(*) FROM tserver - WHERE server_type = 6' + WHERE server_type = '.SERVER_TYPE_WMI ); // POSTGRESQL AND ORACLE COMPATIBLE. $plugin_available = db_get_sql( 'SELECT count(*) FROM tserver - WHERE server_type = 4' + WHERE server_type = '.SERVER_TYPE_PLUGIN ); // POSTGRESQL AND ORACLE COMPATIBLE. $prediction_available = db_get_sql( 'SELECT count(*) FROM tserver - WHERE server_type = 5' + WHERE server_type = '.SERVER_TYPE_PREDICTION +); +// POSTGRESQL AND ORACLE COMPATIBLE. +$web_available = db_get_sql( + 'SELECT count(*) +FROM tserver +WHERE server_type = '.SERVER_TYPE_WEB ); // POSTGRESQL AND ORACLE COMPATIBLE. // Development mode to use all servers. @@ -122,6 +144,10 @@ if ($prediction_available) { $modules['predictionserver'] = __('Create a new prediction server module'); } +if ($web_available) { + $modules['webserver'] = __('Create a new web Server module'); +} + if (enterprise_installed()) { set_enterprise_module_types($modules); } @@ -298,6 +324,7 @@ if ($module_action === 'delete') { switch ($config['dbtype']) { case 'mysql': case 'postgresql': + default: $result = db_process_sql_delete( 'tagente_estado', ['id_agente_modulo' => $id_agent_module_del] @@ -388,10 +415,8 @@ if ($module_action === 'delete') { } } - // Check for errors. - if ($error != 0) { - } else { + if ((int) $error == 0) { $count_correct_delete_modules++; } } @@ -489,6 +514,7 @@ switch ($sortField) { switch ($config['dbtype']) { case 'mysql': case 'postgresql': + default: $order[] = [ 'field' => 'tagente_modulo.nombre', 'order' => 'ASC', @@ -509,6 +535,7 @@ switch ($sortField) { switch ($config['dbtype']) { case 'mysql': case 'postgresql': + default: $order[] = [ 'field' => 'tagente_modulo.nombre', 'order' => 'DESC', @@ -523,6 +550,10 @@ switch ($sortField) { break; } break; + + default: + // Do none. + break; } break; @@ -543,6 +574,10 @@ switch ($sortField) { 'order' => 'DESC', ]; break; + + default: + // Do none. + break; } break; @@ -563,6 +598,10 @@ switch ($sortField) { 'order' => 'DESC', ]; break; + + default: + // Do none. + break; } break; @@ -583,6 +622,10 @@ switch ($sortField) { 'order' => 'DESC', ]; break; + + default: + // Do none. + break; } break; @@ -598,6 +641,7 @@ switch ($sortField) { switch ($config['dbtype']) { case 'mysql': case 'postgresql': + default: $order[] = [ 'field' => 'nombre', 'order' => 'ASC', @@ -622,7 +666,7 @@ if (!empty($order)) { $first = true; foreach ($order as $ord) { - if ($first) { + if ($first === true) { $first = false; } else { $order_sql .= ','; @@ -635,31 +679,35 @@ foreach ($order as $ord) { $limit = (int) $config['block_size']; $offset = (int) get_parameter('offset'); -$params = ($checked) ? 'tagente_modulo.*, tmodule_group.*' : implode( - ',', - [ - 'tagente_modulo.id_agente_modulo', - 'id_tipo_modulo', - 'descripcion', - 'nombre', - 'max', - 'min', - 'module_interval', - 'id_modulo', - 'id_module_group', - 'disabled', - 'max_warning', - 'min_warning', - 'str_warning', - 'max_critical', - 'min_critical', - 'str_critical', - 'quiet', - 'critical_inverse', - 'warning_inverse', - 'id_policy_module', - ] -); +if ((bool) $checked === true) { + $params = 'tagente_modulo.*, tmodule_group.*'; +} else { + $params = implode( + ',', + [ + 'tagente_modulo.id_agente_modulo', + 'id_tipo_modulo', + 'descripcion', + 'nombre', + 'max', + 'min', + 'module_interval', + 'id_modulo', + 'id_module_group', + 'disabled', + 'max_warning', + 'min_warning', + 'str_warning', + 'max_critical', + 'min_critical', + 'str_critical', + 'quiet', + 'critical_inverse', + 'warning_inverse', + 'id_policy_module', + ] + ); +} $where = sprintf('delete_pending = 0 AND id_agente = %s', $id_agente); @@ -686,7 +734,11 @@ if (isset($config['paginate_module'])) { if ($paginate_module) { if (!isset($limit_sql)) { - $limit_sql = " LIMIT $offset, $limit "; + $limit_sql = sprintf( + 'LIMIT %s, %s', + $offset, + $limit + ); } } else { $limit_sql = ''; @@ -732,7 +784,13 @@ if ($modules === false) { } // Prepare pagination. -$url = '?'.'sec=gagente&'.'tab=module&'.'sec2=godmode/agentes/configurar_agente&'.'id_agente='.$id_agente.'&'.'sort_field='.$sortField.'&'.'&sort='.$sort.'&'.'search_string='.urlencode($search_string); +$url = sprintf( + '?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente=%s&sort_field=%s&sort=%s&search_string=%s', + $id_agente, + $sortField, + $sort, + urlencode($search_string) +); if ($paginate_module) { ui_pagination($total_modules, $url); diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index c350866cf0..1310fa80bb 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -682,6 +682,22 @@ switch ($moduletype) { include 'module_manager_editor_wmi.php'; break; + case 'webserver': + case MODULE_WEB: + $moduletype = MODULE_WEB; + // Remove content of $ip_target when it is ip_agent because + // it is used as HTTP auth (server) ....ONLY IN NEW MODULE!!! + if (empty($id_agent_module) + && ($ip_target === agents_get_address($id_agente)) + ) { + $ip_target = ''; + } + + $categories = [9]; + include 'module_manager_editor_common.php'; + include 'module_manager_editor_web.php'; + break; + // WARNING: type 7 is reserved on enterprise. default: if (enterprise_include( diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server index d82944f93b..44d1e4dd33 100755 --- a/pandora_server/bin/pandora_server +++ b/pandora_server/bin/pandora_server @@ -38,6 +38,7 @@ use PandoraFMS::DiscoveryServer; use PandoraFMS::WMIServer; use PandoraFMS::PluginServer; use PandoraFMS::PredictionServer; +use PandoraFMS::WebServer; # Constants for Win32 services. use constant WIN32_SERVICE_STOPPED => 0x01; @@ -123,6 +124,7 @@ sub pandora_startup () { push (@Servers, new PandoraFMS::WMIServer (\%Config, $DBH)); push (@Servers, new PandoraFMS::PluginServer (\%Config, $DBH)); push (@Servers, new PandoraFMS::PredictionServer (\%Config, $DBH)); + push (@Servers, new PandoraFMS::WebServer (\%Config, $DBH)); } else { # Metaconsole service modules are run by the prediction server push (@Servers, new PandoraFMS::PredictionServer (\%Config, $DBH)); diff --git a/pandora_server/lib/PandoraFMS/WebServer.pm b/pandora_server/lib/PandoraFMS/WebServer.pm index 5b08e26b9d..6723848d9f 100644 --- a/pandora_server/lib/PandoraFMS/WebServer.pm +++ b/pandora_server/lib/PandoraFMS/WebServer.pm @@ -1,10 +1,20 @@ package PandoraFMS::WebServer; - ########################################################################## # Pandora FMS Web Server. +# Pandora FMS. the Flexible Monitoring System. http://www.pandorafms.org ########################################################################## # Copyright (c) 2007-2021 Artica Soluciones Tecnologicas S.L -# This code is not free or OpenSource. Please don't redistribute. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation; version 2 +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ########################################################################## use strict; @@ -21,14 +31,14 @@ use POSIX qw(strftime); # Default lib dir for RPM and DEB packages use lib '/usr/lib/perl5'; -use PandoraFMS::Goliat::GoliatTools; -use PandoraFMS::Goliat::GoliatConfig; - use PandoraFMS::Tools; use PandoraFMS::DB; use PandoraFMS::Core; use PandoraFMS::ProducerConsumerServer; +use Goliat::GoliatTools; +use Goliat::GoliatConfig; + # Inherits from PandoraFMS::ProducerConsumerServer our @ISA = qw(PandoraFMS::ProducerConsumerServer);