Merge branch 'ent-8622-alert-server-solo-el-master-dispara-alertas' into 'develop'
RR alertserver See merge request artica/pandorafms!4761
This commit is contained in:
commit
a4947d5449
|
@ -92,15 +92,38 @@ sub data_producer ($) {
|
|||
my @tasks;
|
||||
my @rows;
|
||||
|
||||
my $n_servers = get_db_value($dbh,
|
||||
'SELECT COUNT(*) FROM `tserver` WHERE `server_type` = ? AND `status` = 1',
|
||||
ALERTSERVER
|
||||
);
|
||||
|
||||
my $i = 0;
|
||||
my %servers = map { $_->{'name'} => $i++; } get_db_rows($dbh,
|
||||
'SELECT `name` FROM `tserver` WHERE `server_type` = ? AND `status` = 1 ORDER BY `name` ASC',
|
||||
ALERTSERVER
|
||||
);
|
||||
|
||||
if ($n_servers eq 0) {
|
||||
$n_servers = 1;
|
||||
}
|
||||
|
||||
# Retrieve alerts to be evaluated.
|
||||
my $server_type_id = $servers{$pa_config->{'servername'}};
|
||||
|
||||
# Make a local copy of locked alerts.
|
||||
$AlertSem->down ();
|
||||
my $locked_alerts = {%Alerts};
|
||||
$AlertSem->up ();
|
||||
|
||||
# Check the execution queue.
|
||||
if (pandora_is_master($pa_config) == 1) {
|
||||
@rows = get_db_rows ($dbh, 'SELECT id, utimestamp FROM talert_execution_queue ORDER BY utimestamp ASC');
|
||||
}
|
||||
my $sql = sprintf(
|
||||
'SELECT id, utimestamp FROM talert_execution_queue
|
||||
WHERE `id` %% %d = %d ORDER BY utimestamp ASC',
|
||||
$n_servers,
|
||||
$server_type_id
|
||||
);
|
||||
|
||||
@rows = get_db_rows($dbh, $sql);
|
||||
|
||||
# Queue alerts.
|
||||
foreach my $row (@rows) {
|
||||
|
|
Loading…
Reference in New Issue