Discovery, notify critical issues in console
This commit is contained in:
parent
4c31e4cda3
commit
4cd8006db4
|
@ -1832,18 +1832,7 @@ sub pandora_execute_action ($$$$$$$$$;$$) {
|
||||||
my @user_list = map {clean_blank($_)} split /,/, $field1;
|
my @user_list = map {clean_blank($_)} split /,/, $field1;
|
||||||
my @group_list = map {clean_blank($_)} split /,/, $field2;
|
my @group_list = map {clean_blank($_)} split /,/, $field2;
|
||||||
|
|
||||||
my $notification = {};
|
send_console_notification($pa_config, $dbh, $field3, $field4, \@user_list, \@group_list);
|
||||||
$notification->{'subject'} = safe_input($field3);
|
|
||||||
$notification->{'mensaje'} = safe_input($field4);
|
|
||||||
$notification->{'id_source'} = get_db_value($dbh, 'SELECT id FROM tnotification_source WHERE description = ?', safe_input('System status'));
|
|
||||||
|
|
||||||
# Create message
|
|
||||||
my $notification_id = db_process_insert($dbh,'id_mensaje','tmensajes',$notification);
|
|
||||||
if (!$notification_id) {
|
|
||||||
logger($pa_config, "Failed action '" . $action->{'name'} . "' for alert '". $alert->{'name'} . "' agent '" . (defined($agent) ? $agent->{'alias'} : 'N/A') . "'.", 3);
|
|
||||||
} else {
|
|
||||||
notification_set_targets($pa_config, $dbh, $notification_id, \@user_list, \@group_list);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
logger($pa_config, "Failed action '" . $action->{'name'} . "' for alert '". $alert->{'name'} . "' agent '" . (defined($agent) ? $agent->{'alias'} : 'N/A') . "' Empty targets. Ignored.", 3);
|
logger($pa_config, "Failed action '" . $action->{'name'} . "' for alert '". $alert->{'name'} . "' agent '" . (defined($agent) ? $agent->{'alias'} : 'N/A') . "' Empty targets. Ignored.", 3);
|
||||||
}
|
}
|
||||||
|
@ -1860,6 +1849,40 @@ sub pandora_execute_action ($$$$$$$$$;$$) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
=head2 C<< send_console_notification (I<$pa_config>, I<$dbh>, I<$subject>, I<$message>, I<$user_list>, I<$group_list>) >>
|
||||||
|
|
||||||
|
Send message (with subject) to given userlist and/ or group list.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
##########################################################################
|
||||||
|
sub send_console_notification {
|
||||||
|
my ($pa_config, $dbh, $subject, $message, $user_list, $group_list) = @_;
|
||||||
|
|
||||||
|
my $notification = {};
|
||||||
|
|
||||||
|
$notification->{'subject'} = safe_input($subject);
|
||||||
|
$notification->{'mensaje'} = safe_input($message);
|
||||||
|
$notification->{'id_source'} = get_db_value($dbh,
|
||||||
|
'SELECT id FROM tnotification_source WHERE description = ?',
|
||||||
|
safe_input('System status')
|
||||||
|
);
|
||||||
|
|
||||||
|
# Create message
|
||||||
|
my $notification_id = db_process_insert($dbh, 'id_mensaje', 'tmensajes', $notification);
|
||||||
|
if (!$notification_id) {
|
||||||
|
logger($pa_config, "Cannot send notification '" . $subject . "'", 3);
|
||||||
|
} else {
|
||||||
|
notification_set_targets(
|
||||||
|
$pa_config,
|
||||||
|
$dbh,
|
||||||
|
$notification_id,
|
||||||
|
$user_list,
|
||||||
|
$group_list
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
=head2 C<< pandora_access_update (I<$pa_config>, I<$agent_id>, I<$dbh>) >>
|
=head2 C<< pandora_access_update (I<$pa_config>, I<$agent_id>, I<$dbh>) >>
|
||||||
|
|
||||||
|
|
|
@ -251,6 +251,7 @@ sub data_consumer ($$) {
|
||||||
}
|
}
|
||||||
|
|
||||||
my $recon = new PandoraFMS::Recon::Base(
|
my $recon = new PandoraFMS::Recon::Base(
|
||||||
|
parent => $self,
|
||||||
communities => \@communities,
|
communities => \@communities,
|
||||||
dbh => $dbh,
|
dbh => $dbh,
|
||||||
group_id => $task->{'id_group'},
|
group_id => $task->{'id_group'},
|
||||||
|
@ -1727,6 +1728,16 @@ sub PandoraFMS::Recon::Base::delete_connections($) {
|
||||||
sub PandoraFMS::Recon::Base::message($$$) {
|
sub PandoraFMS::Recon::Base::message($$$) {
|
||||||
my ($self, $message, $verbosity) = @_;
|
my ($self, $message, $verbosity) = @_;
|
||||||
|
|
||||||
|
if ($verbosity <= 1) {
|
||||||
|
PandoraFMS::Core::send_console_notification(
|
||||||
|
$self->{'pa_config'},
|
||||||
|
$self->{'parent'}->getDBH(),
|
||||||
|
"[Recon task " . $self->{'task_id'} . "]",
|
||||||
|
$message,
|
||||||
|
['admin']
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
logger($self->{'pa_config'}, "[Recon task " . $self->{'task_id'} . "] $message", $verbosity);
|
logger($self->{'pa_config'}, "[Recon task " . $self->{'task_id'} . "] $message", $verbosity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue