add vmware discovery mode
This commit is contained in:
parent
d499a51232
commit
a95412b484
|
@ -0,0 +1,81 @@
|
||||||
|
#
|
||||||
|
# Copyright 2019 Centreon (http://www.centreon.com/)
|
||||||
|
#
|
||||||
|
# Centreon is a full-fledged industry-strength solution that meets
|
||||||
|
# the needs in IT infrastructure and application monitoring for
|
||||||
|
# service performance.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
package apps::vmware::connector::mode::discovery;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::mode);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use JSON::XS;
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$self->{version} = '1.0';
|
||||||
|
$options{options}->add_options(arguments => {
|
||||||
|
"prettify" => { name => 'prettify' },
|
||||||
|
});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::init(%options);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub run {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $response = $options{custom}->execute(params => $self->{option_results},
|
||||||
|
command => 'discovery', force_response => 1);
|
||||||
|
|
||||||
|
my $encoded_data;
|
||||||
|
eval {
|
||||||
|
if (defined($self->{option_results}->{prettify})) {
|
||||||
|
$encoded_data = JSON::XS->new->utf8->pretty->encode($response->{data});
|
||||||
|
} else {
|
||||||
|
$encoded_data = JSON::XS->new->utf8->encode($response->{data});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if ($@) {
|
||||||
|
$encoded_data = '{"code":"encode_error","message":"Cannot encode discovered data into JSON format"}';
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{output}->output_add(short_msg => $encoded_data);
|
||||||
|
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Discover resources.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -44,6 +44,7 @@ sub new {
|
||||||
'datastore-usage' => 'apps::vmware::connector::mode::datastoreusage',
|
'datastore-usage' => 'apps::vmware::connector::mode::datastoreusage',
|
||||||
'datastore-vm' => 'apps::vmware::connector::mode::datastorevm',
|
'datastore-vm' => 'apps::vmware::connector::mode::datastorevm',
|
||||||
'device-vm' => 'apps::vmware::connector::mode::devicevm',
|
'device-vm' => 'apps::vmware::connector::mode::devicevm',
|
||||||
|
'discovery' => 'apps::vmware::connector::mode::discovery',
|
||||||
'getmap' => 'apps::vmware::connector::mode::getmap',
|
'getmap' => 'apps::vmware::connector::mode::getmap',
|
||||||
'health-host' => 'apps::vmware::connector::mode::healthhost',
|
'health-host' => 'apps::vmware::connector::mode::healthhost',
|
||||||
'limit-vm' => 'apps::vmware::connector::mode::limitvm',
|
'limit-vm' => 'apps::vmware::connector::mode::limitvm',
|
||||||
|
@ -79,6 +80,6 @@ __END__
|
||||||
|
|
||||||
=head1 PLUGIN DESCRIPTION
|
=head1 PLUGIN DESCRIPTION
|
||||||
|
|
||||||
Check VMWare with centreon-esxd connector.
|
Check VMWare with centreon-vmware connector.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
Loading…
Reference in New Issue