(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}});
|
||||
} elsif ($options{command} eq 'InquireQueueStatus') {
|
||||
@results = $self->{mq_command}->InquireQueueStatus(%{$options{attrs}});
|
||||
} elsif ($options{command} eq 'InquireChannelNames') {
|
||||
@results = $self->{mq_command}->InquireChannelNames(%{$options{attrs}});
|
||||
} elsif ($options{command} eq 'InquireChannel') {
|
||||
@results = $self->{mq_command}->InquireChannel(%{$options{attrs}});
|
||||
}
|
||||
|
||||
if (!@results) {
|
||||
|
|
|
@ -112,6 +112,7 @@ sub new {
|
|||
|
||||
$options{options}->add_options(arguments => {
|
||||
'filter-name:s' => { name => 'filter_name' },
|
||||
'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 => '%{channel_status} !~ /running|idle/i' },
|
||||
|
@ -134,7 +135,7 @@ sub manage_selection {
|
|||
attrs => { }
|
||||
);
|
||||
my $names = $options{custom}->execute_command(
|
||||
command => 'InquireChannelNames',
|
||||
command => 'InquireChannel',
|
||||
attrs => { }
|
||||
);
|
||||
|
||||
|
@ -142,11 +143,14 @@ sub manage_selection {
|
|||
foreach (@$result) {
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne ''
|
||||
&& $_->{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}} = {
|
||||
qmgr_name => $options{custom}->get_qmgr_name(),
|
||||
channel_name => $_->{ChannelName},
|
||||
channel_status => lc($_->{ChannelStatus}),
|
||||
channel_type => $_->{ChannelType},
|
||||
mca_status => lc($_->{MCAStatus}),
|
||||
traffic_in => $_->{BytesReceived} * 8,
|
||||
traffic_out => $_->{BytesSent} * 8
|
||||
|
@ -155,12 +159,16 @@ sub manage_selection {
|
|||
|
||||
foreach (@$names) {
|
||||
next if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne ''
|
||||
&& $_ !~ /$self->{option_results}->{filter_name}/);
|
||||
if (!defined($self->{channel}->{$_})) {
|
||||
$self->{channel}->{$_} = {
|
||||
&& $_->{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}/);
|
||||
|
||||
if (!defined($self->{channel}->{$_->{ChannelName}})) {
|
||||
$self->{channel}->{$_->{ChannelName}} = {
|
||||
qmgr_name => $options{custom}->get_qmgr_name(),
|
||||
channel_name => $_,
|
||||
channel_name => $_->{ChannelName},
|
||||
channel_status => 'idle',
|
||||
channel_type => $_->{ChannelType},
|
||||
mca_status => '-',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -44,14 +44,15 @@ sub manage_selection {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
my $result = $options{custom}->execute_command(
|
||||
command => 'InquireChannelNames',
|
||||
command => 'InquireChannel',
|
||||
attrs => {}
|
||||
);
|
||||
|
||||
$self->{channel} = {};
|
||||
foreach (@$result) {
|
||||
$self->{channel}->{$_} = {
|
||||
name => $_
|
||||
$self->{channel}->{$_->{ChannelName}} = {
|
||||
name => $_->{ChannelName},
|
||||
type => $_->{ChannelType}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -63,8 +64,9 @@ sub run {
|
|||
foreach (sort keys %{$self->{channel}}) {
|
||||
$self->{output}->output_add(long_msg =>
|
||||
sprintf(
|
||||
'[name = %s]',
|
||||
$self->{channel}->{$_}->{name}
|
||||
'[name = %s][type = %s]',
|
||||
$self->{channel}->{$_}->{name},
|
||||
$self->{channel}->{$_}->{type}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -80,7 +82,7 @@ sub run {
|
|||
sub disco_format {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
$self->{output}->add_disco_format(elements => ['name']);
|
||||
$self->{output}->add_disco_format(elements => ['name','type']);
|
||||
}
|
||||
|
||||
sub disco_show {
|
||||
|
|
Loading…
Reference in New Issue