diff --git a/connectors/vmware/centreon_esx_client.pl b/connectors/vmware/centreon_esx_client.pl index acefa1625..952e06d0a 100644 --- a/connectors/vmware/centreon_esx_client.pl +++ b/connectors/vmware/centreon_esx_client.pl @@ -129,6 +129,9 @@ sub print_usage () { print " -w (--warning) Warning Threshold (default none)\n"; print " -c (--critical) Critical Threshold (default none)\n"; print "\n"; + print "'uptimehost':\n"; + print " -e (--esx-host) Esx Host to check (required)\n"; + print "\n"; print "'cpuvm':\n"; print " --vm VM to check (required)\n"; print " -w (--warning) Warning Threshold in percent (default 80)\n"; @@ -407,6 +410,19 @@ sub countvmhost_get_str { return "countvmhost|" . $OPTION{'vsphere'} . "|" . $OPTION{'esx-host'} . "|" . $OPTION{'warning'} . "|" . $OPTION{'critical'}; } +sub uptimehost_check_arg { + if (!defined($OPTION{'esx-host'})) { + print "Option --esx-host is required\n"; + print_usage(); + exit $ERRORS{'UNKNOWN'}; + } + return 0; +} + +sub uptimehost_get_str { + return "uptimehost|" . $OPTION{'vsphere'} . "|" . $OPTION{'esx-host'}; +} + sub cpuvm_check_arg { if (!defined($OPTION{'vm'})) { print "Option --vm is required\n"; @@ -591,7 +607,7 @@ if (!defined($OPTION{'usage'})) { print_usage(); exit $ERRORS{'UNKNOWN'}; } -if ($OPTION{'usage'} !~ /^(healthhost|datastore-usage|datastore-io|maintenancehost|statushost|cpuhost|datastoreshost|nethost|memhost|swaphost|countvmhost|cpuvm|toolsvm|snapshotvm|datastoresvm|memvm|swapvm|listhost|listdatastore|listnichost|getmap|stats)$/) { +if ($OPTION{'usage'} !~ /^(healthhost|datastore-usage|datastore-io|maintenancehost|statushost|cpuhost|datastoreshost|nethost|memhost|swaphost|countvmhost|uptimehost|cpuvm|toolsvm|snapshotvm|datastoresvm|memvm|swapvm|listhost|listdatastore|listnichost|getmap|stats)$/) { print "Usage value is unknown\n"; print_usage(); exit $ERRORS{'UNKNOWN'}; diff --git a/connectors/vmware/centreon_esxd b/connectors/vmware/centreon_esxd index 5c6bdd2aa..7a2b5679a 100644 --- a/connectors/vmware/centreon_esxd +++ b/connectors/vmware/centreon_esxd @@ -2,6 +2,7 @@ BEGIN { + $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = "Net::SSL"; $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0; $ENV{ESX_SYSLOGD_LOAD} = 0; eval 'require Unix::Syslog;'; @@ -60,6 +61,7 @@ require $libpath . '/command-statushost.pm'; require $libpath . '/command-swaphost.pm'; require $libpath . '/command-swapvm.pm'; require $libpath . '/command-toolsvm.pm'; +require $libpath . '/command-uptimehost.pm'; our $VERSION = "1.3"; @@ -109,6 +111,7 @@ our %checks_descr = ( "memhost" => {'arg' => \&memhost_check_args, 'compute' => \&memhost_compute_args, 'exec' => \&memhost_do}, "swaphost" => {'arg' => \&swaphost_check_args, 'compute' => \&swaphost_compute_args, 'exec' => \&swaphost_do}, "countvmhost" => {'arg' => \&countvmhost_check_args, 'compute' => \&countvmhost_compute_args, 'exec' => \&countvmhost_do}, + "uptimehost" => {'arg' => \&uptimehost_check_args, 'compute' => \&uptimehost_compute_args, 'exec' => \&uptimehost_do}, "cpuvm" => {'arg' => \&cpuvm_check_args, 'compute' => \&cpuvm_compute_args, 'exec' => \&cpuvm_do}, "toolsvm" => {'arg' => \&toolsvm_check_args, 'compute' => \&toolsvm_compute_args, 'exec' => \&toolsvm_do}, "snapshotvm" => {'arg' => \&snapshotvm_check_args, 'compute' => \&snapshotvm_compute_args, 'exec' => \&snapshotvm_do}, diff --git a/connectors/vmware/lib/command-snapshotvm.pm b/connectors/vmware/lib/command-snapshotvm.pm index 2c6f2b3f4..0d16c4fc8 100644 --- a/connectors/vmware/lib/command-snapshotvm.pm +++ b/connectors/vmware/lib/command-snapshotvm.pm @@ -47,6 +47,12 @@ sub snapshotvm_do { foreach my $snapshot (@{$$result[0]->{'snapshot.rootSnapshotList'}}) { if ($older != -1) { + if ($module_date_parse_loaded == 0) { + my $status |= $MYERRORS_MASK{'UNKNOWN'}; + print_response($ERRORS{$MYERRORS{$status}} . "|Need to install DateTime::Format::ISO8601 Perl Module.\n"); + return ; + } + # 2012-09-21T14:16:17.540469Z my $create_time = DateTime::Format::ISO8601->parse_datetime($snapshot->createTime); if (time() - $create_time->epoch > $older) {