initial release ibm mq series mqi
This commit is contained in:
parent
c7d7e99fe5
commit
e4f691d32e
|
@ -161,8 +161,8 @@ sub connect {
|
|||
|
||||
$self->{connected} = 1;
|
||||
|
||||
my @results = $self->execute_command(command => 'InquireQueueManager');
|
||||
$self->{qmgr_name} = $results[0]->{QMgrName};
|
||||
my $results = $self->execute_command(command => 'InquireQueueManager');
|
||||
$self->{qmgr_name} = $results->[0]->{QMgrName};
|
||||
}
|
||||
|
||||
sub execute_command {
|
||||
|
@ -185,7 +185,7 @@ sub execute_command {
|
|||
$self->{output}->option_exit();
|
||||
}
|
||||
|
||||
return @results;
|
||||
return \@results;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -30,7 +30,43 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold
|
|||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "state: '" . $self->{result_values}->{state} . "'";
|
||||
return sprintf(
|
||||
'status: %s [message channel agent: %s]',
|
||||
$self->{result_values}->{channel_status},
|
||||
$self->{result_values}->{mca_status}
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_traffic_in_perfdata {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel}, unit => 'b/s',
|
||||
instances => [$self->{result_values}->{qmgr_name_absolute}, $self->{result_values}->{channel_name_absolute}],
|
||||
value => $self->{result_values}->{traffic_in_per_second},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_traffic_out_perfdata {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel}, unit => 'b/s',
|
||||
instances => [$self->{result_values}->{qmgr_name_absolute}, $self->{result_values}->{channel_name_absolute}],
|
||||
value => $self->{result_values}->{traffic_out_per_second},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_channel_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Channel '" . $options{instance_value}->{qmgr_name} . ':' . $options{instance_value}->{channel_name} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
|
@ -42,49 +78,42 @@ sub set_counters {
|
|||
|
||||
$self->{maps_counters}->{channel} = [
|
||||
{ label => 'status', threshold => 0, set => {
|
||||
key_values => [ { name => 'state' }, { name => 'display' } ],
|
||||
key_values => [
|
||||
{ name => 'qmgr_name' }, { name => 'channel_name' },
|
||||
{ name => 'channel_status' }, { name => 'mca_status' }
|
||||
],
|
||||
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,
|
||||
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 => 'traffic-in', nlabel => 'channel.traffic.in.bitspersecond', set => {
|
||||
key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'qmgr_name' }, { name => 'channel_name' } ],
|
||||
output_template => 'traffic in: %s %s/s',
|
||||
per_second => 1, output_change_bytes => 2,
|
||||
closure_custom_perfdata => $self->can('custom_traffic_in_perfdata')
|
||||
}
|
||||
},
|
||||
{ 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' },
|
||||
],
|
||||
{ label => 'traffic-out', nlabel => 'channel.traffic.out.bitspersecond', set => {
|
||||
key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'qmgr_name' }, { name => 'channel_name' } ],
|
||||
output_template => 'traffic out: %s %s/s',
|
||||
per_second => 1, output_change_bytes => 2,
|
||||
closure_custom_perfdata => $self->can('custom_traffic_out_perfdata')
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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' },
|
||||
'unknown-status:s' => { name => 'unknown_status', default => '' },
|
||||
'warning-status:s' => { name => 'warning_status', default => '' },
|
||||
'critical-status:s' => { name => 'critical_status', default => '%{state} ne "running"' },
|
||||
'critical-status:s' => { name => 'critical_status', default => '%{channel_status} !~ /running/i' },
|
||||
});
|
||||
return $self;
|
||||
}
|
||||
|
@ -93,7 +122,7 @@ sub check_options {
|
|||
my ($self, %options) = @_;
|
||||
$self->SUPER::check_options(%options);
|
||||
|
||||
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
||||
$self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']);
|
||||
}
|
||||
|
||||
sub manage_selection {
|
||||
|
@ -103,31 +132,20 @@ sub manage_selection {
|
|||
command => 'InquireChannelStatus',
|
||||
attrs => { }
|
||||
);
|
||||
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},
|
||||
$self->{channel}->{$_->{ChannelName}} = {
|
||||
qmgr_name => $options{custom}->get_qmgr_name(),
|
||||
channel_name => $_->{ChannelName},
|
||||
channel_status => lc($_->{ChannelStatus}),
|
||||
mca_status => lc($_->{MCAStatus}),
|
||||
traffic_in => $_->{BytesReceived} * 8,
|
||||
traffic_out => $_->{BytesSent} * 8
|
||||
};
|
||||
}
|
||||
|
||||
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'));
|
||||
}
|
||||
|
||||
|
@ -141,24 +159,25 @@ Check channels.
|
|||
|
||||
=over 8
|
||||
|
||||
=item B<--filter-name>
|
||||
=item B<--unknown-status>
|
||||
|
||||
Filter channel name (Can use regexp).
|
||||
Set unknown threshold for status (Default: '').
|
||||
Can used special variables like: %{channel_status}, %{mca_status}
|
||||
|
||||
=item B<--warning-status>
|
||||
|
||||
Set warning threshold for status (Default: '').
|
||||
Can used special variables like: %{state}, %{display}
|
||||
Can used special variables like: %{channel_status}, %{mca_status}
|
||||
|
||||
=item B<--critical-status>
|
||||
|
||||
Set critical threshold for status (Default: '%{state} ne "running"').
|
||||
Can used special variables like: %{state}, %{display}
|
||||
Set critical threshold for status (Default: '%{channel_status} !~ /running/i').
|
||||
Can used special variables like: %{channel_status}, %{mca_status}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'queue-msg', 'queue-msg-ready'.
|
||||
Can be: 'traffic-in', 'traffic-out'.
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
package apps::mq::rabbitmq::restapi::mode::listqueues;
|
||||
package apps::mq::ibmmq::mqi::mode::listqueues;
|
||||
|
||||
use base qw(centreon::plugins::mode);
|
||||
|
||||
|
@ -42,14 +42,16 @@ sub check_options {
|
|||
|
||||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $result = $options{custom}->query(url_path => '/api/queues/?columns=vhost,name,state');
|
||||
|
||||
my $result = $options{custom}->execute_command(
|
||||
command => 'InquireQueueStatus',
|
||||
attrs => { QStatusAttrs => ['QName'] }
|
||||
);
|
||||
|
||||
$self->{queue} = {};
|
||||
foreach (@$result) {
|
||||
$self->{queue}->{$_->{vhost} . ':' . $_->{name}} = {
|
||||
vhost => $_->{vhost},
|
||||
name => $_->{name},
|
||||
state => $_->{state},
|
||||
$self->{queue}->{$_->{QName}} = {
|
||||
name => $_->{QName}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -59,9 +61,11 @@ sub run {
|
|||
|
||||
$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(long_msg =>
|
||||
sprintf(
|
||||
'[name = %s]',
|
||||
$self->{queue}->{$_}->{name}
|
||||
)
|
||||
);
|
||||
}
|
||||
$self->{output}->output_add(
|
||||
|
@ -76,7 +80,7 @@ sub run {
|
|||
sub disco_format {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->add_disco_format(elements => ['name', 'vhost', 'state']);
|
||||
$self->{output}->add_disco_format(elements => ['name']);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
|
|
|
@ -29,26 +29,25 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold
|
|||
sub custom_status_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'status: ' . $self->{result_values}->{status};
|
||||
return sprintf(
|
||||
'status: %s [command server: %s] [channel initiator: %s]',
|
||||
$self->{result_values}->{mgr_status},
|
||||
$self->{result_values}->{command_server_status},
|
||||
$self->{result_values}->{channel_initiator_status}
|
||||
);
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
sub custom_connections_perfdata {
|
||||
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,
|
||||
}
|
||||
}
|
||||
];
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
instances => $self->{result_values}->{display_absolute},
|
||||
value => $self->{result_values}->{connection_count_absolute},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_qmgr_output {
|
||||
|
@ -57,6 +56,34 @@ sub prefix_qmgr_output {
|
|||
return "Queue manager '" . $options{instance_value}->{display} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{maps_counters_type} = [
|
||||
{ name => 'qmgr', type => 0, cb_prefix_output => 'prefix_qmgr_output', skipped_code => { -10 => 1 } }
|
||||
];
|
||||
|
||||
$self->{maps_counters}->{qmgr} = [
|
||||
{ label => 'status', threshold => 0, set => {
|
||||
key_values => [
|
||||
{ name => 'mgr_status' }, { name => 'channel_initiator_status' },
|
||||
{ name => 'command_server_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
|
||||
}
|
||||
},
|
||||
{ label => 'connections', nlabel => 'queuemanager.connections.count', set => {
|
||||
key_values => [ { name => 'connection_count' }, { name => 'display' } ],
|
||||
output_template => 'current number of connections: %s',
|
||||
closure_custom_perfdata => $self->can('custom_connections_perfdata')
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||
|
@ -65,8 +92,9 @@ sub new {
|
|||
$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"' },
|
||||
'critical-status:s' => { name => 'critical_status', default => '%{mgr_status} !~ /running/i' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -84,8 +112,14 @@ sub manage_selection {
|
|||
command => 'InquireQueueManagerStatus',
|
||||
attrs => { }
|
||||
);
|
||||
use Data::Dumper;
|
||||
print Data::Dumper::Dumper($result);
|
||||
|
||||
$self->{qmgr} = {
|
||||
display => $options{custom}->get_qmgr_name(),
|
||||
channel_initiator_status => lc($result->[0]->{ChannelInitiatorStatus}),
|
||||
mgr_status => lc($result->[0]->{QMgrStatus}),
|
||||
command_server_status => lc($result->[0]->{CommandServerStatus}),
|
||||
connection_count => $result->[0]->{ConnectionCount}
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -101,22 +135,22 @@ Check queue manager.
|
|||
=item B<--unknown-status>
|
||||
|
||||
Set unknown threshold for status (Default: '').
|
||||
Can used special variables like: %{status}
|
||||
Can used special variables like: %{mgr_status}, %{channel_initiator_status}, %{command_server_status}
|
||||
|
||||
=item B<--warning-status>
|
||||
|
||||
Set warning threshold for status (Default: '').
|
||||
Can used special variables like: %{status}
|
||||
Can used special variables like: %{mgr_status}, %{channel_initiator_status}, %{command_server_status}
|
||||
|
||||
=item B<--critical-status>
|
||||
|
||||
Set critical threshold for status (Default: '%{status} ne "ok"').
|
||||
Can used special variables like: %{status}
|
||||
Set critical threshold for status (Default: '%{mgr_status} !~ /running/i').
|
||||
Can used special variables like: %{mgr_status}, %{channel_initiator_status}, %{command_server_status}
|
||||
|
||||
=item B<--warning-*> B<--critical-*>
|
||||
|
||||
Thresholds.
|
||||
Can be: 'queue-msg-ready', 'queue-msg'.
|
||||
Can be: 'connections'.
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -24,13 +24,60 @@ 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);
|
||||
use centreon::plugins::misc;
|
||||
|
||||
sub custom_status_output {
|
||||
sub custom_oldest_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "state: '" . $self->{result_values}->{state} . "'";
|
||||
return sprintf(
|
||||
'oldest message: %s',
|
||||
centreon::plugins::misc::change_seconds(value => $self->{result_values}->{oldest_msg_age_absolute})
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_connections_perfdata {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
instances => [$self->{result_values}->{qmgr_name_absolute}, $self->{result_values}->{queue_name_absolute}],
|
||||
value => $self->{result_values}->{open_input_count_absolute},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_qdepth_perfdata {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
instances => [$self->{result_values}->{qmgr_name_absolute}, $self->{result_values}->{queue_name_absolute}],
|
||||
value => $self->{result_values}->{current_qdepth_absolute},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_oldest_perfdata {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
nlabel => $self->{nlabel},
|
||||
instances => [$self->{result_values}->{qmgr_name_absolute}, $self->{result_values}->{queue_name_absolute}],
|
||||
value => $self->{result_values}->{oldest_msg_age_absolute},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
|
||||
sub prefix_queue_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return "Queue '" . $options{instance_value}->{qmgr_name} . ':' . $options{instance_value}->{queue_name} . "' ";
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
|
@ -41,61 +88,38 @@ sub set_counters {
|
|||
];
|
||||
|
||||
$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 => 'connections-input', nlabel => 'queue.connections.input.count', set => {
|
||||
key_values => [ { name => 'open_input_count' }, { name => 'qmgr_name' }, { name => 'queue_name' } ],
|
||||
output_template => 'current input connections: %s',
|
||||
closure_custom_perfdata => $self->can('custom_connections_perfdata')
|
||||
}
|
||||
},
|
||||
{ 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 => 'messages-depth', nlabel => 'queue.messages.depth.count', set => {
|
||||
key_values => [ { name => 'current_qdepth' }, { name => 'qmgr_name' }, { name => 'queue_name' } ],
|
||||
output_template => 'current messages depth: %s',
|
||||
closure_custom_perfdata => $self->can('custom_qdepth_perfdata')
|
||||
}
|
||||
},
|
||||
{ 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' },
|
||||
],
|
||||
{ label => 'message-oldest', nlabel => 'queue.message.oldest.seconds', set => {
|
||||
key_values => [ { name => 'oldest_msg_age' }, { name => 'qmgr_name' }, { name => 'queue_name' } ],
|
||||
closure_custom_output => $self->can('custom_oldest_output'),
|
||||
closure_custom_perfdata => $self->can('custom_oldest_perfdata')
|
||||
}
|
||||
},
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
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);
|
||||
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' },
|
||||
'warning-status:s' => { name => 'warning_status', default => '' },
|
||||
'critical-status:s' => { name => 'critical_status', default => '%{state} ne "running"' },
|
||||
'filter-name:s' => { name => 'filter_name' }
|
||||
});
|
||||
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) = @_;
|
||||
|
||||
|
@ -103,21 +127,18 @@ sub manage_selection {
|
|||
command => 'InquireQueueStatus',
|
||||
attrs => { QStatusAttrs => ['QName', 'CurrentQDepth', 'OpenInputCount', 'OldestMsgAge'] }
|
||||
);
|
||||
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}/);
|
||||
&& $_->{QName} !~ /$self->{option_results}->{filter_name}/);
|
||||
|
||||
$self->{queue}->{$name} = {
|
||||
display => $name,
|
||||
queue_messages_ready => $_->{messages_ready},
|
||||
queue_messages => $_->{messages},
|
||||
state => $_->{state},
|
||||
$self->{queue}->{$_->{QName}} = {
|
||||
qmgr_name => $options{custom}->get_qmgr_name(),
|
||||
queue_name => $_->{QName},
|
||||
open_input_count => $_->{OpenInputCount},
|
||||
current_qdepth => $_->{CurrentQDepth},
|
||||
oldest_msg_age => $_->{OldestMsgAge} # in seconds
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -125,10 +146,6 @@ sub manage_selection {
|
|||
$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;
|
||||
|
@ -145,20 +162,10 @@ Check queues.
|
|||
|
||||
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'.
|
||||
Can be: 'connections-input', 'messages-depth', 'message-oldest'.
|
||||
|
||||
=back
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ sub new {
|
|||
'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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue