enh(vmware): version 3.2.2
This commit is contained in:
commit
a51c8f0d42
|
@ -1,3 +1,11 @@
|
|||
2021-12-21 Quentin Garnier <qgarnier@centreon.com> - 3.2.2
|
||||
* Enhancement: add 'storage-host'
|
||||
* Enhancement: add 'cpu-cluster' (issue #90)
|
||||
* Enhancement: add 'licenses'
|
||||
* Enhancement: add refresh capability for datastore-usage (issue #96)
|
||||
* Enhancement: container label in configuration is case-insensitive (issue #83)
|
||||
* Enhancement: add capability to use empty-continue option (issue #77)
|
||||
|
||||
2020-11-03 Quentin Garnier <qgarnier@centreon.com> - 3.2.1
|
||||
* Fix: daemon cannot start (issue #92)
|
||||
|
||||
|
|
|
@ -54,13 +54,14 @@ BEGIN {
|
|||
use base qw(centreon::vmware::script);
|
||||
use vars qw(%centreon_vmware_config);
|
||||
|
||||
my $VERSION = '3.2.1';
|
||||
my $VERSION = '3.2.2';
|
||||
my %handlers = (TERM => {}, HUP => {}, CHLD => {});
|
||||
|
||||
my @load_modules = (
|
||||
'centreon::vmware::cmdalarmdatacenter',
|
||||
'centreon::vmware::cmdalarmhost',
|
||||
'centreon::vmware::cmdcountvmhost',
|
||||
'centreon::vmware::cmdcpucluster',
|
||||
'centreon::vmware::cmdcpuhost',
|
||||
'centreon::vmware::cmdcpuvm',
|
||||
'centreon::vmware::cmddatastorecountvm',
|
||||
|
@ -74,6 +75,7 @@ my @load_modules = (
|
|||
'centreon::vmware::cmddiscovery',
|
||||
'centreon::vmware::cmdgetmap',
|
||||
'centreon::vmware::cmdhealthhost',
|
||||
'centreon::vmware::cmdlicenses',
|
||||
'centreon::vmware::cmdlimitvm',
|
||||
'centreon::vmware::cmdlistclusters',
|
||||
'centreon::vmware::cmdlistdatacenters',
|
||||
|
@ -89,6 +91,7 @@ my @load_modules = (
|
|||
'centreon::vmware::cmdstatuscluster',
|
||||
'centreon::vmware::cmdstatushost',
|
||||
'centreon::vmware::cmdstatusvm',
|
||||
'centreon::vmware::cmdstoragehost',
|
||||
'centreon::vmware::cmdswaphost',
|
||||
'centreon::vmware::cmdswapvm',
|
||||
'centreon::vmware::cmdthinprovisioningvm',
|
||||
|
@ -160,6 +163,11 @@ sub init {
|
|||
|
||||
$self->{centreon_vmware_config} = {%{$self->{centreon_vmware_default_config}}, %centreon_vmware_config};
|
||||
|
||||
foreach my $name (keys %{$self->{centreon_vmware_config}->{vsphere_server}}) {
|
||||
my $iname = lc($name);
|
||||
$self->{centreon_vmware_config}->{vsphere_server}->{$iname} = delete $self->{centreon_vmware_config}->{vsphere_server}->{$name};
|
||||
}
|
||||
|
||||
##### Load modules
|
||||
$self->load_module(@load_modules);
|
||||
|
||||
|
@ -352,20 +360,27 @@ sub request_dynamic {
|
|||
my $container = md5_hex($options{result}->{vsphere_address} . $options{result}->{vsphere_username} . $options{result}->{vsphere_password});
|
||||
# Need to create fork
|
||||
if (!defined($self->{centreon_vmware_config}->{vsphere_server}->{$container})) {
|
||||
$self->{centreon_vmware_config}->{vsphere_server}->{$container} = { url => 'https://' . $options{result}->{vsphere_address} . '/sdk',
|
||||
username => $options{result}->{vsphere_username},
|
||||
password => $options{result}->{vsphere_password},
|
||||
last_request => time() };
|
||||
$self->{logger}->writeLogError(sprintf("Dynamic creation: identity = %s [address: %s] [username: %s] [password: %s]",
|
||||
$container, $options{result}->{vsphere_address}, $options{result}->{vsphere_username}, $options{result}->{vsphere_password}));
|
||||
$self->{centreon_vmware_config}->{vsphere_server}->{$container} = {
|
||||
url => 'https://' . $options{result}->{vsphere_address} . '/sdk',
|
||||
username => $options{result}->{vsphere_username},
|
||||
password => $options{result}->{vsphere_password},
|
||||
last_request => time()
|
||||
};
|
||||
$self->{logger}->writeLogError(
|
||||
sprintf(
|
||||
"Dynamic creation: identity = %s [address: %s] [username: %s] [password: %s]",
|
||||
$container, $options{result}->{vsphere_address}, $options{result}->{vsphere_username}, $options{result}->{vsphere_password}
|
||||
)
|
||||
);
|
||||
$centreon_vmware->create_vsphere_child(vsphere_name => $container, dynamic => 1);
|
||||
}
|
||||
|
||||
return if ($self->waiting_ready(container => $container, manager => $options{manager},
|
||||
identity => $options{identity}) == 0);
|
||||
|
||||
return if ($self->waiting_ready(
|
||||
container => $container, manager => $options{manager},
|
||||
identity => $options{identity}) == 0);
|
||||
|
||||
$self->{centreon_vmware_config}->{vsphere_server}->{$container}->{last_request} = time();
|
||||
|
||||
|
||||
my $flag = ZMQ_NOBLOCK | ZMQ_SNDMORE;
|
||||
my $msg = zmq_msg_init_data("server-" . $container);
|
||||
zmq_msg_send($msg, $frontend, $flag);
|
||||
|
@ -393,36 +408,39 @@ sub request {
|
|||
centreon::vmware::common::response(token => 'RESPSERVER', endpoint => $frontend, identity => $options{identity});
|
||||
return ;
|
||||
}
|
||||
if (!defined($self->{modules_registry}->{$result->{command}})) {
|
||||
if (!defined($self->{modules_registry}->{ $result->{command} })) {
|
||||
centreon::vmware::common::set_response(code => 1, short_message => "Unknown method name '$result->{command}'");
|
||||
centreon::vmware::common::response(token => 'RESPSERVER', endpoint => $frontend, identity => $options{identity});
|
||||
return ;
|
||||
}
|
||||
if ($self->{modules_registry}->{$result->{command}}->checkArgs(manager => $options{manager},
|
||||
arguments => $result)) {
|
||||
if ($self->{modules_registry}->{ $result->{command} }->checkArgs(
|
||||
manager => $options{manager},
|
||||
arguments => $result)) {
|
||||
centreon::vmware::common::response(token => 'RESPSERVER', endpoint => $frontend, identity => $options{identity});
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
# Mode dynamic
|
||||
if (defined($result->{vsphere_address}) && $result->{vsphere_address} ne '') {
|
||||
$self->request_dynamic(result => $result, %options);
|
||||
return ;
|
||||
}
|
||||
|
||||
if (!defined($self->{centreon_vmware_config}->{vsphere_server}->{$result->{container}})) {
|
||||
|
||||
$result->{container} = lc($result->{container});
|
||||
if (!defined($self->{centreon_vmware_config}->{vsphere_server}->{ $result->{container} })) {
|
||||
centreon::vmware::common::set_response(code => 1, short_message => "Unknown container name '$result->{container}'");
|
||||
centreon::vmware::common::response(token => 'RESPSERVER', endpoint => $frontend, identity => $options{identity});
|
||||
return ;
|
||||
}
|
||||
|
||||
return if ($self->waiting_ready(container => $result->{container}, manager => $options{manager},
|
||||
identity => $options{identity}) == 0);
|
||||
|
||||
$self->{counter_stats}->{$result->{container}}++;
|
||||
return if ($self->waiting_ready(
|
||||
container => $result->{container}, manager => $options{manager},
|
||||
identity => $options{identity}) == 0);
|
||||
|
||||
$self->{counter_stats}->{ $result->{container} }++;
|
||||
|
||||
my $flag = ZMQ_NOBLOCK | ZMQ_SNDMORE;
|
||||
my $msg = zmq_msg_init_data("server-" . $result->{container});
|
||||
my $msg = zmq_msg_init_data('server-' . $result->{container});
|
||||
zmq_msg_send($msg, $frontend, $flag);
|
||||
zmq_msg_close($msg);
|
||||
$msg = zmq_msg_init_data('REQCLIENT ' . $options{data});
|
||||
|
@ -445,9 +463,11 @@ sub repserver {
|
|||
|
||||
$result->{identity} =~ /^client-(.*)$/;
|
||||
my $identity = 'client-' . pack('H*', $1);
|
||||
|
||||
centreon::vmware::common::response(token => 'RESPSERVER', endpoint => $frontend,
|
||||
identity => $identity, force_response => $options{data});
|
||||
|
||||
centreon::vmware::common::response(
|
||||
token => 'RESPSERVER', endpoint => $frontend,
|
||||
identity => $identity, force_response => $options{data}
|
||||
);
|
||||
}
|
||||
|
||||
sub router_event {
|
||||
|
@ -457,12 +477,12 @@ sub router_event {
|
|||
zmq_msg_recv($msg, $frontend, ZMQ_DONTWAIT);
|
||||
my $identity = zmq_msg_data($msg);
|
||||
zmq_msg_close($msg);
|
||||
|
||||
|
||||
$msg = zmq_msg_init();
|
||||
zmq_msg_recv($msg, $frontend, ZMQ_DONTWAIT);
|
||||
my $data = zmq_msg_data($msg);
|
||||
zmq_msg_close($msg);
|
||||
|
||||
|
||||
centreon::vmware::common::init_response();
|
||||
if ($centreon_vmware->{stop} != 0) {
|
||||
# We quit so we say we're leaving ;)
|
||||
|
@ -516,7 +536,7 @@ sub create_vsphere_child {
|
|||
modules_registry => $self->{modules_registry},
|
||||
config => $self->{centreon_vmware_config},
|
||||
logger => $self->{logger},
|
||||
vsan_enabled => $self->{vsan_enabled},
|
||||
vsan_enabled => $self->{vsan_enabled}
|
||||
);
|
||||
$connector->run();
|
||||
exit(0);
|
||||
|
|
|
@ -31,7 +31,7 @@ sub new {
|
|||
|
||||
$self->{logger} = $options{logger};
|
||||
$self->{global_case_insensitive} = defined($options{case_insensitive}) ? $options{case_insensitive} : 0;
|
||||
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ sub class_handle_ALRM {
|
|||
|
||||
sub handle_ALRM {
|
||||
my $self = shift;
|
||||
|
||||
|
||||
$self->{logger}->writeLogError('Child process autokill!!');
|
||||
exit(0);
|
||||
}
|
||||
|
@ -80,12 +80,12 @@ sub set_connector {
|
|||
|
||||
sub initArgs {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
foreach (keys %{$options{arguments}}) {
|
||||
$self->{$_} = $options{arguments}->{$_};
|
||||
}
|
||||
centreon::vmware::common::init_response(identity => $options{arguments}->{identity});
|
||||
|
||||
|
||||
if ($self->{global_case_insensitive} == 0 && defined($self->{case_insensitive})) {
|
||||
$self->{global_case_insensitive} = 1;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
# Copyright 2015 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 centreon::vmware::cmdcpucluster;
|
||||
|
||||
use base qw(centreon::vmware::cmdbase);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::vmware::common;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(%options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{commandName} = 'cpucluster';
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub checkArgs {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (defined($options{arguments}->{cluster_name}) && $options{arguments}->{cluster_name} eq '') {
|
||||
centreon::vmware::common::set_response(code => 100, short_message => 'Argument error: cluster name cannot be null');
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub run {
|
||||
my $self = shift;
|
||||
|
||||
if (!($self->{connector}->{perfcounter_speriod} > 0)) {
|
||||
centreon::vmware::common::set_response(code => -1, short_message => "Can't retrieve perf counters");
|
||||
return ;
|
||||
}
|
||||
|
||||
my $filters = $self->build_filter(label => 'name', search_option => 'cluster_name', is_regexp => 'filter');
|
||||
my @properties = ('name');
|
||||
my $views = centreon::vmware::common::search_entities(command => $self, view_type => 'ClusterComputeResource', properties => \@properties, filter => $filters);
|
||||
return if (!defined($views));
|
||||
|
||||
my $values = centreon::vmware::common::generic_performance_values_historic(
|
||||
$self->{connector},
|
||||
$views,
|
||||
[
|
||||
{ label => 'cpu.usage.average', instances => [''] },
|
||||
{ label => 'cpu.usagemhz.average', instances => [''] }
|
||||
],
|
||||
$self->{connector}->{perfcounter_speriod},
|
||||
sampling_period => $self->{sampling_period},
|
||||
time_shift => $self->{time_shift},
|
||||
skip_undef_counter => 1, multiples => 1, multiples_result_by_entity => 1
|
||||
);
|
||||
return if (centreon::vmware::common::performance_errors($self->{connector}, $values) == 1);
|
||||
|
||||
my $interval_min = centreon::vmware::common::get_interval_min(
|
||||
speriod => $self->{connector}->{perfcounter_speriod},
|
||||
sampling_period => $self->{sampling_period},
|
||||
time_shift => $self->{time_shift}
|
||||
);
|
||||
|
||||
my $data = {};
|
||||
foreach my $view (@$views) {
|
||||
my $entity_value = $view->{mo_ref}->{value};
|
||||
$data->{$entity_value} = { name => $view->{name} };
|
||||
|
||||
my $total_cpu_average = centreon::vmware::common::simplify_number(centreon::vmware::common::convert_number($values->{$entity_value}->{ $self->{connector}->{perfcounter_cache}->{'cpu.usage.average'}->{key} . ':' } * 0.01));
|
||||
my $total_cpu_mhz_average = centreon::vmware::common::simplify_number(centreon::vmware::common::convert_number($values->{$entity_value}->{ $self->{connector}->{perfcounter_cache}->{'cpu.usagemhz.average'}->{key} . ':' }));
|
||||
|
||||
$data->{$entity_value}->{'interval_min'} = $interval_min;
|
||||
$data->{$entity_value}->{'cpu.usage.average'} = $total_cpu_average;
|
||||
$data->{$entity_value}->{'cpu.usagemhz.average'} = $total_cpu_mhz_average;
|
||||
}
|
||||
|
||||
centreon::vmware::common::set_response(data => $data);
|
||||
}
|
||||
|
||||
1;
|
|
@ -59,18 +59,25 @@ sub run {
|
|||
return if (!defined($result));
|
||||
|
||||
my @instances = ('*');
|
||||
my $values = centreon::vmware::common::generic_performance_values_historic($self->{connector},
|
||||
$result,
|
||||
[{'label' => 'cpu.usage.average', 'instances' => \@instances},
|
||||
{'label' => 'cpu.usagemhz.average', 'instances' => \@instances}],
|
||||
$self->{connector}->{perfcounter_speriod},
|
||||
sampling_period => $self->{sampling_period}, time_shift => $self->{time_shift},
|
||||
skip_undef_counter => 1, multiples => 1, multiples_result_by_entity => 1);
|
||||
my $values = centreon::vmware::common::generic_performance_values_historic(
|
||||
$self->{connector},
|
||||
$result,
|
||||
[
|
||||
{ label => 'cpu.usage.average', 'instances' => \@instances},
|
||||
{ label => 'cpu.usagemhz.average', 'instances' => \@instances}
|
||||
],
|
||||
$self->{connector}->{perfcounter_speriod},
|
||||
sampling_period => $self->{sampling_period},
|
||||
time_shift => $self->{time_shift},
|
||||
skip_undef_counter => 1, multiples => 1, multiples_result_by_entity => 1
|
||||
);
|
||||
return if (centreon::vmware::common::performance_errors($self->{connector}, $values) == 1);
|
||||
|
||||
my $interval_min = centreon::vmware::common::get_interval_min(speriod => $self->{connector}->{perfcounter_speriod},
|
||||
sampling_period => $self->{sampling_period}, time_shift => $self->{time_shift});
|
||||
|
||||
my $interval_min = centreon::vmware::common::get_interval_min(
|
||||
speriod => $self->{connector}->{perfcounter_speriod},
|
||||
sampling_period => $self->{sampling_period}, time_shift => $self->{time_shift}
|
||||
);
|
||||
|
||||
my $data = {};
|
||||
foreach my $entity_view (@$result) {
|
||||
my $entity_value = $entity_view->{mo_ref}->{value};
|
||||
|
|
|
@ -66,23 +66,29 @@ sub run {
|
|||
return if (!defined($result));
|
||||
|
||||
my @instances = ('*');
|
||||
my $values = centreon::vmware::common::generic_performance_values_historic($self->{connector},
|
||||
$result,
|
||||
[{'label' => 'cpu.usage.average', 'instances' => \@instances},
|
||||
{'label' => 'cpu.usagemhz.average', 'instances' => \@instances},
|
||||
{'label' => 'cpu.ready.summation', 'instances' => \@instances}],
|
||||
$self->{connector}->{perfcounter_speriod},
|
||||
sampling_period => $self->{sampling_period}, time_shift => $self->{time_shift},
|
||||
skip_undef_counter => 1, multiples => 1, multiples_result_by_entity => 1);
|
||||
my $values = centreon::vmware::common::generic_performance_values_historic(
|
||||
$self->{connector},
|
||||
$result,
|
||||
[
|
||||
{'label' => 'cpu.usage.average', 'instances' => \@instances},
|
||||
{'label' => 'cpu.usagemhz.average', 'instances' => \@instances},
|
||||
{'label' => 'cpu.ready.summation', 'instances' => \@instances}
|
||||
],
|
||||
$self->{connector}->{perfcounter_speriod},
|
||||
sampling_period => $self->{sampling_period}, time_shift => $self->{time_shift},
|
||||
skip_undef_counter => 1, multiples => 1, multiples_result_by_entity => 1
|
||||
);
|
||||
return if (centreon::vmware::common::performance_errors($self->{connector}, $values) == 1);
|
||||
|
||||
my $interval_sec = $self->{connector}->{perfcounter_speriod};
|
||||
if (defined($self->{sampling_period}) && $self->{sampling_period} ne '') {
|
||||
$interval_sec = $self->{sampling_period};
|
||||
}
|
||||
my $interval_min = centreon::vmware::common::get_interval_min(speriod => $self->{connector}->{perfcounter_speriod},
|
||||
sampling_period => $self->{sampling_period}, time_shift => $self->{time_shift});
|
||||
|
||||
my $interval_min = centreon::vmware::common::get_interval_min(
|
||||
speriod => $self->{connector}->{perfcounter_speriod},
|
||||
sampling_period => $self->{sampling_period}, time_shift => $self->{time_shift}
|
||||
);
|
||||
|
||||
my $data = {};
|
||||
foreach my $entity_view (@$result) {
|
||||
my $entity_value = $entity_view->{mo_ref}->{value};
|
||||
|
|
|
@ -88,6 +88,10 @@ sub run {
|
|||
|
||||
next if (centreon::vmware::common::is_accessible(accessible => $entity_view->summary->accessible) == 0);
|
||||
|
||||
if (defined($self->{refresh})) {
|
||||
$entity_view->RefreshDatastore();
|
||||
}
|
||||
|
||||
# capacity 0...
|
||||
if ($entity_view->summary->capacity <= 0) {
|
||||
$data->{$entity_value}->{size} = 0;
|
||||
|
|
|
@ -112,9 +112,11 @@ sub run {
|
|||
foreach my $cluster (@$clusters) {
|
||||
next if (!$cluster->{'host'});
|
||||
|
||||
my @properties = ('name', 'vm', 'config.virtualNicManagerInfo.netConfig', 'config.product.version',
|
||||
my @properties = (
|
||||
'name', 'vm', 'config.virtualNicManagerInfo.netConfig', 'config.product.version',
|
||||
'config.product.productLineId', 'hardware.systemInfo.vendor', 'hardware.systemInfo.model',
|
||||
'hardware.systemInfo.uuid', 'runtime.powerState', 'runtime.inMaintenanceMode', 'runtime.connectionState');
|
||||
'hardware.systemInfo.uuid', 'runtime.powerState', 'runtime.inMaintenanceMode', 'runtime.connectionState'
|
||||
);
|
||||
|
||||
my $esxs = centreon::vmware::common::get_views($self->{connector}, \@{$cluster->host}, \@properties);
|
||||
next if (!defined($esxs));
|
||||
|
@ -122,7 +124,7 @@ sub run {
|
|||
foreach my $esx (@$esxs) {
|
||||
my %esx;
|
||||
|
||||
$esx{type} = "esx";
|
||||
$esx{type} = 'esx';
|
||||
$esx{name} = $esx->name;
|
||||
$esx{os} = $esx->{'config.product.productLineId'} . ' ' . $esx->{'config.product.version'};
|
||||
$esx{hardware} = $esx->{'hardware.systemInfo.vendor'} . ' ' . $esx->{'hardware.systemInfo.model'};
|
||||
|
|
|
@ -49,8 +49,10 @@ sub run {
|
|||
my $self = shift;
|
||||
|
||||
my $filters = $self->build_filter(label => 'name', search_option => 'esx_hostname', is_regexp => 'filter');
|
||||
my @properties = ('name', 'runtime.healthSystemRuntime.hardwareStatusInfo', 'runtime.healthSystemRuntime.systemHealthInfo.numericSensorInfo',
|
||||
'runtime.connectionState');
|
||||
my @properties = (
|
||||
'name', 'runtime.healthSystemRuntime.hardwareStatusInfo', 'runtime.healthSystemRuntime.systemHealthInfo.numericSensorInfo',
|
||||
'runtime.connectionState'
|
||||
);
|
||||
my $result = centreon::vmware::common::search_entities(command => $self, view_type => 'HostSystem', properties => \@properties, filter => $filters);
|
||||
return if (!defined($result));
|
||||
|
||||
|
@ -95,7 +97,8 @@ sub run {
|
|||
foreach (@$numericSensorInfo) {
|
||||
push @{$data->{$entity_value}->{sensor_info}}, {
|
||||
status => $_->healthState->key,
|
||||
type => $_->sensorType, name => $_->name, summary => $_->healthState->summary,
|
||||
type => $_->sensorType, name => $_->name,
|
||||
summary => $_->healthState->summary,
|
||||
current_reading => $_->currentReading,
|
||||
power10 => $_->unitModifier,
|
||||
unit => $_->baseUnits
|
||||
|
@ -103,7 +106,7 @@ sub run {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
centreon::vmware::common::set_response(data => $data);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
# Copyright 2015 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 centreon::vmware::cmdlicenses;
|
||||
|
||||
use base qw(centreon::vmware::cmdbase);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::vmware::common;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(%options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{commandName} = 'licenses';
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub checkArgs {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub run {
|
||||
my $self = shift;
|
||||
|
||||
my $entries = centreon::vmware::common::get_view($self->{connector}, $self->{connector}->{session1}->get_service_content()->licenseManager);
|
||||
|
||||
my $data = {};
|
||||
if (defined($entries->licenses)) {
|
||||
foreach my $license (@{$entries->licenses}) {
|
||||
$data->{ $license->{name} } = {
|
||||
total => $license->{total},
|
||||
used => $license->{used},
|
||||
edition => $license->{editionKey}
|
||||
};
|
||||
foreach my $prop (@{$license->{properties}}) {
|
||||
if ($prop->{key} eq 'expirationMinutes') {
|
||||
$data->{ $license->{name} }->{expiration_minutes} = $prop->{value};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
centreon::vmware::common::set_response(data => $data);
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,134 @@
|
|||
# Copyright 2015 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 centreon::vmware::cmdstoragehost;
|
||||
|
||||
use base qw(centreon::vmware::cmdbase);
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use centreon::vmware::common;
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(%options);
|
||||
bless $self, $class;
|
||||
|
||||
$self->{commandName} = 'storagehost';
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub checkArgs {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (defined($options{arguments}->{esx_hostname}) && $options{arguments}->{esx_hostname} eq "") {
|
||||
centreon::vmware::common::set_response(code => 100, short_message => "Argument error: esx hostname cannot be null");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub run {
|
||||
my $self = shift;
|
||||
|
||||
my $filters = $self->build_filter(label => 'name', search_option => 'esx_hostname', is_regexp => 'filter');
|
||||
my @properties = ('name', 'runtime.connectionState', 'runtime.inMaintenanceMode', 'configManager.storageSystem');
|
||||
my $result = centreon::vmware::common::search_entities(command => $self, view_type => 'HostSystem', properties => \@properties, filter => $filters);
|
||||
return if (!defined($result));
|
||||
|
||||
my %host_names = ();
|
||||
my @host_array = ();
|
||||
my $data = {};
|
||||
foreach my $entity_view (@$result) {
|
||||
my $entity_value = $entity_view->{mo_ref}->{value};
|
||||
|
||||
$data->{$entity_value} = {
|
||||
name => $entity_view->{name},
|
||||
state => $entity_view->{'runtime.connectionState'}->val,
|
||||
inMaintenanceMode => $entity_view->{'runtime.inMaintenanceMode'},
|
||||
};
|
||||
|
||||
next if (centreon::vmware::common::is_connected(state => $entity_view->{'runtime.connectionState'}->val) == 0);
|
||||
next if (centreon::vmware::common::is_maintenance(maintenance => $entity_view->{'runtime.inMaintenanceMode'}) == 0);
|
||||
|
||||
if (defined($entity_view->{'configManager.storageSystem'})) {
|
||||
push @host_array, $entity_view->{'configManager.storageSystem'};
|
||||
$host_names{ $entity_view->{'configManager.storageSystem'}->{value} } = $entity_value;
|
||||
}
|
||||
}
|
||||
|
||||
if (scalar(@host_array) == 0) {
|
||||
centreon::vmware::common::set_response(data => $data);
|
||||
return ;
|
||||
}
|
||||
|
||||
@properties = ('storageDeviceInfo');
|
||||
my $result2 = centreon::vmware::common::get_views($self->{connector}, \@host_array, \@properties);
|
||||
return if (!defined($result2));
|
||||
|
||||
foreach my $entity (@$result2) {
|
||||
my $host_id = $host_names{ $entity->{mo_ref}->{value} };
|
||||
|
||||
if (defined($entity->storageDeviceInfo->hostBusAdapter)) {
|
||||
$data->{$host_id}->{adapters} = [];
|
||||
foreach my $dev (@{$entity->storageDeviceInfo->hostBusAdapter}) {
|
||||
push @{$data->{$host_id}->{adapters}}, {
|
||||
name => $dev->device,
|
||||
status => lc($dev->status)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (defined($entity->storageDeviceInfo->scsiLun)) {
|
||||
$data->{$host_id}->{luns} = [];
|
||||
foreach my $scsi (@{$entity->storageDeviceInfo->scsiLun}) {
|
||||
my $name = $scsi->deviceName;
|
||||
if (defined($scsi->{displayName})) {
|
||||
$name = $scsi->displayName;
|
||||
} elsif (defined($scsi->{canonicalName})) {
|
||||
$name = $scsi->canonicalName;
|
||||
}
|
||||
|
||||
push @{$data->{$host_id}->{luns}}, {
|
||||
name => $name,
|
||||
operational_states => $scsi->operationalState
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (defined($entity->storageDeviceInfo->{multipathInfo})) {
|
||||
$data->{$host_id}->{paths} = [];
|
||||
foreach my $lun (@{$entity->storageDeviceInfo->multipathInfo->lun}) {
|
||||
foreach my $path (@{$lun->path}) {
|
||||
my $state = $path->pathState;
|
||||
$state = $path->state if (defined($path->{state}));
|
||||
push @{$data->{$host_id}->{paths}}, {
|
||||
name => $path->name,
|
||||
state => lc($state)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
centreon::vmware::common::set_response(data => $data);
|
||||
}
|
||||
|
||||
1;
|
|
@ -45,7 +45,7 @@ sub init_response {
|
|||
my (%options) = @_;
|
||||
|
||||
$manager_response->{code} = 0;
|
||||
$manager_response->{vmware_connector_version} = '3.2.1';
|
||||
$manager_response->{vmware_connector_version} = '3.2.2';
|
||||
$manager_response->{short_message} = 'OK';
|
||||
$manager_response->{extra_message} = '';
|
||||
$manager_response->{identity} = $options{identity} if (defined($options{identity}));
|
||||
|
@ -486,6 +486,7 @@ sub cache_perf_counters {
|
|||
$obj_vmware->{perfcounter_speriod} = 20;
|
||||
}
|
||||
};
|
||||
|
||||
if ($@) {
|
||||
$obj_vmware->{logger}->writeLogError("'" . $obj_vmware->{whoaim} . "' $@");
|
||||
return 1;
|
||||
|
@ -552,7 +553,13 @@ sub search_entities {
|
|||
}
|
||||
return $results;
|
||||
} else {
|
||||
my ($status, $views) = find_entity_views(connector => $options{command}->{connector}, view_type => $options{view_type}, properties => $options{properties}, filter => $options{filter});
|
||||
my ($status, $views) = find_entity_views(
|
||||
connector => $options{command}->{connector},
|
||||
view_type => $options{view_type},
|
||||
properties => $options{properties},
|
||||
filter => $options{filter},
|
||||
empty_continue => $options{command}->{empty_continue}
|
||||
);
|
||||
return $views;
|
||||
}
|
||||
}
|
||||
|
@ -584,6 +591,9 @@ sub find_entity_views {
|
|||
}
|
||||
if (!defined($entity_views) || scalar(@$entity_views) == 0) {
|
||||
my $status = 0;
|
||||
if (defined($options{empty_continue})) {
|
||||
return (1, []);
|
||||
}
|
||||
if (!defined($options{output_message}) || $options{output_message} != 0) {
|
||||
set_response(code => 1, short_message => "Cannot find '$options{view_type}' object");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue