diff --git a/pandora_console/extras/mr/68.sql b/pandora_console/extras/mr/68.sql index eb2a99c6ee..c72067b5d8 100644 --- a/pandora_console/extras/mr/68.sql +++ b/pandora_console/extras/mr/68.sql @@ -157,5 +157,6 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_ha_databases` ( `master` tinyint unsigned DEFAULT '0', PRIMARY KEY (`node_id`, `host`) ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; +ALTER TABLE `tserver` ADD COLUMN `disabled` BOOLEAN NOT NULL DEFAULT FALSE; COMMIT; \ No newline at end of file diff --git a/pandora_console/godmode/servers/servers.build_table.php b/pandora_console/godmode/servers/servers.build_table.php index 58c9f02a7d..beebb0286e 100644 --- a/pandora_console/godmode/servers/servers.build_table.php +++ b/pandora_console/godmode/servers/servers.build_table.php @@ -133,6 +133,14 @@ foreach ($servers as $server) { __('Server has crashed.'), true ); + + } else if ((int) ($server['disabled'] == 1)){ + $data[1] = ui_print_status_image( + STATUS_SERVER_STANDBY, + __('Server was manually disabled.'), + true + ); + } else if ((int) ($server['status'] === 0) || (($date - $server_keepalive) > ($server['server_keepalive']) * 2) ) { diff --git a/pandora_console/images/status_sets/default/server_standby.png b/pandora_console/images/status_sets/default/server_standby.png new file mode 100644 index 0000000000..21e8a6e2cc Binary files /dev/null and b/pandora_console/images/status_sets/default/server_standby.png differ diff --git a/pandora_console/images/status_sets/default/server_standby_ball.png b/pandora_console/images/status_sets/default/server_standby_ball.png new file mode 100644 index 0000000000..3f4067c7b6 Binary files /dev/null and b/pandora_console/images/status_sets/default/server_standby_ball.png differ diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index 48046e2905..4c640ec3b6 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -325,7 +325,7 @@ define('STATUS_ALERT_DISABLED', 'alert_disabled.png'); define('STATUS_SERVER_OK', 'server_ok.png'); define('STATUS_SERVER_DOWN', 'server_down.png'); define('STATUS_SERVER_CRASH', 'server_crash.png'); - +define('STATUS_SERVER_STANDBY', 'server_standby.png'); // Status images (ball). // For modules. @@ -351,7 +351,7 @@ define('STATUS_ALERT_DISABLED_BALL', 'alert_disabled_ball.png'); define('STATUS_SERVER_OK_BALL', 'server_ok_ball.png'); define('STATUS_SERVER_DOWN_BALL', 'server_down_ball.png'); define('STATUS_SERVER_CRASH_BALL', 'server_crash_ball.png'); - +define('STATUS_SERVER_STANDBY_BALL', 'server_standby_ball.png'); // Events criticity. diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 2fb31c87b2..0ce82b1cc0 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -2851,6 +2851,10 @@ function modules_get_color_status($status, $force_module=false) case STATUS_SERVER_CRASH_BALL: return COL_CRITICAL; + case STATUS_SERVER_STANDBY: + case STATUS_SERVER_STANDBY_BALL: + return COL_WARNING; + case AGENT_MODULE_STATUS_WARNING: case AGENT_STATUS_WARNING: case STATUS_MODULE_WARNING: diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 0f46c890a0..2ab5c1be83 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -3454,6 +3454,7 @@ function get_shape_status_set($type) case STATUS_SERVER_OK: case STATUS_SERVER_DOWN: case STATUS_SERVER_CRASH: + case STATUS_SERVER_STANDBY: $return = ['class' => 'status_small_squares']; break; diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index c53fefe586..fe3eb7ebaa 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1157,6 +1157,7 @@ CREATE TABLE IF NOT EXISTS `tserver` ( `exec_proxy` TINYINT UNSIGNED NOT NULL DEFAULT 0, `port` INT UNSIGNED NOT NULL DEFAULT 0, `server_keepalive_utimestamp` BIGINT NOT NULL DEFAULT 0, + `disabled` BOOLEAN NOT NULL DEFAULT FALSE, PRIMARY KEY (`id_server`), KEY `name` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4; diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 5d3d34f870..2fe0572a3a 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -3374,12 +3374,14 @@ Update server status: =cut ########################################################################## -sub pandora_update_server ($$$$$$;$$$$) { +sub pandora_update_server ($$$$$$;$$$$$$) { my ($pa_config, $dbh, $server_name, $server_id, $status, - $server_type, $num_threads, $queue_size, $version, $keepalive) = @_; + $server_type, $num_threads, $queue_size, $version, $keepalive, $disabled, $remote_config) = @_; $num_threads = 0 unless defined ($num_threads); $queue_size = 0 unless defined ($queue_size); + $remote_config = 0 unless defined($remote_config); + $disabled = 0 unless defined($disabled); $keepalive = $pa_config->{'keepalive'} unless defined ($keepalive); my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime()); @@ -3393,13 +3395,12 @@ sub pandora_update_server ($$$$$$;$$$$) { # First run if ($server_id == 0) { - # Create an entry in tserver if needed my $server = get_db_single_row ($dbh, 'SELECT id_server FROM tserver WHERE BINARY name = ? AND server_type = ?', $server_name, $server_type); if (! defined ($server)) { - $server_id = db_insert ($dbh, 'id_server', 'INSERT INTO tserver (name, server_type, description, version, threads, queued_modules, server_keepalive, server_keepalive_utimestamp) - VALUES (?, ?, ?, ?, ?, ?, ?, ?)', $server_name, $server_type, - 'Autocreated at startup', $version, $num_threads, $queue_size, $keepalive, $keepalive_utimestamp); + $server_id = db_insert ($dbh, 'id_server', 'INSERT INTO tserver (name, server_type, description, version, threads, queued_modules, server_keepalive, server_keepalive_utimestamp, disabled) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)', $server_name, $server_type, + 'Autocreated at startup', $version, $num_threads, $queue_size, $keepalive, $keepalive_utimestamp, $disabled); $server = get_db_single_row ($dbh, 'SELECT status FROM tserver WHERE id_server = ?', $server_id); if (! defined ($server)) { @@ -3408,6 +3409,10 @@ sub pandora_update_server ($$$$$$;$$$$) { } } else { $server_id = $server->{'id_server'}; + + if(!$remote_config){ + db_do ($dbh, 'UPDATE tserver SET disabled = ? WHERE id_server = ?', $disabled, $server_id); + } } db_do ($dbh, 'UPDATE tserver SET status = ?, keepalive = ?, master = ?, laststart = ?, version = ?, threads = ?, queued_modules = ?, server_keepalive = ?, server_keepalive_utimestamp = ? @@ -7206,6 +7211,7 @@ sub pandora_disable_autodisable_agents ($$) { GROUP BY tm.id_agente ) AS subquery WHERE subquery.unknown_count >= subquery.sync_modules;'; + my @agents_autodisabled = get_db_rows ($dbh, $sql); return if ($#agents_autodisabled < 0); diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index cb2c5afc4c..5601c1eef7 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -1067,9 +1067,9 @@ sub process_xml_server ($$$$) { $modules = 0 unless defined($modules); $threads = 0 unless defined($threads); $version = '' unless defined($version); - + # Update server information - pandora_update_server ($pa_config, $dbh, $data->{'server_name'}, 0, 1, $server_type, $threads, $modules, $version, $data->{'keepalive'}); + pandora_update_server ($pa_config, $dbh, $data->{'server_name'}, 0, 1, $server_type, $threads, $modules, $version, $data->{'keepalive'}, $data->{'disabled'}, $data->{'remote_config'}); }