[CTOR-306] [Plugin] [CommunityPR] Allow to filter ActiveMQ Brokers by mbean and attributes (#4883)
Co-authored-by: Colin Gagnaire <gagnaire.colin@gmail.com> Co-authored-by: Lucie Dubrunfaut <ldubrunfaut@CNTR-P-PF3DNAR1>
This commit is contained in:
parent
6393960d96
commit
53162b3459
|
@ -4,12 +4,15 @@ Centreon
|
|||
Fortinet
|
||||
Fortigate
|
||||
license-instances-usage-prct
|
||||
MBean
|
||||
OID
|
||||
oneaccess-sys-mib
|
||||
perfdata
|
||||
powershell
|
||||
queue-messages-inflighted
|
||||
SNMP
|
||||
space-usage-prct
|
||||
SSH
|
||||
SureBackup
|
||||
topic-messages-inflighted
|
||||
Veeam
|
||||
|
|
|
@ -155,7 +155,7 @@ jobs:
|
|||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
|
||||
- if: ${{ matrix.distrib == 'el7' }}
|
||||
uses: actions/cache/restore@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
|
||||
uses: actions/cache/restore@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
|
||||
with:
|
||||
path: ./build/
|
||||
key: fatpacked-plugins-${{ github.sha }}-${{ github.run_id }}
|
||||
|
|
|
@ -204,7 +204,8 @@ sub new {
|
|||
$options{options}->add_options(arguments => {
|
||||
'filter-broker-name:s' => { name => 'filter_broker_name' },
|
||||
'filter-destination-name:s' => { name => 'filter_destination_name' },
|
||||
'filter-destination-type:s' => { name => 'filter_destination_type' }
|
||||
'filter-destination-type:s' => { name => 'filter_destination_type' },
|
||||
'request:s@' => { name => 'request' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -238,6 +239,24 @@ sub manage_selection {
|
|||
]
|
||||
}
|
||||
];
|
||||
|
||||
if (defined($self->{option_results}->{request}) && $self->{option_results}->{request} ne '') {
|
||||
centreon::plugins::misc::mymodule_load(
|
||||
output => $self->{output}, module => 'JSON::XS',
|
||||
error_msg => "Cannot load module 'JSON::XS'."
|
||||
);
|
||||
$request = undef;
|
||||
foreach (@{$self->{option_results}->{request}}) {
|
||||
eval {
|
||||
push @$request, JSON::XS->new->utf8->decode($_);
|
||||
};
|
||||
if ($@) {
|
||||
$self->{output}->add_option_msg(short_msg => "Cannot use request as it is a malformed JSON: " . $@);
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $result = $options{custom}->get_attributes(request => $request, nothing_quit => 1);
|
||||
|
||||
$self->{cache_name} = 'activemq_' . $self->{mode} . '_' . md5_hex($options{custom}->get_connection_info()) . '_' .
|
||||
|
@ -318,6 +337,24 @@ Filter destination name (can be a regexp).
|
|||
|
||||
Filter destination type (can be a regexp).
|
||||
|
||||
=item B<--request>
|
||||
|
||||
EXPERIMENTAL Option : Community-supported only (no support from Centreon at this time)
|
||||
|
||||
Set the MBean and attributes to request (will replace defaults)
|
||||
in a JSON-formatted fashion.
|
||||
|
||||
This is useful to reduce the size of returned data by providing destination
|
||||
type and name or broker name instead of filtering afterwards, and grabbing
|
||||
exactly the wanted attributes.
|
||||
|
||||
This can be set multiple times.
|
||||
|
||||
Example:
|
||||
|
||||
--request='{"mbean":"org.apache.activemq:brokerName=*,destinationName=MyQueue,destinationType=Queue,type=Broker","attributes":[{"name":"QueueSize"}]}'
|
||||
--request='{"mbean":"org.apache.activemq:brokerName=*,type=Broker,service=Health","attributes":[{"name":"CurrentStatus"}]}'
|
||||
|
||||
=item B<--warning-status>
|
||||
|
||||
Define the conditions to match for the status to be WARNING.
|
||||
|
|
Loading…
Reference in New Issue