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->{modes}} = (
|
||||
'alarm-datacenter' => 'apps::vmware::connector::mode::alarmdatacenter',
|
||||
'alarm-host' => 'apps::vmware::connector::mode::alarmhost',
|
||||
'countvm-host' => 'apps::vmware::connector::mode::countvmhost',
|
||||
'cpu-host' => 'apps::vmware::connector::mode::cpuhost',
|
||||
'cpu-vm' => 'apps::vmware::connector::mode::cpuvm',
|
||||
'datastore-countvm' => 'apps::vmware::connector::mode::datastorecountvm',
|
||||
'datastore-host' => 'apps::vmware::connector::mode::datastorehost',
|
||||
'datastore-io' => 'apps::vmware::connector::mode::datastoreio',
|
||||
'datastore-iops' => 'apps::vmware::connector::mode::datastoreiops',
|
||||
'datastore-snapshot' => 'apps::vmware::connector::mode::datastoresnapshot',
|
||||
'datastore-usage' => 'apps::vmware::connector::mode::datastoreusage',
|
||||
'datastore-vm' => 'apps::vmware::connector::mode::datastorevm',
|
||||
'device-vm' => 'apps::vmware::connector::mode::devicevm',
|
||||
'getmap' => 'apps::vmware::connector::mode::getmap',
|
||||
'health-host' => 'apps::vmware::connector::mode::healthhost',
|
||||
'limit-vm' => 'apps::vmware::connector::mode::limitvm',
|
||||
'list-clusters' => 'apps::vmware::connector::mode::listclusters',
|
||||
'list-datacenters' => 'apps::vmware::connector::mode::listdatacenters',
|
||||
'list-datastores' => 'apps::vmware::connector::mode::listdatastores',
|
||||
'list-nichost' => 'apps::vmware::connector::mode::listnichost',
|
||||
'maintenance-host' => 'apps::vmware::connector::mode::maintenancehost',
|
||||
'memory-host' => 'apps::vmware::connector::mode::memoryhost',
|
||||
'memory-vm' => 'apps::vmware::connector::mode::memoryvm',
|
||||
'net-host' => 'apps::vmware::connector::mode::nethost',
|
||||
'service-host' => 'apps::vmware::connector::mode::servicehost',
|
||||
'snapshot-vm' => 'apps::vmware::connector::mode::snapshotvm',
|
||||
'stat-connectors' => 'apps::vmware::connector::mode::statconnectors',
|
||||
'status-host' => 'apps::vmware::connector::mode::statushost',
|
||||
'status-vm' => 'apps::vmware::connector::mode::statusvm',
|
||||
'swap-host' => 'apps::vmware::connector::mode::swaphost',
|
||||
'swap-vm' => 'apps::vmware::connector::mode::swapvm',
|
||||
'thinprovisioning-vm' => 'apps::vmware::connector::mode::thinprovisioningvm',
|
||||
'time-host' => 'apps::vmware::connector::mode::timehost',
|
||||
'tools-vm' => 'apps::vmware::connector::mode::toolsvm',
|
||||
'uptime-host' => 'apps::vmware::connector::mode::uptimehost',
|
||||
'vmoperation-cluster' => 'apps::vmware::connector::mode::vmoperationcluster',
|
||||
);
|
||||
'alarm-datacenter' => 'apps::vmware::connector::mode::alarmdatacenter',
|
||||
'alarm-host' => 'apps::vmware::connector::mode::alarmhost',
|
||||
'countvm-host' => 'apps::vmware::connector::mode::countvmhost',
|
||||
'cpu-host' => 'apps::vmware::connector::mode::cpuhost',
|
||||
'cpu-vm' => 'apps::vmware::connector::mode::cpuvm',
|
||||
'datastore-countvm' => 'apps::vmware::connector::mode::datastorecountvm',
|
||||
'datastore-host' => 'apps::vmware::connector::mode::datastorehost',
|
||||
'datastore-io' => 'apps::vmware::connector::mode::datastoreio',
|
||||
'datastore-iops' => 'apps::vmware::connector::mode::datastoreiops',
|
||||
'datastore-snapshot' => 'apps::vmware::connector::mode::datastoresnapshot',
|
||||
'datastore-usage' => 'apps::vmware::connector::mode::datastoreusage',
|
||||
'datastore-vm' => 'apps::vmware::connector::mode::datastorevm',
|
||||
'device-vm' => 'apps::vmware::connector::mode::devicevm',
|
||||
'discovery' => 'apps::vmware::connector::mode::discovery',
|
||||
'getmap' => 'apps::vmware::connector::mode::getmap',
|
||||
'health-host' => 'apps::vmware::connector::mode::healthhost',
|
||||
'limit-vm' => 'apps::vmware::connector::mode::limitvm',
|
||||
'list-clusters' => 'apps::vmware::connector::mode::listclusters',
|
||||
'list-datacenters' => 'apps::vmware::connector::mode::listdatacenters',
|
||||
'list-datastores' => 'apps::vmware::connector::mode::listdatastores',
|
||||
'list-nichost' => 'apps::vmware::connector::mode::listnichost',
|
||||
'maintenance-host' => 'apps::vmware::connector::mode::maintenancehost',
|
||||
'memory-host' => 'apps::vmware::connector::mode::memoryhost',
|
||||
'memory-vm' => 'apps::vmware::connector::mode::memoryvm',
|
||||
'net-host' => 'apps::vmware::connector::mode::nethost',
|
||||
'service-host' => 'apps::vmware::connector::mode::servicehost',
|
||||
'snapshot-vm' => 'apps::vmware::connector::mode::snapshotvm',
|
||||
'stat-connectors' => 'apps::vmware::connector::mode::statconnectors',
|
||||
'status-host' => 'apps::vmware::connector::mode::statushost',
|
||||
'status-vm' => 'apps::vmware::connector::mode::statusvm',
|
||||
'swap-host' => 'apps::vmware::connector::mode::swaphost',
|
||||
'swap-vm' => 'apps::vmware::connector::mode::swapvm',
|
||||
'thinprovisioning-vm' => 'apps::vmware::connector::mode::thinprovisioningvm',
|
||||
'time-host' => 'apps::vmware::connector::mode::timehost',
|
||||
'tools-vm' => 'apps::vmware::connector::mode::toolsvm',
|
||||
'uptime-host' => 'apps::vmware::connector::mode::uptimehost',
|
||||
'vmoperation-cluster' => 'apps::vmware::connector::mode::vmoperationcluster',
|
||||
);
|
||||
|
||||
$self->{custom_modes}{connector} = 'apps::vmware::connector::custom::connector';
|
||||
return $self;
|
||||
|
@ -79,6 +80,6 @@ __END__
|
|||
|
||||
=head1 PLUGIN DESCRIPTION
|
||||
|
||||
Check VMWare with centreon-esxd connector.
|
||||
Check VMWare with centreon-vmware connector.
|
||||
|
||||
=cut
|
||||
|
|
Loading…
Reference in New Issue