Ref #5494
git-svn-id: http://svn.merethis.net/centreon-esxd/trunk@59 a5eaa968-4c79-4d68-970d-af6011b5b055
This commit is contained in:
parent
0290faf501
commit
87006e17ea
|
@ -67,6 +67,8 @@ sub new {
|
||||||
timeout_kill => 30,
|
timeout_kill => 30,
|
||||||
refresh_keeper_session => 15,
|
refresh_keeper_session => 15,
|
||||||
port => 5700,
|
port => 5700,
|
||||||
|
datastore_state_error => 'UNKNOWN',
|
||||||
|
vm_state_error => 'UNKNOWN',
|
||||||
vsphere_server => {
|
vsphere_server => {
|
||||||
#'default' => {'url' => 'https://XXXXXX/sdk',
|
#'default' => {'url' => 'https://XXXXXX/sdk',
|
||||||
# 'username' => 'XXXXX',
|
# 'username' => 'XXXXX',
|
||||||
|
|
|
@ -61,11 +61,15 @@ sub run {
|
||||||
}
|
}
|
||||||
|
|
||||||
my %filters = ('name' => $self->{lvm});
|
my %filters = ('name' => $self->{lvm});
|
||||||
my @properties = ('name');
|
my @properties = ('name', 'runtime.connectionState', 'runtime.powerState');
|
||||||
my $result = centreon::esxd::common::get_entities_host($self->{obj_esxd}, 'VirtualMachine', \%filters, \@properties);
|
my $result = centreon::esxd::common::get_entities_host($self->{obj_esxd}, 'VirtualMachine', \%filters, \@properties);
|
||||||
if (!defined($result)) {
|
if (!defined($result)) {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return if (centreon::esxd::common::vm_state($self->{obj_esxd}, $self->{lvm},
|
||||||
|
$$result[0]->{'runtime.connectionState'}->val,
|
||||||
|
$$result[0]->{'runtime.powerState'}->val) == 0);
|
||||||
|
|
||||||
my @instances = ('*');
|
my @instances = ('*');
|
||||||
|
|
||||||
|
|
|
@ -61,11 +61,13 @@ sub run {
|
||||||
}
|
}
|
||||||
|
|
||||||
my %filters = ('summary.name' => $self->{ds});
|
my %filters = ('summary.name' => $self->{ds});
|
||||||
my @properties = ('summary.name');
|
my @properties = ('summary.name', 'summary.accessible');
|
||||||
my $result = centreon::esxd::common::get_entities_host($self->{obj_esxd}, 'Datastore', \%filters, \@properties);
|
my $result = centreon::esxd::common::get_entities_host($self->{obj_esxd}, 'Datastore', \%filters, \@properties);
|
||||||
if (!defined($result)) {
|
if (!defined($result)) {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return if (centreon::esxd::common::datastore_state($self->{obj_esxd}, $self->{ds}, $$result[0]->{'summary.accessible'}) == 0);
|
||||||
|
|
||||||
my $values = centreon::esxd::common::generic_performance_values_historic($self->{obj_esxd},
|
my $values = centreon::esxd::common::generic_performance_values_historic($self->{obj_esxd},
|
||||||
$$result[0],
|
$$result[0],
|
||||||
|
|
|
@ -61,11 +61,15 @@ sub run {
|
||||||
}
|
}
|
||||||
|
|
||||||
my %filters = ('name' => $self->{lvm});
|
my %filters = ('name' => $self->{lvm});
|
||||||
my @properties = ('datastore');
|
my @properties = ('datastore', 'runtime.connectionState', 'runtime.powerState');
|
||||||
my $result = centreon::esxd::common::get_entities_host($self->{obj_esxd}, 'VirtualMachine', \%filters, \@properties);
|
my $result = centreon::esxd::common::get_entities_host($self->{obj_esxd}, 'VirtualMachine', \%filters, \@properties);
|
||||||
if (!defined($result)) {
|
if (!defined($result)) {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return if (centreon::esxd::common::vm_state($self->{obj_esxd}, $self->{lvm},
|
||||||
|
$$result[0]->{'runtime.connectionState'}->val,
|
||||||
|
$$result[0]->{'runtime.powerState'}->val) == 0);
|
||||||
|
|
||||||
my @ds_array = ();
|
my @ds_array = ();
|
||||||
foreach my $entity_view (@$result) {
|
foreach my $entity_view (@$result) {
|
||||||
|
|
|
@ -61,28 +61,26 @@ sub run {
|
||||||
if (!defined($result)) {
|
if (!defined($result)) {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return if (centreon::esxd::common::datastore_state($self->{obj_esxd}, $self->{ds}, $$result[0]->summary->accessible) == 0);
|
||||||
|
|
||||||
my $status = 0; # OK
|
my $status = 0; # OK
|
||||||
my $output = "";
|
my $output = "";
|
||||||
if ($$result[0]->summary->accessible == 1) {
|
|
||||||
my $dsName = $$result[0]->summary->name;
|
|
||||||
my $capacity = $$result[0]->summary->capacity;
|
|
||||||
my $free = $$result[0]->summary->freeSpace;
|
|
||||||
my $pct = ($capacity - $free) / $capacity * 100;
|
|
||||||
|
|
||||||
my $usedD = ($capacity - $free) / 1024 / 1024 / 1024;
|
|
||||||
my $sizeD = $capacity / 1024 / 1024 / 1024;
|
|
||||||
|
|
||||||
$output = "Datastore $dsName - used ".sprintf("%.2f", $usedD)." Go / ".sprintf("%.2f", $sizeD)." Go (".sprintf("%.2f", $pct)." %) |used=".($capacity - $free)."o;;;0;".$capacity." size=".$capacity."o\n";
|
my $dsName = $$result[0]->summary->name;
|
||||||
if ($pct >= $self->{warn}) {
|
my $capacity = $$result[0]->summary->capacity;
|
||||||
$status = centreon::esxd::common::errors_mask($status, 'WARNING');
|
my $free = $$result[0]->summary->freeSpace;
|
||||||
}
|
my $pct = ($capacity - $free) / $capacity * 100;
|
||||||
if ($pct > $self->{crit}) {
|
|
||||||
$status = centreon::esxd::common::errors_mask($status, 'CRITICAL');
|
my $usedD = ($capacity - $free) / 1024 / 1024 / 1024;
|
||||||
}
|
my $sizeD = $capacity / 1024 / 1024 / 1024;
|
||||||
} else {
|
|
||||||
$output = "Datastore '" . $self->{ds} . "' summary not accessible.";
|
$output = "Datastore $dsName - used ".sprintf("%.2f", $usedD)." Go / ".sprintf("%.2f", $sizeD)." Go (".sprintf("%.2f", $pct)." %) |used=".($capacity - $free)."o;;;0;".$capacity." size=".$capacity."o\n";
|
||||||
$status = centreon::esxd::common::errors_mask($status, 'UNKNOWN');
|
if ($pct >= $self->{warn}) {
|
||||||
|
$status = centreon::esxd::common::errors_mask($status, 'WARNING');
|
||||||
|
}
|
||||||
|
if ($pct > $self->{crit}) {
|
||||||
|
$status = centreon::esxd::common::errors_mask($status, 'CRITICAL');
|
||||||
}
|
}
|
||||||
$self->{obj_esxd}->print_response(centreon::esxd::common::get_status($status) . "|$output\n");
|
$self->{obj_esxd}->print_response(centreon::esxd::common::get_status($status) . "|$output\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,11 +61,15 @@ sub run {
|
||||||
}
|
}
|
||||||
|
|
||||||
my %filters = ('name' => $self->{lvm});
|
my %filters = ('name' => $self->{lvm});
|
||||||
my @properties = ('summary.config.memorySizeMB');
|
my @properties = ('summary.config.memorySizeMB', 'runtime.connectionState', 'runtime.powerState');
|
||||||
my $result = centreon::esxd::common::get_entities_host($self->{obj_esxd}, 'VirtualMachine', \%filters, \@properties);
|
my $result = centreon::esxd::common::get_entities_host($self->{obj_esxd}, 'VirtualMachine', \%filters, \@properties);
|
||||||
if (!defined($result)) {
|
if (!defined($result)) {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return if (centreon::esxd::common::vm_state($self->{obj_esxd}, $self->{lvm},
|
||||||
|
$$result[0]->{'runtime.connectionState'}->val,
|
||||||
|
$$result[0]->{'runtime.powerState'}->val) == 0);
|
||||||
|
|
||||||
my $memory_size = $$result[0]->{'summary.config.memorySizeMB'} * 1024 * 1024;
|
my $memory_size = $$result[0]->{'summary.config.memorySizeMB'} * 1024 * 1024;
|
||||||
|
|
||||||
|
|
|
@ -61,11 +61,15 @@ sub run {
|
||||||
}
|
}
|
||||||
|
|
||||||
my %filters = ('name' => $self->{lvm});
|
my %filters = ('name' => $self->{lvm});
|
||||||
my @properties = ('name');
|
my @properties = ('name', 'runtime.connectionState', 'runtime.powerState');
|
||||||
my $result = centreon::esxd::common::get_entities_host($self->{obj_esxd}, 'VirtualMachine', \%filters, \@properties);
|
my $result = centreon::esxd::common::get_entities_host($self->{obj_esxd}, 'VirtualMachine', \%filters, \@properties);
|
||||||
if (!defined($result)) {
|
if (!defined($result)) {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return if (centreon::esxd::common::vm_state($self->{obj_esxd}, $self->{lvm},
|
||||||
|
$$result[0]->{'runtime.connectionState'}->val,
|
||||||
|
$$result[0]->{'runtime.powerState'}->val) == 0);
|
||||||
|
|
||||||
my $values = centreon::esxd::common::generic_performance_values_historic($self->{obj_esxd},
|
my $values = centreon::esxd::common::generic_performance_values_historic($self->{obj_esxd},
|
||||||
$$result[0],
|
$$result[0],
|
||||||
|
|
|
@ -41,12 +41,17 @@ sub run {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
my %filters = ('name' => $self->{lvm});
|
my %filters = ('name' => $self->{lvm});
|
||||||
my @properties = ('summary.guest.toolsStatus');
|
my @properties = ('summary.guest.toolsStatus', 'runtime.connectionState', 'runtime.powerState');
|
||||||
my $result = centreon::esxd::common::get_entities_host($self->{obj_esxd}, 'VirtualMachine', \%filters, \@properties);
|
my $result = centreon::esxd::common::get_entities_host($self->{obj_esxd}, 'VirtualMachine', \%filters, \@properties);
|
||||||
if (!defined($result)) {
|
if (!defined($result)) {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return if (centreon::esxd::common::vm_state($self->{obj_esxd}, $self->{lvm},
|
||||||
|
$$result[0]->{'runtime.connectionState'}->val,
|
||||||
|
$$result[0]->{'runtime.powerState'}->val) == 0);
|
||||||
|
|
||||||
|
|
||||||
my $status = 0; # OK
|
my $status = 0; # OK
|
||||||
my $output = '';
|
my $output = '';
|
||||||
|
|
||||||
|
|
|
@ -231,6 +231,39 @@ sub get_entities_host {
|
||||||
return $entity_views;
|
return $entity_views;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub datastore_state {
|
||||||
|
my ($obj_esxd, $ds, $accessible) = @_;
|
||||||
|
|
||||||
|
if ($accessible !~ /^true|1$/) {
|
||||||
|
my $output = "Datastore '" . $ds . "' not accessible. Can be disconnected.";
|
||||||
|
my $status = errors_mask(0, $obj_esxd->{centreonesxd_config}->{datastore_state_error});
|
||||||
|
$obj_esxd->print_response(get_status($status) . "|$output\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub vm_state {
|
||||||
|
my ($obj_esxd, $vm, $connection_state, $power_state) = @_;
|
||||||
|
|
||||||
|
if ($connection_state !~ /^connected$/i) {
|
||||||
|
my $output = "VM '" . $vm . "' not connected. Current Connection State: '$connection_state'.";
|
||||||
|
my $status = errors_mask(0, $obj_esxd->{centreonesxd_config}->{vm_state_error});
|
||||||
|
$obj_esxd->print_response(get_status($status) . "|$output\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($power_state !~ /^poweredOn$/i) {
|
||||||
|
my $output = "VM '" . $vm . "' not running. Current Power State: '$power_state'.";
|
||||||
|
my $status = errors_mask(0, $obj_esxd->{centreonesxd_config}->{vm_state_error});
|
||||||
|
$obj_esxd->print_response(get_status($status) . "|$output\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
sub stats_info {
|
sub stats_info {
|
||||||
my ($obj_esxd, $rh, $current_fileno, $args) = @_;
|
my ($obj_esxd, $rh, $current_fileno, $args) = @_;
|
||||||
my $output;
|
my $output;
|
||||||
|
|
Loading…
Reference in New Issue