WIP: Backup upload
This commit is contained in:
parent
d43c51cc66
commit
4b7c0fc7ee
|
@ -1,22 +1,38 @@
|
||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Module Manager main script.
|
||||||
|
*
|
||||||
|
* @category Module
|
||||||
|
* @package Pandora FMS
|
||||||
|
* @subpackage Agent Configuration
|
||||||
|
* @version 1.0.0
|
||||||
|
* @license See below
|
||||||
|
*
|
||||||
|
* ______ ___ _______ _______ ________
|
||||||
|
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||||
|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||||
|
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||||
|
*
|
||||||
|
* ============================================================================
|
||||||
|
* Copyright (c) 2005-2021 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
|
||||||
|
* as published by the Free Software Foundation for 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.
|
||||||
|
* ============================================================================
|
||||||
|
*/
|
||||||
|
|
||||||
// Pandora FMS - http://pandorafms.com
|
// You can redefine $url and unset $id_agente to reuse the form. Dirty (hope temporal) hack.
|
||||||
// ==================================================
|
$url_id_agente = (isset($id_agente) === true) ? '&id_agente='.$id_agente : '';
|
||||||
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
|
|
||||||
// Please see http://pandorafms.org for full contribution list
|
$url = sprintf(
|
||||||
// This program is free software; you can redistribute it and/or
|
'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module%s',
|
||||||
// modify it under the terms of the GNU General Public License
|
$url_id_agente
|
||||||
// as published by the Free Software Foundation for 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 can redefine $url and unset $id_agente to reuse the form. Dirty (hope temporal) hack
|
|
||||||
if (isset($id_agente)) {
|
|
||||||
$url = 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module&id_agente='.$id_agente;
|
|
||||||
} else {
|
|
||||||
$url = 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=module';
|
|
||||||
}
|
|
||||||
|
|
||||||
enterprise_include('godmode/agentes/module_manager.php');
|
enterprise_include('godmode/agentes/module_manager.php');
|
||||||
$isFunctionPolicies = enterprise_include_once('include/functions_policies.php');
|
$isFunctionPolicies = enterprise_include_once('include/functions_policies.php');
|
||||||
|
@ -56,7 +72,7 @@ echo __('Search').' '.html_print_input_text(
|
||||||
);
|
);
|
||||||
html_print_input_hidden('search', 1);
|
html_print_input_hidden('search', 1);
|
||||||
// Search string filter form.
|
// Search string filter form.
|
||||||
if (($policy_page) || (isset($agent))) {
|
if (($policy_page !== false) || (isset($agent) === true)) {
|
||||||
echo '<form id="" method="post" action="">';
|
echo '<form id="" method="post" action="">';
|
||||||
} else {
|
} else {
|
||||||
echo '<form id="create_module_type" method="post" action="'.$url.'">';
|
echo '<form id="create_module_type" method="post" action="'.$url.'">';
|
||||||
|
@ -73,25 +89,31 @@ echo '</form>';
|
||||||
$network_available = db_get_sql(
|
$network_available = db_get_sql(
|
||||||
'SELECT count(*)
|
'SELECT count(*)
|
||||||
FROM tserver
|
FROM tserver
|
||||||
WHERE server_type = 1'
|
WHERE server_type = '.SERVER_TYPE_NETWORK
|
||||||
);
|
);
|
||||||
// POSTGRESQL AND ORACLE COMPATIBLE.
|
// POSTGRESQL AND ORACLE COMPATIBLE.
|
||||||
$wmi_available = db_get_sql(
|
$wmi_available = db_get_sql(
|
||||||
'SELECT count(*)
|
'SELECT count(*)
|
||||||
FROM tserver
|
FROM tserver
|
||||||
WHERE server_type = 6'
|
WHERE server_type = '.SERVER_TYPE_WMI
|
||||||
);
|
);
|
||||||
// POSTGRESQL AND ORACLE COMPATIBLE.
|
// POSTGRESQL AND ORACLE COMPATIBLE.
|
||||||
$plugin_available = db_get_sql(
|
$plugin_available = db_get_sql(
|
||||||
'SELECT count(*)
|
'SELECT count(*)
|
||||||
FROM tserver
|
FROM tserver
|
||||||
WHERE server_type = 4'
|
WHERE server_type = '.SERVER_TYPE_PLUGIN
|
||||||
);
|
);
|
||||||
// POSTGRESQL AND ORACLE COMPATIBLE.
|
// POSTGRESQL AND ORACLE COMPATIBLE.
|
||||||
$prediction_available = db_get_sql(
|
$prediction_available = db_get_sql(
|
||||||
'SELECT count(*)
|
'SELECT count(*)
|
||||||
FROM tserver
|
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.
|
// POSTGRESQL AND ORACLE COMPATIBLE.
|
||||||
// Development mode to use all servers.
|
// Development mode to use all servers.
|
||||||
|
@ -122,6 +144,10 @@ if ($prediction_available) {
|
||||||
$modules['predictionserver'] = __('Create a new prediction server module');
|
$modules['predictionserver'] = __('Create a new prediction server module');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($web_available) {
|
||||||
|
$modules['webserver'] = __('Create a new web Server module');
|
||||||
|
}
|
||||||
|
|
||||||
if (enterprise_installed()) {
|
if (enterprise_installed()) {
|
||||||
set_enterprise_module_types($modules);
|
set_enterprise_module_types($modules);
|
||||||
}
|
}
|
||||||
|
@ -298,6 +324,7 @@ if ($module_action === 'delete') {
|
||||||
switch ($config['dbtype']) {
|
switch ($config['dbtype']) {
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
case 'postgresql':
|
case 'postgresql':
|
||||||
|
default:
|
||||||
$result = db_process_sql_delete(
|
$result = db_process_sql_delete(
|
||||||
'tagente_estado',
|
'tagente_estado',
|
||||||
['id_agente_modulo' => $id_agent_module_del]
|
['id_agente_modulo' => $id_agent_module_del]
|
||||||
|
@ -388,10 +415,8 @@ if ($module_action === 'delete') {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Check for errors.
|
// Check for errors.
|
||||||
if ($error != 0) {
|
if ((int) $error == 0) {
|
||||||
} else {
|
|
||||||
$count_correct_delete_modules++;
|
$count_correct_delete_modules++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -489,6 +514,7 @@ switch ($sortField) {
|
||||||
switch ($config['dbtype']) {
|
switch ($config['dbtype']) {
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
case 'postgresql':
|
case 'postgresql':
|
||||||
|
default:
|
||||||
$order[] = [
|
$order[] = [
|
||||||
'field' => 'tagente_modulo.nombre',
|
'field' => 'tagente_modulo.nombre',
|
||||||
'order' => 'ASC',
|
'order' => 'ASC',
|
||||||
|
@ -509,6 +535,7 @@ switch ($sortField) {
|
||||||
switch ($config['dbtype']) {
|
switch ($config['dbtype']) {
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
case 'postgresql':
|
case 'postgresql':
|
||||||
|
default:
|
||||||
$order[] = [
|
$order[] = [
|
||||||
'field' => 'tagente_modulo.nombre',
|
'field' => 'tagente_modulo.nombre',
|
||||||
'order' => 'DESC',
|
'order' => 'DESC',
|
||||||
|
@ -523,6 +550,10 @@ switch ($sortField) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Do none.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -543,6 +574,10 @@ switch ($sortField) {
|
||||||
'order' => 'DESC',
|
'order' => 'DESC',
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Do none.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -563,6 +598,10 @@ switch ($sortField) {
|
||||||
'order' => 'DESC',
|
'order' => 'DESC',
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Do none.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -583,6 +622,10 @@ switch ($sortField) {
|
||||||
'order' => 'DESC',
|
'order' => 'DESC',
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Do none.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -598,6 +641,7 @@ switch ($sortField) {
|
||||||
switch ($config['dbtype']) {
|
switch ($config['dbtype']) {
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
case 'postgresql':
|
case 'postgresql':
|
||||||
|
default:
|
||||||
$order[] = [
|
$order[] = [
|
||||||
'field' => 'nombre',
|
'field' => 'nombre',
|
||||||
'order' => 'ASC',
|
'order' => 'ASC',
|
||||||
|
@ -622,7 +666,7 @@ if (!empty($order)) {
|
||||||
|
|
||||||
$first = true;
|
$first = true;
|
||||||
foreach ($order as $ord) {
|
foreach ($order as $ord) {
|
||||||
if ($first) {
|
if ($first === true) {
|
||||||
$first = false;
|
$first = false;
|
||||||
} else {
|
} else {
|
||||||
$order_sql .= ',';
|
$order_sql .= ',';
|
||||||
|
@ -635,7 +679,10 @@ foreach ($order as $ord) {
|
||||||
$limit = (int) $config['block_size'];
|
$limit = (int) $config['block_size'];
|
||||||
$offset = (int) get_parameter('offset');
|
$offset = (int) get_parameter('offset');
|
||||||
|
|
||||||
$params = ($checked) ? 'tagente_modulo.*, tmodule_group.*' : implode(
|
if ((bool) $checked === true) {
|
||||||
|
$params = 'tagente_modulo.*, tmodule_group.*';
|
||||||
|
} else {
|
||||||
|
$params = implode(
|
||||||
',',
|
',',
|
||||||
[
|
[
|
||||||
'tagente_modulo.id_agente_modulo',
|
'tagente_modulo.id_agente_modulo',
|
||||||
|
@ -660,6 +707,7 @@ $params = ($checked) ? 'tagente_modulo.*, tmodule_group.*' : implode(
|
||||||
'id_policy_module',
|
'id_policy_module',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$where = sprintf('delete_pending = 0 AND id_agente = %s', $id_agente);
|
$where = sprintf('delete_pending = 0 AND id_agente = %s', $id_agente);
|
||||||
|
|
||||||
|
@ -686,7 +734,11 @@ if (isset($config['paginate_module'])) {
|
||||||
|
|
||||||
if ($paginate_module) {
|
if ($paginate_module) {
|
||||||
if (!isset($limit_sql)) {
|
if (!isset($limit_sql)) {
|
||||||
$limit_sql = " LIMIT $offset, $limit ";
|
$limit_sql = sprintf(
|
||||||
|
'LIMIT %s, %s',
|
||||||
|
$offset,
|
||||||
|
$limit
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$limit_sql = '';
|
$limit_sql = '';
|
||||||
|
@ -732,7 +784,13 @@ if ($modules === false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare pagination.
|
// 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) {
|
if ($paginate_module) {
|
||||||
ui_pagination($total_modules, $url);
|
ui_pagination($total_modules, $url);
|
||||||
|
|
|
@ -682,6 +682,22 @@ switch ($moduletype) {
|
||||||
include 'module_manager_editor_wmi.php';
|
include 'module_manager_editor_wmi.php';
|
||||||
break;
|
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.
|
// WARNING: type 7 is reserved on enterprise.
|
||||||
default:
|
default:
|
||||||
if (enterprise_include(
|
if (enterprise_include(
|
||||||
|
|
|
@ -38,6 +38,7 @@ use PandoraFMS::DiscoveryServer;
|
||||||
use PandoraFMS::WMIServer;
|
use PandoraFMS::WMIServer;
|
||||||
use PandoraFMS::PluginServer;
|
use PandoraFMS::PluginServer;
|
||||||
use PandoraFMS::PredictionServer;
|
use PandoraFMS::PredictionServer;
|
||||||
|
use PandoraFMS::WebServer;
|
||||||
|
|
||||||
# Constants for Win32 services.
|
# Constants for Win32 services.
|
||||||
use constant WIN32_SERVICE_STOPPED => 0x01;
|
use constant WIN32_SERVICE_STOPPED => 0x01;
|
||||||
|
@ -123,6 +124,7 @@ sub pandora_startup () {
|
||||||
push (@Servers, new PandoraFMS::WMIServer (\%Config, $DBH));
|
push (@Servers, new PandoraFMS::WMIServer (\%Config, $DBH));
|
||||||
push (@Servers, new PandoraFMS::PluginServer (\%Config, $DBH));
|
push (@Servers, new PandoraFMS::PluginServer (\%Config, $DBH));
|
||||||
push (@Servers, new PandoraFMS::PredictionServer (\%Config, $DBH));
|
push (@Servers, new PandoraFMS::PredictionServer (\%Config, $DBH));
|
||||||
|
push (@Servers, new PandoraFMS::WebServer (\%Config, $DBH));
|
||||||
} else {
|
} else {
|
||||||
# Metaconsole service modules are run by the prediction server
|
# Metaconsole service modules are run by the prediction server
|
||||||
push (@Servers, new PandoraFMS::PredictionServer (\%Config, $DBH));
|
push (@Servers, new PandoraFMS::PredictionServer (\%Config, $DBH));
|
||||||
|
|
|
@ -1,10 +1,20 @@
|
||||||
package PandoraFMS::WebServer;
|
package PandoraFMS::WebServer;
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# Pandora FMS Web Server.
|
# Pandora FMS Web Server.
|
||||||
|
# Pandora FMS. the Flexible Monitoring System. http://www.pandorafms.org
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# Copyright (c) 2007-2021 Artica Soluciones Tecnologicas S.L
|
# 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;
|
use strict;
|
||||||
|
@ -21,14 +31,14 @@ use POSIX qw(strftime);
|
||||||
# Default lib dir for RPM and DEB packages
|
# Default lib dir for RPM and DEB packages
|
||||||
use lib '/usr/lib/perl5';
|
use lib '/usr/lib/perl5';
|
||||||
|
|
||||||
use PandoraFMS::Goliat::GoliatTools;
|
|
||||||
use PandoraFMS::Goliat::GoliatConfig;
|
|
||||||
|
|
||||||
use PandoraFMS::Tools;
|
use PandoraFMS::Tools;
|
||||||
use PandoraFMS::DB;
|
use PandoraFMS::DB;
|
||||||
use PandoraFMS::Core;
|
use PandoraFMS::Core;
|
||||||
use PandoraFMS::ProducerConsumerServer;
|
use PandoraFMS::ProducerConsumerServer;
|
||||||
|
|
||||||
|
use Goliat::GoliatTools;
|
||||||
|
use Goliat::GoliatConfig;
|
||||||
|
|
||||||
# Inherits from PandoraFMS::ProducerConsumerServer
|
# Inherits from PandoraFMS::ProducerConsumerServer
|
||||||
our @ISA = qw(PandoraFMS::ProducerConsumerServer);
|
our @ISA = qw(PandoraFMS::ProducerConsumerServer);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue