diff --git a/connectors/vmware/centreon_esx_client.pl b/connectors/vmware/centreon_esx_client.pl index 29728ae8d..932f1f11a 100644 --- a/connectors/vmware/centreon_esx_client.pl +++ b/connectors/vmware/centreon_esx_client.pl @@ -6,7 +6,7 @@ use IO::Socket; use Getopt::Long; my $PROGNAME = $0; -my $VERSION = "1.0"; +my $VERSION = "1.3"; my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); my $socket; diff --git a/connectors/vmware/centreon_esxd b/connectors/vmware/centreon_esxd index a0818441d..46a2d3149 100644 --- a/connectors/vmware/centreon_esxd +++ b/connectors/vmware/centreon_esxd @@ -17,7 +17,6 @@ use VMware::VIRuntime; use VMware::VILib; use IO::Socket; use File::Basename; -use Net::hostent; # for OOish version of gethostbyaddr use IO::Select; use POSIX ":sys_wait_h"; use Data::Dumper; @@ -61,6 +60,8 @@ require $libpath . '/command-statushost.pm'; require $libpath . '/command-swaphost.pm'; require $libpath . '/command-toolsvm.pm'; + +our $VERSION = "1.3"; our $session_id; our %sockets = (); our %child_proc; @@ -451,7 +452,7 @@ while (1) { } my $tmp_handle = ${$vsphere_server{$vsphere_name}->{'writer_two'}}; - print $tmp_handle $current_fileno . "." . $sockets{$current_fileno}->{'counter'} . "|$name|@args\n"; + print $tmp_handle $current_fileno . "." . $sockets{$current_fileno}->{'counter'} . "|$name|" . join('|', @args) . "\n"; } else { delete $sockets{$current_fileno}; $rh->send("3|Need arguments\n"); diff --git a/connectors/vmware/lib/command-snapshotvm.pm b/connectors/vmware/lib/command-snapshotvm.pm index ee84c064a..2c6f2b3f4 100644 --- a/connectors/vmware/lib/command-snapshotvm.pm +++ b/connectors/vmware/lib/command-snapshotvm.pm @@ -23,7 +23,7 @@ sub snapshotvm_compute_args { sub snapshotvm_do { my ($lvm, $older, $warn, $crit) = @_; - if ($module_date_parse_loaded == 0) { + if ($older != -1 && $module_date_parse_loaded == 0) { my $status |= $MYERRORS_MASK{'UNKNOWN'}; print_response($ERRORS{$MYERRORS{$status}} . "|Need to install DateTime::Format::ISO8601 CPAN Module.\n"); return ; @@ -45,25 +45,27 @@ sub snapshotvm_do { return ; } - # 2012-09-21T14:16:17.540469Z foreach my $snapshot (@{$$result[0]->{'snapshot.rootSnapshotList'}}) { - my $create_time = DateTime::Format::ISO8601->parse_datetime($snapshot->createTime); - if ($older != -1 && time() - $create_time->epoch > $older) { - if ($warn == 1) { - $output = 'Older snapshot problem (' . $snapshot->createTime . ').'; - $status |= $MYERRORS_MASK{'WARNING'}; - } - if ($crit == 1) { - $output = 'Older snapshot problem (' . $snapshot->createTime . ').'; - $status |= $MYERRORS_MASK{'CRITICAL'}; + if ($older != -1) { + # 2012-09-21T14:16:17.540469Z + my $create_time = DateTime::Format::ISO8601->parse_datetime($snapshot->createTime); + if (time() - $create_time->epoch > $older) { + if ($warn == 1) { + $output = 'Older snapshot problem (' . $snapshot->createTime . ').'; + $status |= $MYERRORS_MASK{'WARNING'}; + } + if ($crit == 1) { + $output = 'Older snapshot problem (' . $snapshot->createTime . ').'; + $status |= $MYERRORS_MASK{'CRITICAL'}; + } } } elsif ($older == -1) { if ($warn == 1) { - $output = 'There is at least one snapshot (' . $snapshot->createTime . ').'; + $output = 'There is at least one snapshot.'; $status |= $MYERRORS_MASK{'WARNING'}; } if ($crit == 1) { - $output = 'There is at least one snapshot (' . $snapshot->createTime . ').'; + $output = 'There is at least one snapshot.'; $status |= $MYERRORS_MASK{'CRITICAL'}; } }