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
|
|
@ -31,43 +31,44 @@ sub new {
|
||||||
|
|
||||||
$self->{version} = '0.1';
|
$self->{version} = '0.1';
|
||||||
%{$self->{modes}} = (
|
%{$self->{modes}} = (
|
||||||
'alarm-datacenter' => 'apps::vmware::connector::mode::alarmdatacenter',
|
'alarm-datacenter' => 'apps::vmware::connector::mode::alarmdatacenter',
|
||||||
'alarm-host' => 'apps::vmware::connector::mode::alarmhost',
|
'alarm-host' => 'apps::vmware::connector::mode::alarmhost',
|
||||||
'countvm-host' => 'apps::vmware::connector::mode::countvmhost',
|
'countvm-host' => 'apps::vmware::connector::mode::countvmhost',
|
||||||
'cpu-host' => 'apps::vmware::connector::mode::cpuhost',
|
'cpu-host' => 'apps::vmware::connector::mode::cpuhost',
|
||||||
'cpu-vm' => 'apps::vmware::connector::mode::cpuvm',
|
'cpu-vm' => 'apps::vmware::connector::mode::cpuvm',
|
||||||
'datastore-countvm' => 'apps::vmware::connector::mode::datastorecountvm',
|
'datastore-countvm' => 'apps::vmware::connector::mode::datastorecountvm',
|
||||||
'datastore-host' => 'apps::vmware::connector::mode::datastorehost',
|
'datastore-host' => 'apps::vmware::connector::mode::datastorehost',
|
||||||
'datastore-io' => 'apps::vmware::connector::mode::datastoreio',
|
'datastore-io' => 'apps::vmware::connector::mode::datastoreio',
|
||||||
'datastore-iops' => 'apps::vmware::connector::mode::datastoreiops',
|
'datastore-iops' => 'apps::vmware::connector::mode::datastoreiops',
|
||||||
'datastore-snapshot' => 'apps::vmware::connector::mode::datastoresnapshot',
|
'datastore-snapshot' => 'apps::vmware::connector::mode::datastoresnapshot',
|
||||||
'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',
|
||||||
'getmap' => 'apps::vmware::connector::mode::getmap',
|
'discovery' => 'apps::vmware::connector::mode::discovery',
|
||||||
'health-host' => 'apps::vmware::connector::mode::healthhost',
|
'getmap' => 'apps::vmware::connector::mode::getmap',
|
||||||
'limit-vm' => 'apps::vmware::connector::mode::limitvm',
|
'health-host' => 'apps::vmware::connector::mode::healthhost',
|
||||||
'list-clusters' => 'apps::vmware::connector::mode::listclusters',
|
'limit-vm' => 'apps::vmware::connector::mode::limitvm',
|
||||||
'list-datacenters' => 'apps::vmware::connector::mode::listdatacenters',
|
'list-clusters' => 'apps::vmware::connector::mode::listclusters',
|
||||||
'list-datastores' => 'apps::vmware::connector::mode::listdatastores',
|
'list-datacenters' => 'apps::vmware::connector::mode::listdatacenters',
|
||||||
'list-nichost' => 'apps::vmware::connector::mode::listnichost',
|
'list-datastores' => 'apps::vmware::connector::mode::listdatastores',
|
||||||
'maintenance-host' => 'apps::vmware::connector::mode::maintenancehost',
|
'list-nichost' => 'apps::vmware::connector::mode::listnichost',
|
||||||
'memory-host' => 'apps::vmware::connector::mode::memoryhost',
|
'maintenance-host' => 'apps::vmware::connector::mode::maintenancehost',
|
||||||
'memory-vm' => 'apps::vmware::connector::mode::memoryvm',
|
'memory-host' => 'apps::vmware::connector::mode::memoryhost',
|
||||||
'net-host' => 'apps::vmware::connector::mode::nethost',
|
'memory-vm' => 'apps::vmware::connector::mode::memoryvm',
|
||||||
'service-host' => 'apps::vmware::connector::mode::servicehost',
|
'net-host' => 'apps::vmware::connector::mode::nethost',
|
||||||
'snapshot-vm' => 'apps::vmware::connector::mode::snapshotvm',
|
'service-host' => 'apps::vmware::connector::mode::servicehost',
|
||||||
'stat-connectors' => 'apps::vmware::connector::mode::statconnectors',
|
'snapshot-vm' => 'apps::vmware::connector::mode::snapshotvm',
|
||||||
'status-host' => 'apps::vmware::connector::mode::statushost',
|
'stat-connectors' => 'apps::vmware::connector::mode::statconnectors',
|
||||||
'status-vm' => 'apps::vmware::connector::mode::statusvm',
|
'status-host' => 'apps::vmware::connector::mode::statushost',
|
||||||
'swap-host' => 'apps::vmware::connector::mode::swaphost',
|
'status-vm' => 'apps::vmware::connector::mode::statusvm',
|
||||||
'swap-vm' => 'apps::vmware::connector::mode::swapvm',
|
'swap-host' => 'apps::vmware::connector::mode::swaphost',
|
||||||
'thinprovisioning-vm' => 'apps::vmware::connector::mode::thinprovisioningvm',
|
'swap-vm' => 'apps::vmware::connector::mode::swapvm',
|
||||||
'time-host' => 'apps::vmware::connector::mode::timehost',
|
'thinprovisioning-vm' => 'apps::vmware::connector::mode::thinprovisioningvm',
|
||||||
'tools-vm' => 'apps::vmware::connector::mode::toolsvm',
|
'time-host' => 'apps::vmware::connector::mode::timehost',
|
||||||
'uptime-host' => 'apps::vmware::connector::mode::uptimehost',
|
'tools-vm' => 'apps::vmware::connector::mode::toolsvm',
|
||||||
'vmoperation-cluster' => 'apps::vmware::connector::mode::vmoperationcluster',
|
'uptime-host' => 'apps::vmware::connector::mode::uptimehost',
|
||||||
);
|
'vmoperation-cluster' => 'apps::vmware::connector::mode::vmoperationcluster',
|
||||||
|
);
|
||||||
|
|
||||||
$self->{custom_modes}{connector} = 'apps::vmware::connector::custom::connector';
|
$self->{custom_modes}{connector} = 'apps::vmware::connector::custom::connector';
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -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