Monitoring-Icinga2-Client-Simple
view release on metacpan or search on metacpan
lib/Monitoring/Icinga2/Client/Simple.pm view on Meta::CPAN
if( defined $ua ) {
# This is a hack as I don't maintain the superclass. However, I wrote its
# constructor and we'll check whether it has changed so it should be fine.
# uncoverable branch true
defined $self->{ua} or croak( 'Monitoring::Icinga2::Client::REST seems to have changed internals; '. 'passing `useragent\' does not work. Please notify mbethke@cpan.org');
$ua->default_header( 'Accept' => 'application/json' );
$self->{ua} = $ua;
}
# uncoverable condition false
# uncoverable branch right
$self->{_mics_author} = getlogin || getpwuid($<);
return $self;
}
sub schedule_downtime {
my ($self, %args) = @_;
_checkargs(\%args, qw/ start_time end_time comment host /);
# uncoverable condition true
$args{author} //= $self->{_mics_author};
if( $args{service} and not $args{services} ) {
lib/Monitoring/Icinga2/Client/Simple.pm view on Meta::CPAN
=item *
C<service>: set a downtime for only this service on C<host>. Ignored when combined with C<services>.
=item *
C<services>: set to a true value to set downtimes on all of a host's services. Default is to set the downime on the host only.
=item *
C<author>: will use L<getlogin()|perlfunc/getlogin> (or L<getpwuid|perlfunc/getpwuid> where that's unavailable) if unset
=item *
C<fixed>: set to true for a fixed downtime, default is flexible
=back
The method returns a list of hashes with one element for each downtime
successfully set. The following keys are available:
t/MIC-Simple.t view on Meta::CPAN
use strict;
use warnings;
use v5.10.1;
use utf8;
use open qw/ :encoding(UTF-8) :std /;
use Test::More;
use Test::Fatal;
use JSON::XS;
use Monitoring::Icinga2::Client::Simple;
my $LOGIN = getlogin || getpwuid($<);
my @START_END = (
start_time => 1_234_567_890,
end_time => 1_234_567_890 + 60,
);
my $uri_base = 'https://localhost:5665/v1';
my $uri_scheddt = "$uri_base/actions/schedule-downtime";
my $uri_removedt = "$uri_base/actions/remove-downtime";
my $uri_custnot = "$uri_base/actions/send-custom-notification";
my $uri_hosts = "$uri_base/objects/hosts";
( run in 0.300 second using v1.01-cache-2.11-cpan-8d75d55dd25 )