mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-28 08:04:36 +02:00
initial release ibm mq series mqi
This commit is contained in:
parent
c7d7e99fe5
commit
e4f691d32e
@ -161,8 +161,8 @@ sub connect {
|
|||||||
|
|
||||||
$self->{connected} = 1;
|
$self->{connected} = 1;
|
||||||
|
|
||||||
my @results = $self->execute_command(command => 'InquireQueueManager');
|
my $results = $self->execute_command(command => 'InquireQueueManager');
|
||||||
$self->{qmgr_name} = $results[0]->{QMgrName};
|
$self->{qmgr_name} = $results->[0]->{QMgrName};
|
||||||
}
|
}
|
||||||
|
|
||||||
sub execute_command {
|
sub execute_command {
|
||||||
@ -185,7 +185,7 @@ sub execute_command {
|
|||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
return @results;
|
return \@results;
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -30,7 +30,43 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold
|
|||||||
sub custom_status_output {
|
sub custom_status_output {
|
||||||
my ($self, %options) = @_;
|
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 {
|
sub set_counters {
|
||||||
@ -42,49 +78,42 @@ sub set_counters {
|
|||||||
|
|
||||||
$self->{maps_counters}->{channel} = [
|
$self->{maps_counters}->{channel} = [
|
||||||
{ label => 'status', threshold => 0, set => {
|
{ 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_calc => \&catalog_status_calc,
|
||||||
closure_custom_output => $self->can('custom_status_output'),
|
closure_custom_output => $self->can('custom_status_output'),
|
||||||
closure_custom_perfdata => sub { return 0; },
|
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 => {
|
{ label => 'traffic-in', nlabel => 'channel.traffic.in.bitspersecond', set => {
|
||||||
key_values => [ { name => 'queue_messages' }, { name => 'display' } ],
|
key_values => [ { name => 'traffic_in', diff => 1 }, { name => 'qmgr_name' }, { name => 'channel_name' } ],
|
||||||
output_template => 'current queue messages : %s',
|
output_template => 'traffic in: %s %s/s',
|
||||||
perfdatas => [
|
per_second => 1, output_change_bytes => 2,
|
||||||
{ label => 'queue_msg', value => 'queue_messages_absolute', template => '%d',
|
closure_custom_perfdata => $self->can('custom_traffic_in_perfdata')
|
||||||
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'queue-msg-ready', nlabel => 'queue.messages.ready.count', set => {
|
{ label => 'traffic-out', nlabel => 'channel.traffic.out.bitspersecond', set => {
|
||||||
key_values => [ { name => 'queue_messages_ready' }, { name => 'display' } ],
|
key_values => [ { name => 'traffic_out', diff => 1 }, { name => 'qmgr_name' }, { name => 'channel_name' } ],
|
||||||
output_template => 'current queue messages ready : %s',
|
output_template => 'traffic out: %s %s/s',
|
||||||
perfdatas => [
|
per_second => 1, output_change_bytes => 2,
|
||||||
{ label => 'queue_msg_ready', value => 'queue_messages_ready_absolute', template => '%d',
|
closure_custom_perfdata => $self->can('custom_traffic_out_perfdata')
|
||||||
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 {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
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, statefile => 1, force_new_perfdata => 1);
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$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 => '' },
|
'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;
|
return $self;
|
||||||
}
|
}
|
||||||
@ -93,7 +122,7 @@ sub check_options {
|
|||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
$self->SUPER::check_options(%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 {
|
sub manage_selection {
|
||||||
@ -103,31 +132,20 @@ sub manage_selection {
|
|||||||
command => 'InquireChannelStatus',
|
command => 'InquireChannelStatus',
|
||||||
attrs => { }
|
attrs => { }
|
||||||
);
|
);
|
||||||
use Data::Dumper; print Data::Dumper::Dumper($result);
|
|
||||||
exit(1);
|
|
||||||
|
|
||||||
|
|
||||||
$self->{channel} = {};
|
$self->{channel} = {};
|
||||||
foreach (@$result) {
|
foreach (@$result) {
|
||||||
my $name = $_->{vhost} . ':' . $_->{name};
|
$self->{channel}->{$_->{ChannelName}} = {
|
||||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne ''
|
qmgr_name => $options{custom}->get_qmgr_name(),
|
||||||
&& $_->{name} !~ /$self->{option_results}->{filter_name}/);
|
channel_name => $_->{ChannelName},
|
||||||
|
channel_status => lc($_->{ChannelStatus}),
|
||||||
$self->{channel}->{$name} = {
|
mca_status => lc($_->{MCAStatus}),
|
||||||
display => $name,
|
traffic_in => $_->{BytesReceived} * 8,
|
||||||
queue_messages_ready => $_->{messages_ready},
|
traffic_out => $_->{BytesSent} * 8
|
||||||
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() . '_' .
|
$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'));
|
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,24 +159,25 @@ Check channels.
|
|||||||
|
|
||||||
=over 8
|
=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>
|
=item B<--warning-status>
|
||||||
|
|
||||||
Set warning threshold for status (Default: '').
|
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>
|
=item B<--critical-status>
|
||||||
|
|
||||||
Set critical threshold for status (Default: '%{state} ne "running"').
|
Set critical threshold for status (Default: '%{channel_status} !~ /running/i').
|
||||||
Can used special variables like: %{state}, %{display}
|
Can used special variables like: %{channel_status}, %{mca_status}
|
||||||
|
|
||||||
=item B<--warning-*> B<--critical-*>
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
Thresholds.
|
Thresholds.
|
||||||
Can be: 'queue-msg', 'queue-msg-ready'.
|
Can be: 'traffic-in', 'traffic-out'.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
package apps::mq::rabbitmq::restapi::mode::listqueues;
|
package apps::mq::ibmmq::mqi::mode::listqueues;
|
||||||
|
|
||||||
use base qw(centreon::plugins::mode);
|
use base qw(centreon::plugins::mode);
|
||||||
|
|
||||||
@ -42,14 +42,16 @@ sub check_options {
|
|||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
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} = {};
|
$self->{queue} = {};
|
||||||
foreach (@$result) {
|
foreach (@$result) {
|
||||||
$self->{queue}->{$_->{vhost} . ':' . $_->{name}} = {
|
$self->{queue}->{$_->{QName}} = {
|
||||||
vhost => $_->{vhost},
|
name => $_->{QName}
|
||||||
name => $_->{name},
|
|
||||||
state => $_->{state},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -59,9 +61,11 @@ sub run {
|
|||||||
|
|
||||||
$self->manage_selection(%options);
|
$self->manage_selection(%options);
|
||||||
foreach (sort keys %{$self->{queue}}) {
|
foreach (sort keys %{$self->{queue}}) {
|
||||||
$self->{output}->output_add(long_msg => sprintf(
|
$self->{output}->output_add(long_msg =>
|
||||||
"[name = %s][vhost = %s][state = %s]",
|
sprintf(
|
||||||
$self->{queue}->{$_}->{name}, $self->{queue}->{$_}->{vhost}, $self->{queue}->{$_}->{state})
|
'[name = %s]',
|
||||||
|
$self->{queue}->{$_}->{name}
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$self->{output}->output_add(
|
$self->{output}->output_add(
|
||||||
@ -76,7 +80,7 @@ sub run {
|
|||||||
sub disco_format {
|
sub disco_format {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{output}->add_disco_format(elements => ['name', 'vhost', 'state']);
|
$self->{output}->add_disco_format(elements => ['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub disco_show {
|
sub disco_show {
|
||||||
|
@ -29,26 +29,25 @@ use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold
|
|||||||
sub custom_status_output {
|
sub custom_status_output {
|
||||||
my ($self, %options) = @_;
|
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) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{maps_counters_type} = [
|
$self->{output}->perfdata_add(
|
||||||
{ name => 'qmgr', type => 0, prefix_output => 'prefix_qmgr_output', skipped_code => { -10 => 1 } },
|
nlabel => $self->{nlabel},
|
||||||
];
|
instances => $self->{result_values}->{display_absolute},
|
||||||
|
value => $self->{result_values}->{connection_count_absolute},
|
||||||
$self->{maps_counters}->{vhost} = [
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
|
||||||
{ label => 'status', threshold => 0, set => {
|
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
|
||||||
key_values => [ { name => 'status' }, { name => 'display' } ],
|
min => 0
|
||||||
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 {
|
sub prefix_qmgr_output {
|
||||||
@ -57,6 +56,34 @@ sub prefix_qmgr_output {
|
|||||||
return "Queue manager '" . $options{instance_value}->{display} . "' ";
|
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 {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
|
||||||
@ -65,8 +92,9 @@ sub new {
|
|||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'unknown-status:s' => { name => 'unknown_status', default => '' },
|
'unknown-status:s' => { name => 'unknown_status', default => '' },
|
||||||
'warning-status:s' => { name => 'warning_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;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,8 +112,14 @@ sub manage_selection {
|
|||||||
command => 'InquireQueueManagerStatus',
|
command => 'InquireQueueManagerStatus',
|
||||||
attrs => { }
|
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;
|
1;
|
||||||
@ -101,22 +135,22 @@ Check queue manager.
|
|||||||
=item B<--unknown-status>
|
=item B<--unknown-status>
|
||||||
|
|
||||||
Set unknown threshold for status (Default: '').
|
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>
|
=item B<--warning-status>
|
||||||
|
|
||||||
Set warning threshold for status (Default: '').
|
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>
|
=item B<--critical-status>
|
||||||
|
|
||||||
Set critical threshold for status (Default: '%{status} ne "ok"').
|
Set critical threshold for status (Default: '%{mgr_status} !~ /running/i').
|
||||||
Can used special variables like: %{status}
|
Can used special variables like: %{mgr_status}, %{channel_initiator_status}, %{command_server_status}
|
||||||
|
|
||||||
=item B<--warning-*> B<--critical-*>
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
Thresholds.
|
Thresholds.
|
||||||
Can be: 'queue-msg-ready', 'queue-msg'.
|
Can be: 'connections'.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
@ -24,13 +24,60 @@ use base qw(centreon::plugins::templates::counter);
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Digest::MD5 qw(md5_hex);
|
use centreon::plugins::misc;
|
||||||
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold catalog_status_calc);
|
|
||||||
|
|
||||||
sub custom_status_output {
|
sub custom_oldest_output {
|
||||||
my ($self, %options) = @_;
|
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 {
|
sub set_counters {
|
||||||
@ -41,61 +88,38 @@ sub set_counters {
|
|||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{queue} = [
|
$self->{maps_counters}->{queue} = [
|
||||||
{ label => 'status', threshold => 0, set => {
|
{ label => 'connections-input', nlabel => 'queue.connections.input.count', set => {
|
||||||
key_values => [ { name => 'state' }, { name => 'display' } ],
|
key_values => [ { name => 'open_input_count' }, { name => 'qmgr_name' }, { name => 'queue_name' } ],
|
||||||
closure_custom_calc => \&catalog_status_calc,
|
output_template => 'current input connections: %s',
|
||||||
closure_custom_output => $self->can('custom_status_output'),
|
closure_custom_perfdata => $self->can('custom_connections_perfdata')
|
||||||
closure_custom_perfdata => sub { return 0; },
|
|
||||||
closure_custom_threshold_check => \&catalog_status_threshold,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'queue-msg', nlabel => 'queue.messages.count', set => {
|
{ label => 'messages-depth', nlabel => 'queue.messages.depth.count', set => {
|
||||||
key_values => [ { name => 'queue_messages' }, { name => 'display' } ],
|
key_values => [ { name => 'current_qdepth' }, { name => 'qmgr_name' }, { name => 'queue_name' } ],
|
||||||
output_template => 'current queue messages : %s',
|
output_template => 'current messages depth: %s',
|
||||||
perfdatas => [
|
closure_custom_perfdata => $self->can('custom_qdepth_perfdata')
|
||||||
{ 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 => {
|
{ label => 'message-oldest', nlabel => 'queue.message.oldest.seconds', set => {
|
||||||
key_values => [ { name => 'queue_messages_ready' }, { name => 'display' } ],
|
key_values => [ { name => 'oldest_msg_age' }, { name => 'qmgr_name' }, { name => 'queue_name' } ],
|
||||||
output_template => 'current queue messages ready : %s',
|
closure_custom_output => $self->can('custom_oldest_output'),
|
||||||
perfdatas => [
|
closure_custom_perfdata => $self->can('custom_oldest_perfdata')
|
||||||
{ 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 {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
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;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'filter-name:s' => { name => 'filter_name' },
|
'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;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_options {
|
|
||||||
my ($self, %options) = @_;
|
|
||||||
$self->SUPER::check_options(%options);
|
|
||||||
|
|
||||||
$self->change_macros(macros => ['warning_status', 'critical_status']);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
@ -103,21 +127,18 @@ sub manage_selection {
|
|||||||
command => 'InquireQueueStatus',
|
command => 'InquireQueueStatus',
|
||||||
attrs => { QStatusAttrs => ['QName', 'CurrentQDepth', 'OpenInputCount', 'OldestMsgAge'] }
|
attrs => { QStatusAttrs => ['QName', 'CurrentQDepth', 'OpenInputCount', 'OldestMsgAge'] }
|
||||||
);
|
);
|
||||||
use Data::Dumper; print Data::Dumper::Dumper($result);
|
|
||||||
exit(1);
|
|
||||||
|
|
||||||
|
|
||||||
$self->{queue} = {};
|
$self->{queue} = {};
|
||||||
foreach (@$result) {
|
foreach (@$result) {
|
||||||
my $name = $_->{vhost} . ':' . $_->{name};
|
|
||||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne ''
|
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} = {
|
$self->{queue}->{$_->{QName}} = {
|
||||||
display => $name,
|
qmgr_name => $options{custom}->get_qmgr_name(),
|
||||||
queue_messages_ready => $_->{messages_ready},
|
queue_name => $_->{QName},
|
||||||
queue_messages => $_->{messages},
|
open_input_count => $_->{OpenInputCount},
|
||||||
state => $_->{state},
|
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}->add_option_msg(short_msg => 'No queue found');
|
||||||
$self->{output}->option_exit();
|
$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;
|
1;
|
||||||
@ -145,20 +162,10 @@ Check queues.
|
|||||||
|
|
||||||
Filter queue name (Can use regexp).
|
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-*>
|
=item B<--warning-*> B<--critical-*>
|
||||||
|
|
||||||
Thresholds.
|
Thresholds.
|
||||||
Can be: 'queue-msg', 'queue-msg-ready'.
|
Can be: 'connections-input', 'messages-depth', 'message-oldest'.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ sub new {
|
|||||||
'queues' => 'apps::mq::ibmmq::mqi::mode::queues',
|
'queues' => 'apps::mq::ibmmq::mqi::mode::queues',
|
||||||
'queue-manager' => 'apps::mq::ibmmq::mqi::mode::queuemanager'
|
'queue-manager' => 'apps::mq::ibmmq::mqi::mode::queuemanager'
|
||||||
);
|
);
|
||||||
|
|
||||||
$self->{custom_modes}{api} = 'apps::mq::ibmmq::mqi::custom::api';
|
$self->{custom_modes}{api} = 'apps::mq::ibmmq::mqi::custom::api';
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user