From da01d2939780f2ee3a98a2729431d38abefe21f5 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Wed, 26 Feb 2020 14:33:33 +0100 Subject: [PATCH] wip: ibm mq --- .../apps/mq/ibmmq/mqi/custom/api.pm | 222 ++++++++++++++++++ .../apps/mq/ibmmq/mqi/mode/channels.pm | 165 +++++++++++++ .../apps/mq/ibmmq/mqi/mode/listqueues.pm | 103 ++++++++ .../apps/mq/ibmmq/mqi/mode/queuemanager.pm | 123 ++++++++++ .../apps/mq/ibmmq/mqi/mode/queues.pm | 165 +++++++++++++ centreon-plugins/apps/mq/ibmmq/mqi/plugin.pm | 52 ++++ 6 files changed, 830 insertions(+) create mode 100644 centreon-plugins/apps/mq/ibmmq/mqi/custom/api.pm create mode 100644 centreon-plugins/apps/mq/ibmmq/mqi/mode/channels.pm create mode 100644 centreon-plugins/apps/mq/ibmmq/mqi/mode/listqueues.pm create mode 100644 centreon-plugins/apps/mq/ibmmq/mqi/mode/queuemanager.pm create mode 100644 centreon-plugins/apps/mq/ibmmq/mqi/mode/queues.pm create mode 100644 centreon-plugins/apps/mq/ibmmq/mqi/plugin.pm diff --git a/centreon-plugins/apps/mq/ibmmq/mqi/custom/api.pm b/centreon-plugins/apps/mq/ibmmq/mqi/custom/api.pm new file mode 100644 index 000000000..2451bc741 --- /dev/null +++ b/centreon-plugins/apps/mq/ibmmq/mqi/custom/api.pm @@ -0,0 +1,222 @@ +# +# 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::ibmmq::mqi::custom::api; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; +use centreon::plugins::misc; + +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 => { + 'hostname:s' => { name => 'hostname' }, + 'port:s' => { name => 'port' }, + 'channel:s' => { name => 'channel' }, + 'timeout:s' => { name => 'timeout' } + }); + } + $options{options}->add_help(package => __PACKAGE__, sections => 'CUSTOM MQI OPTIONS', once => 1); + + $self->{output} = $options{output}; + $self->{mode} = $options{mode}; + + centreon::plugins::misc::mymodule_load( + output => $self->{output}, + module => 'MQSeries::QueueManager', + error_msg => "Cannot load module 'MQSeries::QueueManager'." + ); + centreon::plugins::misc::mymodule_load( + output => $self->{output}, + module => 'MQSeries::Command', + error_msg => "Cannot load module 'MQSeries::Command'." + ); + + $self->{connected} = 0; + 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->{channel} = (defined($self->{option_results}->{channel})) ? $self->{option_results}->{channel} : ''; + $self->{port} = (defined($self->{option_results}->{port})) && $self->{option_results}->{port} =~ /(\d+)/ ? $1 : 1414; + $self->{timeout} = (defined($self->{option_results}->{timeout})) && $self->{option_results}->{timeout} =~ /(\d+)/ ? $1 : 30; + + if ($self->{hostname} eq '') { + $self->{output}->add_option_msg(short_msg => 'Need to specify --hostname option.'); + $self->{output}->option_exit(); + } + if ($self->{channel} eq '') { + $self->{output}->add_option_msg(short_msg => 'Need to specify --channel option.'); + $self->{output}->option_exit(); + } + + return 0; +} + +sub get_hostname { + my ($self, %options) = @_; + + return $self->{hostname}; +} + +sub get_port { + my ($self, %options) = @_; + + return $self->{port}; +} + +sub get_qmgr_name { + my ($self, %options) = @_; + + return $self->{qmgr_name}; +} + +sub my_logger {} + +sub connect { + my ($self, %options) = @_; + + return if ($self->{connected} == 1); + + my $reason; + $self->{qmgr} = MQSeries::QueueManager->new( + QueueManager => '', + ConnectTimeout => $self->{timeout}, + Carp => \&my_logger, + Reason => \$reason, + ClientConn => { + 'ChannelName' => $self->{channel}, + 'TransportType' => 'TCP', + 'ConnectionName' => $self->{hostname} . '(' . $self->{port} . ')', + 'MaxMsgLength' => 16 * 1024 * 1024 + } + ); + if (!$self->{qmgr}) { + $self->{output}->add_option_msg(short_msg => 'unable to connect to the queue manager: ' . MQSeries::MQReasonToText($reason)); + $self->{output}->option_exit(); + } + + $self->{mq_command} = MQSeries::Command->new(QueueManager => $self->{qmgr}, CommandVersion => eval('MQSeries::MQCFH_VERSION_3')); + if (!$self->{mq_command}) { + $self->{output}->add_option_msg(short_msg => 'unable to instantiate command object'); + $self->{output}->option_exit(); + } + + $self->{connected} = 1; + + my @results = $self->execute_command(command => 'InquireQueueManager', attrs => { QAttrs => ['QMgrName'] }); + $self->{qmgr_name} = $results[0]->{QMgrName}; +} + +sub execute_command { + my ($self, %options) = @_; + + $self->connect(); + + my @results; + my $method = $self->{mq_command}->can($options{command}); + if ($method) { + @results = $self->{mq_command}->$method(%{$options{attrs}}); + if (!@results) { + $self->{output}->add_option_msg(short_msg => "method '$options{command}' issue: " . $self->{mq_command}->ReasonText()); + $self->{output}->option_exit(); + } + } + + return @results; +} + +1; + +__END__ + +=head1 NAME + +IBM MQ MQI + +=head1 CUSTOM MQI OPTIONS + +IBM MQ MQI + +=over 8 + +=item B<--hostname> + +Hostname or IP address. + +=item B<--port> + +Port used (Default: 1414) + +=item B<--channel> + +Channel name. + +=item B<--timeout> + +Set timeout in seconds (Default: 30). + +=back + +=head1 DESCRIPTION + +B. + +=cut diff --git a/centreon-plugins/apps/mq/ibmmq/mqi/mode/channels.pm b/centreon-plugins/apps/mq/ibmmq/mqi/mode/channels.pm new file mode 100644 index 000000000..39c8f2df9 --- /dev/null +++ b/centreon-plugins/apps/mq/ibmmq/mqi/mode/channels.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::ibmmq::mqi::mode::channels; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return "state: '" . $self->{result_values}->{state} . "'"; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'channel', type => 1, cb_prefix_output => 'prefix_channel_output', message_multiple => 'All channels are ok', skipped_code => { -10 => 1 } }, + ]; + + $self->{maps_counters}->{channel} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'state' }, { 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, + } + }, + { label => 'queue-msg', nlabel => 'queue.messages.count', set => { + key_values => [ { name => 'queue_messages' }, { name => 'display' } ], + output_template => 'current queue messages : %s', + perfdatas => [ + { label => 'queue_msg', value => 'queue_messages_absolute', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'queue-msg-ready', nlabel => 'queue.messages.ready.count', set => { + key_values => [ { name => 'queue_messages_ready' }, { name => 'display' } ], + output_template => 'current queue messages ready : %s', + perfdatas => [ + { label => 'queue_msg_ready', value => 'queue_messages_ready_absolute', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +sub prefix_channel_output { + my ($self, %options) = @_; + + return "Channel '" . $options{instance_value}->{display} . "' "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{state} ne "running"' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['warning_status', 'critical_status']); +} + +sub manage_selection { + my ($self, %options) = @_; + + my $result = $options{custom}->execute_command( + command => 'InquireChannelStatus', + attrs => { QAttrs => 'All' } + ); + use Data::Dumper; print Data::Dumper::Dumper($result); + exit(1); + + + $self->{channel} = {}; + foreach (@$result) { + my $name = $_->{vhost} . ':' . $_->{name}; + next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' + && $_->{name} !~ /$self->{option_results}->{filter_name}/); + + $self->{channel}->{$name} = { + display => $name, + queue_messages_ready => $_->{messages_ready}, + queue_messages => $_->{messages}, + state => $_->{state}, + }; + } + + if (scalar(keys %{$self->{channel}}) <= 0) { + $self->{output}->add_option_msg(short_msg => 'No channel found'); + $self->{output}->option_exit(); + } + + $self->{cache_name} = "ibmmq_" . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . $options{custom}->get_port() . '_' . + (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check channels. + +=over 8 + +=item B<--filter-name> + +Filter channel name (Can use regexp). + +=item B<--warning-status> + +Set warning threshold for status (Default: ''). +Can used special variables like: %{state}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{state} ne "running"'). +Can used special variables like: %{state}, %{display} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'queue-msg', 'queue-msg-ready'. + +=back + +=cut diff --git a/centreon-plugins/apps/mq/ibmmq/mqi/mode/listqueues.pm b/centreon-plugins/apps/mq/ibmmq/mqi/mode/listqueues.pm new file mode 100644 index 000000000..c8ae7f557 --- /dev/null +++ b/centreon-plugins/apps/mq/ibmmq/mqi/mode/listqueues.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::rabbitmq::restapi::mode::listqueues; + +use base qw(centreon::plugins::mode); + +use strict; +use warnings; + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options); + bless $self, $class; + + $options{options}->add_options(arguments => {}); + + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::init(%options); +} + +sub manage_selection { + my ($self, %options) = @_; + + my $result = $options{custom}->query(url_path => '/api/queues/?columns=vhost,name,state'); + $self->{queue} = {}; + foreach (@$result) { + $self->{queue}->{$_->{vhost} . ':' . $_->{name}} = { + vhost => $_->{vhost}, + name => $_->{name}, + state => $_->{state}, + }; + } +} + +sub run { + my ($self, %options) = @_; + + $self->manage_selection(%options); + foreach (sort keys %{$self->{queue}}) { + $self->{output}->output_add(long_msg => sprintf( + "[name = %s][vhost = %s][state = %s]", + $self->{queue}->{$_}->{name}, $self->{queue}->{$_}->{vhost}, $self->{queue}->{$_}->{state}) + ); + } + $self->{output}->output_add( + severity => 'OK', + short_msg => 'List queues:' + ); + + $self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1); + $self->{output}->exit(); +} + +sub disco_format { + my ($self, %options) = @_; + + $self->{output}->add_disco_format(elements => ['name', 'vhost', 'state']); +} + +sub disco_show { + my ($self, %options) = @_; + + $self->manage_selection(%options); + foreach (values %{$self->{queue}}) { + $self->{output}->add_disco_entry(%$_); + } +} + +1; + +__END__ + +=head1 MODE + +List queues. + +=over 8 + +=back + +=cut diff --git a/centreon-plugins/apps/mq/ibmmq/mqi/mode/queuemanager.pm b/centreon-plugins/apps/mq/ibmmq/mqi/mode/queuemanager.pm new file mode 100644 index 000000000..c84790785 --- /dev/null +++ b/centreon-plugins/apps/mq/ibmmq/mqi/mode/queuemanager.pm @@ -0,0 +1,123 @@ +# +# 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::ibmmq::mqi::mode::queuemanager; + +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 set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'qmgr', type => 0, prefix_output => 'prefix_qmgr_output', skipped_code => { -10 => 1 } }, + ]; + + $self->{maps_counters}->{vhost} = [ + { 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 prefix_qmgr_output { + my ($self, %options) = @_; + + return "Queue manager '" . $options{instance_value}->{display} . "' "; +} + +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 => { + 'unknown-status:s' => { name => 'unknown_status', default => '' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{status} ne "ok"' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']); +} + +sub manage_selection { + my ($self, %options) = @_; + + my $result = $options{custom}->execute_command( + command => 'InquireQueueManagerStatus', + attrs => { QAttrs => 'All' } + ); + use Data::Dumper; + print Data::Dumper::Dumper($result); +} + +1; + +__END__ + +=head1 MODE + +Check queue manager. + +=over 8 + +=item B<--unknown-status> + +Set unknown threshold for status (Default: ''). +Can used special variables like: %{status} + +=item B<--warning-status> + +Set warning threshold for status (Default: ''). +Can used special variables like: %{status} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{status} ne "ok"'). +Can used special variables like: %{status} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'queue-msg-ready', 'queue-msg'. + +=back + +=cut diff --git a/centreon-plugins/apps/mq/ibmmq/mqi/mode/queues.pm b/centreon-plugins/apps/mq/ibmmq/mqi/mode/queues.pm new file mode 100644 index 000000000..8baddf78b --- /dev/null +++ b/centreon-plugins/apps/mq/ibmmq/mqi/mode/queues.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::ibmmq::mqi::mode::queues; + +use base qw(centreon::plugins::templates::counter); + +use strict; +use warnings; +use Digest::MD5 qw(md5_hex); +use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc); + +sub custom_status_output { + my ($self, %options) = @_; + + return "state: '" . $self->{result_values}->{state} . "'"; +} + +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'queue', type => 1, cb_prefix_output => 'prefix_queue_output', message_multiple => 'All queues are ok', skipped_code => { -10 => 1 } }, + ]; + + $self->{maps_counters}->{queue} = [ + { label => 'status', threshold => 0, set => { + key_values => [ { name => 'state' }, { 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, + } + }, + { label => 'queue-msg', nlabel => 'queue.messages.count', set => { + key_values => [ { name => 'queue_messages' }, { name => 'display' } ], + output_template => 'current queue messages : %s', + perfdatas => [ + { label => 'queue_msg', value => 'queue_messages_absolute', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + { label => 'queue-msg-ready', nlabel => 'queue.messages.ready.count', set => { + key_values => [ { name => 'queue_messages_ready' }, { name => 'display' } ], + output_template => 'current queue messages ready : %s', + perfdatas => [ + { label => 'queue_msg_ready', value => 'queue_messages_ready_absolute', template => '%d', + min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }, + ], + } + }, + ]; +} + +sub prefix_queue_output { + my ($self, %options) = @_; + + return "Queue '" . $options{instance_value}->{display} . "' "; +} + +sub new { + my ($class, %options) = @_; + my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1); + bless $self, $class; + + $options{options}->add_options(arguments => { + 'filter-name:s' => { name => 'filter_name' }, + 'warning-status:s' => { name => 'warning_status', default => '' }, + 'critical-status:s' => { name => 'critical_status', default => '%{state} ne "running"' }, + }); + return $self; +} + +sub check_options { + my ($self, %options) = @_; + $self->SUPER::check_options(%options); + + $self->change_macros(macros => ['warning_status', 'critical_status']); +} + +sub manage_selection { + my ($self, %options) = @_; + + my $result = $options{custom}->execute_command( + command => 'InquireQueueStatus', + attrs => { QAttrs => 'All' } + ); + use Data::Dumper; print Data::Dumper::Dumper($result); + exit(1); + + + $self->{queue} = {}; + foreach (@$result) { + my $name = $_->{vhost} . ':' . $_->{name}; + next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' + && $_->{name} !~ /$self->{option_results}->{filter_name}/); + + $self->{queue}->{$name} = { + display => $name, + queue_messages_ready => $_->{messages_ready}, + queue_messages => $_->{messages}, + state => $_->{state}, + }; + } + + if (scalar(keys %{$self->{queue}}) <= 0) { + $self->{output}->add_option_msg(short_msg => 'No queue found'); + $self->{output}->option_exit(); + } + + $self->{cache_name} = "ibmmq_" . $self->{mode} . '_' . $options{custom}->get_hostname() . '_' . $options{custom}->get_port() . '_' . + (defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')) . '_' . + (defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')); +} + +1; + +__END__ + +=head1 MODE + +Check queues. + +=over 8 + +=item B<--filter-name> + +Filter queue name (Can use regexp). + +=item B<--warning-status> + +Set warning threshold for status (Default: ''). +Can used special variables like: %{state}, %{display} + +=item B<--critical-status> + +Set critical threshold for status (Default: '%{state} ne "running"'). +Can used special variables like: %{state}, %{display} + +=item B<--warning-*> B<--critical-*> + +Thresholds. +Can be: 'queue-msg', 'queue-msg-ready'. + +=back + +=cut diff --git a/centreon-plugins/apps/mq/ibmmq/mqi/plugin.pm b/centreon-plugins/apps/mq/ibmmq/mqi/plugin.pm new file mode 100644 index 000000000..a93e3b3b8 --- /dev/null +++ b/centreon-plugins/apps/mq/ibmmq/mqi/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::ibmmq::mqi::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} = '1.0'; + %{$self->{modes}} = ( + 'channels' => 'apps::mq::ibmmq::mqi::mode::channels', + 'list-queues' => 'apps::mq::ibmmq::mqi::mode::listqueues', + 'queues' => 'apps::mq::ibmmq::mqi::mode::queues', + 'queue-manager' => 'apps::mq::ibmmq::mqi::mode::queuemanager' + ); + + $self->{custom_modes}{api} = 'apps::mq::ibmmq::mqi::custom::api'; + return $self; +} + +1; + +__END__ + +=head1 PLUGIN DESCRIPTION + +Check IBM MQ using middleware product API (work for version <= 7.5) + +=cut