mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-27 15:44:21 +02:00
(enh)plugin - add type filtering capability
This commit is contained in:
parent
ba1594b4ae
commit
87d0d06985
@ -178,8 +178,8 @@ sub execute_command {
|
|||||||
@results = $self->{mq_command}->InquireChannelStatus(%{$options{attrs}});
|
@results = $self->{mq_command}->InquireChannelStatus(%{$options{attrs}});
|
||||||
} elsif ($options{command} eq 'InquireQueueStatus') {
|
} elsif ($options{command} eq 'InquireQueueStatus') {
|
||||||
@results = $self->{mq_command}->InquireQueueStatus(%{$options{attrs}});
|
@results = $self->{mq_command}->InquireQueueStatus(%{$options{attrs}});
|
||||||
} elsif ($options{command} eq 'InquireChannelNames') {
|
} elsif ($options{command} eq 'InquireChannel') {
|
||||||
@results = $self->{mq_command}->InquireChannelNames(%{$options{attrs}});
|
@results = $self->{mq_command}->InquireChannel(%{$options{attrs}});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!@results) {
|
if (!@results) {
|
||||||
|
@ -112,6 +112,7 @@ sub new {
|
|||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'filter-name:s' => { name => 'filter_name' },
|
'filter-name:s' => { name => 'filter_name' },
|
||||||
|
'filter-type:s' => { name => 'filter_type' },
|
||||||
'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 => '%{channel_status} !~ /running|idle/i' },
|
'critical-status:s' => { name => 'critical_status', default => '%{channel_status} !~ /running|idle/i' },
|
||||||
@ -134,7 +135,7 @@ sub manage_selection {
|
|||||||
attrs => { }
|
attrs => { }
|
||||||
);
|
);
|
||||||
my $names = $options{custom}->execute_command(
|
my $names = $options{custom}->execute_command(
|
||||||
command => 'InquireChannelNames',
|
command => 'InquireChannel',
|
||||||
attrs => { }
|
attrs => { }
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -142,11 +143,14 @@ sub manage_selection {
|
|||||||
foreach (@$result) {
|
foreach (@$result) {
|
||||||
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 ''
|
||||||
&& $_->{ChannelName} !~ /$self->{option_results}->{filter_name}/);
|
&& $_->{ChannelName} !~ /$self->{option_results}->{filter_name}/);
|
||||||
|
next if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne ''
|
||||||
|
&& $_->{ChannelType} !~ /$self->{option_results}->{filter_type}/);
|
||||||
|
|
||||||
$self->{channel}->{$_->{ChannelName}} = {
|
$self->{channel}->{$_->{ChannelName}} = {
|
||||||
qmgr_name => $options{custom}->get_qmgr_name(),
|
qmgr_name => $options{custom}->get_qmgr_name(),
|
||||||
channel_name => $_->{ChannelName},
|
channel_name => $_->{ChannelName},
|
||||||
channel_status => lc($_->{ChannelStatus}),
|
channel_status => lc($_->{ChannelStatus}),
|
||||||
|
channel_type => $_->{ChannelType},
|
||||||
mca_status => lc($_->{MCAStatus}),
|
mca_status => lc($_->{MCAStatus}),
|
||||||
traffic_in => $_->{BytesReceived} * 8,
|
traffic_in => $_->{BytesReceived} * 8,
|
||||||
traffic_out => $_->{BytesSent} * 8
|
traffic_out => $_->{BytesSent} * 8
|
||||||
@ -155,12 +159,16 @@ sub manage_selection {
|
|||||||
|
|
||||||
foreach (@$names) {
|
foreach (@$names) {
|
||||||
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 ''
|
||||||
&& $_ !~ /$self->{option_results}->{filter_name}/);
|
&& $_->{ChannelName} !~ /$self->{option_results}->{filter_name}/);
|
||||||
if (!defined($self->{channel}->{$_})) {
|
next if (defined($self->{option_results}->{filter_type}) && $self->{option_results}->{filter_type} ne ''
|
||||||
$self->{channel}->{$_} = {
|
&& $_->{ChannelType} !~ /$self->{option_results}->{filter_type}/);
|
||||||
|
|
||||||
|
if (!defined($self->{channel}->{$_->{ChannelName}})) {
|
||||||
|
$self->{channel}->{$_->{ChannelName}} = {
|
||||||
qmgr_name => $options{custom}->get_qmgr_name(),
|
qmgr_name => $options{custom}->get_qmgr_name(),
|
||||||
channel_name => $_,
|
channel_name => $_->{ChannelName},
|
||||||
channel_status => 'idle',
|
channel_status => 'idle',
|
||||||
|
channel_type => $_->{ChannelType},
|
||||||
mca_status => '-',
|
mca_status => '-',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -44,14 +44,15 @@ sub manage_selection {
|
|||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my $result = $options{custom}->execute_command(
|
my $result = $options{custom}->execute_command(
|
||||||
command => 'InquireChannelNames',
|
command => 'InquireChannel',
|
||||||
attrs => {}
|
attrs => {}
|
||||||
);
|
);
|
||||||
|
|
||||||
$self->{channel} = {};
|
$self->{channel} = {};
|
||||||
foreach (@$result) {
|
foreach (@$result) {
|
||||||
$self->{channel}->{$_} = {
|
$self->{channel}->{$_->{ChannelName}} = {
|
||||||
name => $_
|
name => $_->{ChannelName},
|
||||||
|
type => $_->{ChannelType}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,8 +64,9 @@ sub run {
|
|||||||
foreach (sort keys %{$self->{channel}}) {
|
foreach (sort keys %{$self->{channel}}) {
|
||||||
$self->{output}->output_add(long_msg =>
|
$self->{output}->output_add(long_msg =>
|
||||||
sprintf(
|
sprintf(
|
||||||
'[name = %s]',
|
'[name = %s][type = %s]',
|
||||||
$self->{channel}->{$_}->{name}
|
$self->{channel}->{$_}->{name},
|
||||||
|
$self->{channel}->{$_}->{type}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -80,7 +82,7 @@ sub run {
|
|||||||
sub disco_format {
|
sub disco_format {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{output}->add_disco_format(elements => ['name']);
|
$self->{output}->add_disco_format(elements => ['name','type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub disco_show {
|
sub disco_show {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user