mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 16:55:05 +02:00
FIx issues from ticket 10847
This commit is contained in:
parent
5e49200f72
commit
633ee5ff2a
@ -97,6 +97,8 @@ INSERT IGNORE INTO `tcredential_store` (`identifier`, `id_group`, `product`, `ex
|
|||||||
;
|
;
|
||||||
UPDATE `trecon_task` SET `auth_strings` = IF(`auth_strings` = '',CONCAT(@creds_name,`id_rt`),CONCAT(@creds_name,`id_rt`,',',`auth_strings`)) WHERE `snmp_version` = 3 AND `snmp_enabled` = 1;
|
UPDATE `trecon_task` SET `auth_strings` = IF(`auth_strings` = '',CONCAT(@creds_name,`id_rt`),CONCAT(@creds_name,`id_rt`,',',`auth_strings`)) WHERE `snmp_version` = 3 AND `snmp_enabled` = 1;
|
||||||
|
|
||||||
|
ALTER TABLE `tdatabase` ADD COLUMN `disabled` TINYINT NOT NULL DEFAULT 0;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `tmetaconsole_ha_databases` (
|
CREATE TABLE IF NOT EXISTS `tmetaconsole_ha_databases` (
|
||||||
`node_id` int unsigned NOT NULL,
|
`node_id` int unsigned NOT NULL,
|
||||||
`host` varchar(255) DEFAULT '',
|
`host` varchar(255) DEFAULT '',
|
||||||
|
@ -442,16 +442,6 @@ sub ha_database_connect_pandora($) {
|
|||||||
# Select a new master database.
|
# Select a new master database.
|
||||||
my ($dbh, $utimestamp, $max_utimestamp) = (undef, undef, -1);
|
my ($dbh, $utimestamp, $max_utimestamp) = (undef, undef, -1);
|
||||||
|
|
||||||
my @disabled_nodes = get_disabled_nodes($conf);
|
|
||||||
|
|
||||||
# If there are disabled nodes ignore them from the HA_DB_Hosts.
|
|
||||||
if(scalar @disabled_nodes ne 0){
|
|
||||||
@HA_DB_Hosts = grep { my $item = $_; !grep { $_ eq $item } @disabled_nodes } @HA_DB_Hosts;
|
|
||||||
|
|
||||||
my $data = join(",", @disabled_nodes);
|
|
||||||
log_message($conf, 'LOG', "Ignoring disabled hosts: " . $data);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach my $ha_dbhost (@HA_DB_Hosts) {
|
foreach my $ha_dbhost (@HA_DB_Hosts) {
|
||||||
|
|
||||||
# Retry each database ha_connect_retries times.
|
# Retry each database ha_connect_retries times.
|
||||||
@ -478,6 +468,25 @@ sub ha_database_connect_pandora($) {
|
|||||||
# No luck. Try the next database.
|
# No luck. Try the next database.
|
||||||
next unless defined($dbh);
|
next unless defined($dbh);
|
||||||
|
|
||||||
|
# Check if database is disabled.
|
||||||
|
if (defined(get_db_value($dbh, 'SELECT `id` FROM `tdatabase` WHERE `host` = "' . $ha_dbhost . '" AND disabled = 1')))
|
||||||
|
{
|
||||||
|
log_message($conf, 'LOG', "Ignoring disabled host: " . $ha_dbhost);
|
||||||
|
db_disconnect($dbh);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
my @disabled_nodes = get_disabled_nodes($conf);
|
||||||
|
|
||||||
|
# If there are disabled nodes ignore them from the HA_DB_Hosts.
|
||||||
|
if(scalar @disabled_nodes ne 0){
|
||||||
|
#@HA_DB_Hosts = grep { my $item = $_; !grep { $_ eq $item } @disabled_nodes } @HA_DB_Hosts;
|
||||||
|
|
||||||
|
my $data = join(",", @disabled_nodes);
|
||||||
|
log_message($conf, 'LOG', "Ignoring disabled hosts: " . $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
next if (grep { $_ == $ha_dbhost } @disabled_nodes)
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
# Get the most recent utimestamp from the database.
|
# Get the most recent utimestamp from the database.
|
||||||
$utimestamp = get_db_value($dbh, 'SELECT UNIX_TIMESTAMP(MAX(keepalive)) FROM tserver');
|
$utimestamp = get_db_value($dbh, 'SELECT UNIX_TIMESTAMP(MAX(keepalive)) FROM tserver');
|
||||||
@ -542,36 +551,6 @@ sub ha_restart_pandora($) {
|
|||||||
`$config->{'pandora_service_cmd'} $control_command 2>/dev/null`;
|
`$config->{'pandora_service_cmd'} $control_command 2>/dev/null`;
|
||||||
}
|
}
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
# Get ip of the disabled nodes.
|
|
||||||
###############################################################################
|
|
||||||
sub get_disabled_nodes($) {
|
|
||||||
my ($conf) = @_;
|
|
||||||
|
|
||||||
my $dbh = db_connect('mysql',
|
|
||||||
$conf->{'dbname'},
|
|
||||||
$conf->{'dbhost'},
|
|
||||||
$conf->{'dbport'},
|
|
||||||
$conf->{'ha_dbuser'},
|
|
||||||
$conf->{'ha_dbpass'});
|
|
||||||
|
|
||||||
my $disabled_nodes = get_db_value($dbh, "SELECT value FROM tconfig WHERE token = 'ha_disabled_nodes'");
|
|
||||||
|
|
||||||
if(!defined($disabled_nodes) || $disabled_nodes eq ""){
|
|
||||||
$disabled_nodes = ',';
|
|
||||||
}
|
|
||||||
|
|
||||||
my @disabled_nodes = split(',', $disabled_nodes);
|
|
||||||
|
|
||||||
if(scalar @disabled_nodes ne 0){
|
|
||||||
$disabled_nodes = join(",", @disabled_nodes);
|
|
||||||
@disabled_nodes = get_db_rows($dbh, "SELECT host FROM tdatabase WHERE id IN ($disabled_nodes)");
|
|
||||||
@disabled_nodes = map { $_->{host} } @disabled_nodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
return @disabled_nodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Main (Pacemaker)
|
# Main (Pacemaker)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
Loading…
x
Reference in New Issue
Block a user