diff --git a/pandora_console/godmode/servers/modificar_server.php b/pandora_console/godmode/servers/modificar_server.php
index 64e7e18485..38cd738b88 100644
--- a/pandora_console/godmode/servers/modificar_server.php
+++ b/pandora_console/godmode/servers/modificar_server.php
@@ -29,6 +29,9 @@ if (! check_acl ($config["id_user"], 0, "AW")) {
}
if (isset($_GET["server"])) {
+
+ enterprise_include("godmode/agentes/agent_disk_conf_editor.php");
+
$id_server= get_parameter_get ("server");
// Headers
ui_print_page_header (__('Update Server'), "images/gm_servers.png", false, "servers", true);
@@ -53,6 +56,13 @@ if (isset($_GET["server"])) {
echo "";
}
+elseif (isset($_GET["server_remote"])) {
+
+ // Headers
+ $id_server= get_parameter_get ("server_remote");
+ ui_print_page_header (__('Remote Configuration'), "images/gm_servers.png", false, "servers", true);
+ enterprise_include("godmode/servers/server_disk_conf_editor.php");
+ }
else {
// Header
ui_print_page_header (__('Pandora servers'), "images/gm_servers.png", false, "servers", true);
@@ -107,6 +117,26 @@ else {
ui_print_error_message(__('There was a problem updating the server'));
}
}
+ elseif (isset($_GET["delete_conf_file"])) {
+
+ $correct = false;
+ $id_server = get_parameter ("id_server");
+ $server_md5 = md5(io_safe_output(servers_get_name ($id_server,'none')), FALSE);
+
+ if (file_exists ($config["remote_config"] . "/md5/" . $server_md5 . ".srv.md5")) {
+ // Server remote configuration editor
+ $file_name = $config["remote_config"] . "/conf/" . $server_md5 . ".srv.conf";
+ $correct = @unlink ($file_name);
+
+ $file_name = $config["remote_config"] . "/md5/" . $server_md5 . ".srv.md5";
+ $correct = @unlink ($file_name);
+ }
+
+ ui_print_result_message ($correct,
+ __('Conf file deleted successfully'),
+ __('Could not delete conf file'));
+ }
+
$tiny = false;
require($config['homedir'] . '/godmode/servers/servers.build_table.php');
diff --git a/pandora_console/godmode/servers/servers.build_table.php b/pandora_console/godmode/servers/servers.build_table.php
index 146240baea..75c619ab72 100644
--- a/pandora_console/godmode/servers/servers.build_table.php
+++ b/pandora_console/godmode/servers/servers.build_table.php
@@ -75,6 +75,7 @@ if (check_acl ($config["id_user"], 0, "PM")) {
}
$table->data = array ();
+$names_servers = array ();
foreach ($servers as $server) {
$data = array ();
@@ -122,6 +123,15 @@ foreach ($servers as $server) {
}
$data[7] = ui_print_timestamp ($server['keepalive'], true);
+ $safe_server_name = servers_get_name($server["id_server"]);
+ if (!isset($names_servers[$safe_server_name])){
+ if (servers_check_remote_config ($safe_server_name) && enterprise_installed()) {
+ $names_servers[$safe_server_name] = true;
+ } else {
+ $names_servers[$safe_server_name] = false;
+ }
+ }
+
//Only Pandora Administrator can delete servers
if (check_acl ($config["id_user"], 0, "PM")) {
$data[8] = '';
@@ -143,6 +153,14 @@ foreach ($servers as $server) {
array('title' => __('Edit')));
$data[8] .= '';
+ if ($names_servers[$safe_server_name] === true) {
+ $data[8] .= '';
+ $data[8] .= html_print_image ('images/remote_configuration.png', true,
+ array('title' => __('Remote configuration')));
+ $data[8] .= '';
+ $names_servers[$safe_server_name] = false;
+ }
+
$data[8] .= ' ';
$data[8] .= html_print_image ('images/cross.png', true,
array('title' => __('Delete'),
diff --git a/pandora_console/include/functions_servers.php b/pandora_console/include/functions_servers.php
index 02e41ddc8b..9ecbdf2520 100644
--- a/pandora_console/include/functions_servers.php
+++ b/pandora_console/include/functions_servers.php
@@ -670,6 +670,37 @@ function servers_get_name ($id_server) {
return (string) db_get_value ('name', 'tserver', 'id_server', (int) $id_server);
}
+/**
+ * Get the presence of .conf and .md5 into remote_config dir
+ *
+ * @param string Agent name
+ *
+ * @return true if files exist and are writable
+ */
+
+
+function servers_check_remote_config ($server_name) {
+ global $config;
+
+ $server_md5 = md5 ($server_name, false);
+
+ $filenames = array();
+ $filenames['md5'] = io_safe_output($config["remote_config"])
+ . "/md5/" . $server_md5 . ".srv.md5";
+ $filenames['conf'] = io_safe_output($config["remote_config"])
+ . "/conf/" . $server_md5 . ".srv.conf";
+
+ if (! isset ($filenames['conf']))
+ return false;
+ if (! isset ($filenames['md5']))
+ return false;
+
+ return (file_exists ($filenames['conf'])
+ && is_writable ($filenames['conf'])
+ && file_exists ($filenames['md5'])
+ && is_writable ($filenames['md5']));
+}
+
/**
* Return a string containing image tag for a given target id (server)
* TODO: Make this print_servertype_icon and move to functions_ui.php. Make XHTML compatible. Make string translatable
diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server
index 3dad433d68..263294a7c6 100755
--- a/pandora_server/bin/pandora_server
+++ b/pandora_server/bin/pandora_server
@@ -139,8 +139,10 @@ sub pandora_startup () {
########################################################################################
# Server restart.
########################################################################################
-sub pandora_restart () {
-
+sub pandora_restart (;$) {
+
+ my $sleep_time = @_ > 0 ? $_[0] : $Config{'restart_delay'};
+
# Stop the servers
foreach my $server (@Servers) {
$server->stop ();
@@ -153,7 +155,7 @@ sub pandora_restart () {
close (STDERR);
# Wait before trying to start again
- sleep ($Config{'restart_delay'});
+ sleep ($sleep_time);
# Start the servers
pandora_startup ();
@@ -624,6 +626,18 @@ sub main() {
# Unmute
open(STDOUT, ">&OLDOUT");
close (OLDOUT);
+ }
+
+ if ($Config{'remote_config'} == 1 && enterprise_hook ('pandora_remote_config_server', [\%Config])) {
+
+ # Generate 'restarting' events
+ foreach my $server (@Servers) {
+ $server->restartEvent ($@);
+ }
+
+ logger (\%Config, 'Pandora FMS Server restarting (' . $@ . ') in 10 seconds.', 1);
+ pandora_load_config (\%Config);
+ pandora_restart (5);
}
threads->yield;
diff --git a/pandora_server/conf/pandora_server.conf.new b/pandora_server/conf/pandora_server.conf.new
index ef6933e66c..246d7ce351 100644
--- a/pandora_server/conf/pandora_server.conf.new
+++ b/pandora_server/conf/pandora_server.conf.new
@@ -509,3 +509,5 @@ console_pass pandora
# Maximum executing time of an alert (in seconds)
global_alert_timeout 15
+# If set to 1 allows PandoraFMS Server to be configured via the web console (Only Enterprise version)
+remote_config 0
diff --git a/pandora_server/conf/pandora_server.conf.windows b/pandora_server/conf/pandora_server.conf.windows
index 5c9aa5bbe5..4557ca05bc 100644
--- a/pandora_server/conf/pandora_server.conf.windows
+++ b/pandora_server/conf/pandora_server.conf.windows
@@ -316,3 +316,5 @@ console_pass pandora
# Maximum executing time of an alert (in seconds)
global_alert_timeout 15
+# If set to 1 allows PandoraFMS Server to be configured via the web console (Only Enterprise version)
+remote_config 0
diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm
index 3fe011c28d..44bdb5bc89 100644
--- a/pandora_server/lib/PandoraFMS/Config.pm
+++ b/pandora_server/lib/PandoraFMS/Config.pm
@@ -385,6 +385,9 @@ sub pandora_load_config {
# Global Timeout for Custom Commands Alerts
$pa_config->{"global_alert_timeout"}= 15; # 6.0
+
+ # Server Remote Config
+ $pa_config->{"remote_config"}= 0; # 6.0
# Check for UID0
@@ -857,6 +860,9 @@ sub pandora_load_config {
elsif ($parametro =~ m/^global_alert_timeout\s+([0-9]*)/i) {
$pa_config->{'global_alert_timeout'}= clean_blank($1);
}
+ elsif ($parametro =~ m/^remote_config\s+([0-9]*)/i) {
+ $pa_config->{'remote_config'}= clean_blank($1);
+ }
} # end of loop for parameter #
# Set to RDBMS' standard port