/
usr
/
lib
/
raider
/
Raider
/
Notification
/
File Upload :
llllll
Current File: //usr/lib/raider/Raider/Notification/API.pm
use strict; use warnings; package Raider::Notification::API; use base qw( Raider::Notification ); use Raider::Notification::Email; =head1 NAME Raider::Notification::API - Interact with the System Restore API =head1 DESCRIPTION Class for interacting with the System Restore API. =head1 USAGE use Raider::Notification::API; my $apiObj = Raider::Notification::API->new(); =head1 METHODS =head2 send_notification(\%args) Send the passed API notification to the api_host. =cut sub send_notification { my ($self, $opts) = @_; my $notifEmail = Raider::Notification::Email->new(); eval { my %params = ( ip => $self->{raidalarm}->get_my_ip(), host => $Raider::Base::base_conf{hostname}, data => $opts->{message}, uniq_id => $self->{uniq_id} ); $params{testing} = \1 if ($ENV{RAIDER_RAIDARLARM_DEBUG}); $self->{raidalarm}->call( method => '/json', verb => 'post', params => \%params, ); }; if (my $e = $@) { my $msg = <<END; RAIDER was unable to post to the API on [$Raider::Base::base_conf{hostname}]; This alarm will need to be submitted to RaidAlarms manually.. RAIDER version: $Raider::Base::base_conf{raider_version} Perl version: $Raider::Base::base_conf{perl_version} Exception: $e Original message below: $opts->{message} END if ($opts->{no_log}) { print STDERR "$msg\n"; $notifEmail->send_notification({no_log => 1, subject => '[RAIDER] [CRIT] Error posting to API', message => $msg}); } else { $self->logger({cat => 'w', msg => "Failed to post event to API:\n$e\nDoing email notification."}); $notifEmail->send_notification({subject => '[RAIDER] [CRIT] Error posting to API', message => $msg}); } return; } if ($opts->{no_log}) { print "Successfully posted event to API.\n"; } else { $self->logger({cat => 'i', msg => 'Successfully posted event to API.'}); } } 1;
Copyright ©2k19 -
Hexid
|
Tex7ure