add vernemq plugin

This commit is contained in:
garnier-quentin 2020-05-11 11:02:06 +02:00
parent 5e5c105aed
commit fb81824a85
1 changed files with 7 additions and 16 deletions

View File

@ -143,22 +143,13 @@ sub request_api {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->settings(); $self->settings();
my $content = $self->{http}->request(
my $content = do { method => defined($options{method}) ? $options{method} : 'GET',
local $/ = undef; url_path => '/api/v1' . $options{endpoint},
if (!open my $fh, "<", '/tmp/plop.txt') { unknown_status => $self->{unknown_http_status},
$self->{output}->add_option_msg(short_msg => "Could not open file $self->{option_results}->{$_} : $!"); warning_status => $self->{warning_http_status},
$self->{output}->option_exit(); critical_status => $self->{critical_http_status}
} );
<$fh>;
};
#my $content = $self->{http}->request(
# method => defined($options{method}) ? $options{method} : 'GET',
# url_path => '/api/v1' . $options{endpoint},
# unknown_status => $self->{unknown_http_status},
# warning_status => $self->{warning_http_status},
# critical_status => $self->{critical_http_status}
#);
if (!defined($content) || $content eq '') { if (!defined($content) || $content eq '') {
$self->{output}->add_option_msg(short_msg => "API returns empty content [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']"); $self->{output}->add_option_msg(short_msg => "API returns empty content [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']");