Add agent_disabled functionality
This commit is contained in:
parent
d3f931703b
commit
747a63a2ba
|
@ -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;
|
|
@ -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)
|
||||
) {
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
|
@ -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.
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -1069,7 +1069,7 @@ sub process_xml_server ($$$$) {
|
|||
$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'});
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue