From 0b53e4053bb9e5ee2ff7dd672097b7cd885e09e2 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 11 May 2020 11:01:46 +0200 Subject: [PATCH] add vernemq plugin --- .../apps/mq/vernemq/restapi/custom/api.pm | 220 ++++++++++++++++++ .../apps/mq/vernemq/restapi/mode/clusters.pm | 165 +++++++++++++ .../apps/mq/vernemq/restapi/mode/listeners.pm | 165 +++++++++++++ .../apps/mq/vernemq/restapi/mode/plugins.pm | 99 ++++++++ .../apps/mq/vernemq/restapi/mode/sessions.pm | 103 ++++++++ .../apps/mq/vernemq/restapi/plugin.pm | 52 +++++ 6 files changed, 804 insertions(+) create mode 100644 centreon-plugins/apps/mq/vernemq/restapi/custom/api.pm create mode 100644 centreon-plugins/apps/mq/vernemq/restapi/mode/clusters.pm create mode 100644 centreon-plugins/apps/mq/vernemq/restapi/mode/listeners.pm create mode 100644 centreon-plugins/apps/mq/vernemq/restapi/mode/plugins.pm create mode 100644 centreon-plugins/apps/mq/vernemq/restapi/mode/sessions.pm create mode 100644 centreon-plugins/apps/mq/vernemq/restapi/plugin.pm diff --git a/centreon-plugins/apps/mq/vernemq/restapi/custom/api.pm b/centreon-plugins/apps/mq/vernemq/restapi/custom/api.pm new file mode 100644 index 000000000..a4e498482 --- /dev/null +++ b/centreon-plugins/apps/mq/vernemq/restapi/custom/api.pm @@ -0,0 +1,220 @@ +# +# Copyright 2020 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package apps::mq::vernemq::restapi::custom::api; + +use strict; +use warnings; +use centreon::plugins::http; +use JSON::XS; + +sub new { + my ($class, %options) = @_; + my $self = {}; + bless $self, $class; + + if (!defined($options{output})) { + print "Class Custom: Need to specify 'output' argument.\n"; + exit 3; + } + if (!defined($options{options})) { + $options{output}->add_option_msg(short_msg => "Class Custom: Need to specify 'options' argument."); + $options{output}->option_exit(); + } + + if (!defined($options{noptions})) { + $options{options}->add_options(arguments => { + 'api-key:s' => { name => 'api_key' }, + 'hostname:s' => { name => 'hostname' }, + 'port:s' => { name => 'port' }, + 'proto:s' => { name => 'proto' }, + 'timeout:s' => { name => 'timeout' }, + 'unknown-http-status:s' => { name => 'unknown_http_status' }, + 'warning-http-status:s' => { name => 'warning_http_status' }, + 'critical-http-status:s' => { name => 'critical_http_status' } + }); + } + $options{options}->add_help(package => __PACKAGE__, sections => 'REST API OPTIONS', once => 1); + + $self->{output} = $options{output}; + $self->{mode} = $options{mode}; + $self->{http} = centreon::plugins::http->new(%options); + + return $self; +} + +sub set_options { + my ($self, %options) = @_; + + $self->{option_results} = $options{option_results}; +} + +sub set_defaults { + my ($self, %options) = @_; + + foreach (keys %{$options{default}}) { + if ($_ eq $self->{mode}) { + for (my $i = 0; $i < scalar(@{$options{default}->{$_}}); $i++) { + foreach my $opt (keys %{$options{default}->{$_}[$i]}) { + if (!defined($self->{option_results}->{$opt}[$i])) { + $self->{option_results}->{$opt}[$i] = $options{default}->{$_}[$i]->{$opt}; + } + } + } + } + } +} + +sub check_options { + my ($self, %options) = @_; + + $self->{hostname} = (defined($self->{option_results}->{hostname})) ? $self->{option_results}->{hostname} : ''; + $self->{port} = (defined($self->{option_results}->{port})) ? $self->{option_results}->{port} : 8888; + $self->{proto} = (defined($self->{option_results}->{proto})) ? $self->{option_results}->{proto} : 'http'; + $self->{timeout} = (defined($self->{option_results}->{timeout})) ? $self->{option_results}->{timeout} : 10; + $self->{api_key} = (defined($self->{option_results}->{api_key})) ? $self->{option_results}->{api_key} : undef; + $self->{unknown_http_status} = (defined($self->{option_results}->{unknown_http_status})) ? $self->{option_results}->{unknown_http_status} : '%{http_code} < 200 or %{http_code} >= 300'; + $self->{warning_http_status} = (defined($self->{option_results}->{warning_http_status})) ? $self->{option_results}->{warning_http_status} : ''; + $self->{critical_http_status} = (defined($self->{option_results}->{critical_http_status})) ? $self->{option_results}->{critical_http_status} : ''; + + if (!defined($self->{hostname}) || $self->{hostname} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --hostname option."); + $self->{output}->option_exit(); + } + if (!defined($self->{api_key}) || $self->{api_key} eq '') { + $self->{output}->add_option_msg(short_msg => "Need to specify --api-key option."); + $self->{output}->option_exit(); + } + + return 0; +} + +sub build_options_for_httplib { + my ($self, %options) = @_; + + $self->{option_results}->{hostname} = $self->{api_key} . '@' . $self->{hostname}; + $self->{option_results}->{timeout} = $self->{timeout}; + $self->{option_results}->{port} = $self->{port}; + $self->{option_results}->{proto} = $self->{proto}; + $self->{option_results}->{timeout} = $self->{timeout}; +} + +sub settings { + my ($self, %options) = @_; + + return if (defined($self->{settings_done})); + $self->build_options_for_httplib(); + $self->{http}->add_header(key => 'Accept', value => 'application/json'); + $self->{http}->add_header(key => 'Content-Type', value => 'application/json'); + $self->{http}->set_options(%{$self->{option_results}}); + $self->{settings_done} = 1; +} + +sub get_hostname { + my ($self, %options) = @_; + + return $self->{hostname}; +} + +sub get_port { + my ($self, %options) = @_; + + return $self->{port}; +} + +sub request_api { + my ($self, %options) = @_; + + $self->settings(); + + my $content = do { + local $/ = undef; + if (!open my $fh, "<", '/tmp/plop.txt') { + $self->{output}->add_option_msg(short_msg => "Could not open file $self->{option_results}->{$_} : $!"); + $self->{output}->option_exit(); + } + <$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 '') { + $self->{output}->add_option_msg(short_msg => "API returns empty content [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']"); + $self->{output}->option_exit(); + } + + my $decoded; + eval { + $decoded = JSON::XS->new->utf8->decode($content); + }; + if ($@) { + $self->{output}->add_option_msg(short_msg => "Cannot decode response (add --debug option to display returned content)"); + $self->{output}->option_exit(); + } + + return $decoded; +} + +1; + +__END__ + +=head1 NAME + +VerneMQ Rest API + +=head1 REST API OPTIONS + +VerneMQ Rest API + +=over 8 + +=item B<--hostname> + +Set hostname. + +=item B<--port> + +Port used (Default: 8888) + +=item B<--proto> + +Specify https if needed (Default: 'http') + +=item B<--api-key> + +VerneMQ API Token. + +=item B<--timeout> + +Set timeout in seconds (Default: 10). + +=back + +=head1 DESCRIPTION + +B. + +=cut diff --git a/centreon-plugins/apps/mq/vernemq/restapi/mode/clusters.pm b/centreon-plugins/apps/mq/vernemq/restapi/mode/clusters.pm new file mode 100644 index 000000000..0dc8c8618 --- /dev/null +++ b/centreon-plugins/apps/mq/vernemq/restapi/mode/clusters.pm @@ -0,0 +1,165 @@ +# +# Copyright 2020 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package apps::mq::vernemq::restapi::mode::clusters; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return 'status: ' . $self->{result_values}->{status}; +} + +sub prefix_cluster_output { + my ($self, %options) = @_; + + return "Cluster '" . $options{instance_value}->{display} . "' "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'clusters', type => 1, cb_prefix_output => 'prefix_cluster_output', message_multiple => 'All clusters are ok', skipped_code => { -10 => 1 } }, + ]; + + $self->{maps_counters}->{global} = [ + { label => 'running', nlabel => 'clusters.running.count', display_ok => 0, set => { + key_values => [ { name => 'running' } ], + output_template => 'current clusters running: %s', + perfdatas => [ + { value => 'running_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'notrunning', nlabel => 'clusters.notrunning.count', display_ok => 0, set => { + key_values => [ { name => 'notrunning' } ], + output_template => 'current clusters not running: %s', + perfdatas => [ + { value => 'notrunning_absolute', template => '%s', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{clusters} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + } + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} eq "notRunning"' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['warning_status', 'critical_status', 'unknown_status']); +} + +sub manage_selection { + my ($self, %options) = @_; + + my $clusters = $options{custom}->request_api(endpoint => '/cluster/show'); + + $self->{global} = { running => 0, notrunning => 0 }; + $self->{clusters} = {}; + foreach (@{$clusters->{table}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $_->{Node} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping cluster '" . $_->{Node} . "': no matching filter.", debug => 1); + next; + } + + $_->{Running} ? $self->{global}->{running}++ : $self->{global}->{notrunning}++; + $self->{clusters}->{$_->{Node}} = { + display => $_->{Node}, + status => $_->{Running} ? 'running' : 'notRunning' + }; + } + + if (scalar(keys %{$self->{clusters}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No cluster found"); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check clusters. + +=over 8 + +=item B<--filter-name> + +Filter cluster name (can be a regexp). + +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{status}, %{display} + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{status}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} eq "notRunning"'). +Can used special variables like: %{status}, %{display} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'running', 'notrunning'. + +=back + +=cut diff --git a/centreon-plugins/apps/mq/vernemq/restapi/mode/listeners.pm b/centreon-plugins/apps/mq/vernemq/restapi/mode/listeners.pm new file mode 100644 index 000000000..8da916ebe --- /dev/null +++ b/centreon-plugins/apps/mq/vernemq/restapi/mode/listeners.pm @@ -0,0 +1,165 @@ +# +# Copyright 2020 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package apps::mq::vernemq::restapi::mode::listeners; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return 'status: ' . $self->{result_values}->{status}; +} + +sub prefix_listener_output { + my ($self, %options) = @_; + + return "Listener '" . $options{instance_value}->{display} . "' "; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0 }, + { name => 'listeners', type => 1, cb_prefix_output => 'prefix_listener_output', message_multiple => 'All listeners are ok', skipped_code => { -10 => 1 } }, + ]; + + $self->{maps_counters}->{global} = [ + { label => 'running', nlabel => 'listeners.running.count', display_ok => 0, set => { + key_values => [ { name => 'running' } ], + output_template => 'current listeners running: %s', + perfdatas => [ + { value => 'running_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'notrunning', nlabel => 'listeners.notrunning.count', display_ok => 0, set => { + key_values => [ { name => 'notrunning' } ], + output_template => 'current listeners not running: %s', + perfdatas => [ + { value => 'notrunning_absolute', template => '%s', min => 0 } + ] + } + } + ]; + + $self->{maps_counters}->{listeners} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'status' }, { name => 'display' } ], + closure_custom_calc => \&catalog_status_calc, + closure_custom_output => $self->can('custom_status_output'), + closure_custom_perfdata => sub { return 0; }, + closure_custom_threshold_check => \&catalog_status_threshold + } + } + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'filter-type:s' => { name => 'filter_type' }, + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} ne "running"' }, + }); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['warning_status', 'critical_status', 'unknown_status']); +} + +sub manage_selection { + my ($self, %options) = @_; + + my $clusters = $options{custom}->request_api(endpoint => '/listener/show'); + + $self->{global} = { running => 0, notrunning => 0 }; + $self->{listeners} = {}; + foreach (@{$clusters->{table}}) { + if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne '' && + $_->{type} !~ /$self->{option_results}->{filter_type}/) { + $self->{output}->output_add(long_msg => "skipping listeners '" . $_->{type} . "': no matching filter.", debug => 1); + next; + } + + $_->{status} eq 'running' ? $self->{global}->{running}++ : $self->{global}->{notrunning}++; + $self->{listeners}->{$_->{type}} = { + display => $_->{type}, + status => $_->{status} + }; + } + + if (scalar(keys %{$self->{listeners}}) <= 0) { + $self->{output}->add_option_msg(short_msg => "No listener found"); + $self->{output}->option_exit(); + } +} + +1; + +__END__ + +=head1 MODE + +Check listeners. + +=over 8 + +=item B<--filter-type> + +Filter listener type (can be a regexp). + +=item B<--unknown-status> + +Set unknown threshold for status. +Can used special variables like: %{status}, %{display} + +=item B<--warning-status> + +Set warning threshold for status. +Can used special variables like: %{status}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} ne "running"'). +Can used special variables like: %{status}, %{display} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'running', 'notrunning'. + +=back + +=cut diff --git a/centreon-plugins/apps/mq/vernemq/restapi/mode/plugins.pm b/centreon-plugins/apps/mq/vernemq/restapi/mode/plugins.pm new file mode 100644 index 000000000..49fef8ace --- /dev/null +++ b/centreon-plugins/apps/mq/vernemq/restapi/mode/plugins.pm @@ -0,0 +1,99 @@ +# +# Copyright 2020 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package apps::mq::vernemq::restapi::mode::plugins; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'total', nlabel => 'plugins.total.count', set => { + key_values => [ { name => 'total' } ], + output_template => 'current total plugins: %s', + perfdatas => [ + { value => 'total_absolute', template => '%s', min => 0 } + ] + } + } + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' } + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $plugins = $options{custom}->request_api( + endpoint => '/plugin/show' + ); + + $self->{global} = { total => 0 }; + foreach (@{$plugins->{table}}) { + if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && + $_->{Plugin} !~ /$self->{option_results}->{filter_name}/) { + $self->{output}->output_add(long_msg => "skipping plugin '" . $_->{Plugin} . "': no matching filter.", debug => 1); + next; + } + + $self->{global}->{total}++; + } +} + +1; + +__END__ + +=head1 MODE + +Check plugins. + +=over 8 + +=item B<--filter-name> + +Filter plugin name (can be a regexp). + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'total'. + +=back + +=cut diff --git a/centreon-plugins/apps/mq/vernemq/restapi/mode/sessions.pm b/centreon-plugins/apps/mq/vernemq/restapi/mode/sessions.pm new file mode 100644 index 000000000..d3f2cdde7 --- /dev/null +++ b/centreon-plugins/apps/mq/vernemq/restapi/mode/sessions.pm @@ -0,0 +1,103 @@ +# +# Copyright 2020 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package apps::mq::vernemq::restapi::mode::sessions; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; + +sub prefix_session_output { + my ($self, %options) = @_; + + return 'Sessions '; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'global', type => 0, cb_prefix_output => 'prefix_session_output', skipped_code => { -10 => 1 } } + ]; + + $self->{maps_counters}->{global} = [ + { label => 'online', nlabel => 'sessions.online.count', set => { + key_values => [ { name => 'online' } ], + output_template => 'current online: %s', + perfdatas => [ + { value => 'online_absolute', template => '%s', min => 0 } + ] + } + }, + { label => 'total', nlabel => 'sessions.total.count', set => { + key_values => [ { name => 'total' } ], + output_template => 'current total: %s', + perfdatas => [ + { value => 'total_absolute', template => '%s', min => 0 } + ] + } + } + ]; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + }); + + return $self; +} + +sub manage_selection { + my ($self, %options) = @_; + + my $sessions = $options{custom}->request_api( + endpoint => '/session/show' + ); + + $self->{global} = { total => 0, online => 0 }; + foreach (@{$sessions->{table}}) { + $self->{global}->{online}++ if ($_->{is_online}); + $self->{global}->{total}++; + } +} + +1; + +__END__ + +=head1 MODE + +Check sessions. + +=over 8 + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'total', 'online'. + +=back + +=cut diff --git a/centreon-plugins/apps/mq/vernemq/restapi/plugin.pm b/centreon-plugins/apps/mq/vernemq/restapi/plugin.pm new file mode 100644 index 000000000..a861913d3 --- /dev/null +++ b/centreon-plugins/apps/mq/vernemq/restapi/plugin.pm @@ -0,0 +1,52 @@ +# +# Copyright 2020 Centreon (http://www.centreon.com/) +# +# Centreon is a full-fledged industry-strength solution that meets +# the needs in IT infrastructure and application monitoring for +# service performance. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package apps::mq::vernemq::restapi::plugin; + +use strict; +use warnings; +use base qw(centreon::plugins::script_custom); + +sub new { + my ( $class, %options ) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $self->{version} = '0.1'; + %{ $self->{modes} } = ( + 'clusters' => 'apps::mq::vernemq::restapi::mode::clusters', + 'listeners' => 'apps::mq::vernemq::restapi::mode::listeners', + 'plugins' => 'apps::mq::vernemq::restapi::mode::plugins', + 'sessions' => 'apps::mq::vernemq::restapi::mode::sessions' + ); + + $self->{custom_modes}{api} = 'apps::mq::vernemq::restapi::custom::api'; + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check VerneMQ using Rest API. + +=cut