git-svn-id: http://svn.merethis.net/centreon-esxd/trunk@59 a5eaa968-4c79-4d68-970d-af6011b5b055
This commit is contained in:
Quentin Garnier 2013-07-02 08:56:22 +00:00
parent 0290faf501
commit 87006e17ea
9 changed files with 80 additions and 24 deletions

View File

@ -67,6 +67,8 @@ sub new {
timeout_kill => 30,
refresh_keeper_session => 15,
port => 5700,
datastore_state_error => 'UNKNOWN',
vm_state_error => 'UNKNOWN',
vsphere_server => {
#'default' => {'url' => 'https://XXXXXX/sdk',
# 'username' => 'XXXXX',

View File

@ -61,12 +61,16 @@ sub run {
}
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);
if (!defined($result)) {
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 $values = centreon::esxd::common::generic_performance_values_historic($self->{obj_esxd},

View File

@ -61,12 +61,14 @@ sub run {
}
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);
if (!defined($result)) {
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},
$$result[0],
[{'label' => 'datastore.read.average', 'instances' => ['']},

View File

@ -61,12 +61,16 @@ sub run {
}
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);
if (!defined($result)) {
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 = ();
foreach my $entity_view (@$result) {
if (defined $entity_view->datastore) {

View File

@ -62,9 +62,11 @@ sub run {
return ;
}
return if (centreon::esxd::common::datastore_state($self->{obj_esxd}, $self->{ds}, $$result[0]->summary->accessible) == 0);
my $status = 0; # OK
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;
@ -80,10 +82,6 @@ sub run {
if ($pct > $self->{crit}) {
$status = centreon::esxd::common::errors_mask($status, 'CRITICAL');
}
} else {
$output = "Datastore '" . $self->{ds} . "' summary not accessible.";
$status = centreon::esxd::common::errors_mask($status, 'UNKNOWN');
}
$self->{obj_esxd}->print_response(centreon::esxd::common::get_status($status) . "|$output\n");
}

View File

@ -61,12 +61,16 @@ sub run {
}
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);
if (!defined($result)) {
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 $values = centreon::esxd::common::generic_performance_values_historic($self->{obj_esxd},

View File

@ -61,12 +61,16 @@ sub run {
}
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);
if (!defined($result)) {
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},
$$result[0],
[{'label' => 'mem.swapinRate.average', 'instances' => ['']},

View File

@ -41,12 +41,17 @@ sub run {
my $self = shift;
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);
if (!defined($result)) {
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 $output = '';

View File

@ -231,6 +231,39 @@ sub get_entities_host {
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 {
my ($obj_esxd, $rh, $current_fileno, $args) = @_;
my $output;