mirror of
https://github.com/centreon/centreon-plugins.git
synced 2025-07-23 05:35:01 +02:00
Fix #4861
git-svn-id: http://svn.merethis.net/centreon-esxd/trunk@48 a5eaa968-4c79-4d68-970d-af6011b5b055
This commit is contained in:
parent
dffa8b3a7b
commit
d153fe1bfd
@ -64,7 +64,7 @@ require $libpath . '/command-toolsvm.pm';
|
||||
require $libpath . '/command-uptimehost.pm';
|
||||
|
||||
|
||||
our $VERSION = "1.3";
|
||||
our $VERSION = "1.3.1";
|
||||
our $session_id;
|
||||
our %sockets = ();
|
||||
our %child_proc;
|
||||
|
43
connectors/vmware/lib/command-uptimehost.pm
Normal file
43
connectors/vmware/lib/command-uptimehost.pm
Normal file
@ -0,0 +1,43 @@
|
||||
sub uptimehost_check_args {
|
||||
my ($lhost) = @_;
|
||||
if (!defined($lhost) || $lhost eq "") {
|
||||
writeLogFile(LOG_ESXD_ERROR, "ARGS error: need host name\n");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub uptimehost_compute_args {
|
||||
my $lhost = $_[0];
|
||||
return ($lhost);
|
||||
}
|
||||
|
||||
sub uptimehost_do {
|
||||
my ($lhost) = @_;
|
||||
|
||||
my %filters = ('name' => $lhost);
|
||||
my @properties = ('runtime.bootTime');
|
||||
my $result = get_entities_host('HostSystem', \%filters, \@properties);
|
||||
if (!defined($result)) {
|
||||
return ;
|
||||
}
|
||||
|
||||
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 ;
|
||||
}
|
||||
|
||||
my $create_time = DateTime::Format::ISO8601->parse_datetime($$result[0]->{'runtime.bootTime'});
|
||||
my $diff_time = time() - $create_time->epoch;
|
||||
my $days = int($diff_time / 60 / 60 / 24);
|
||||
|
||||
my $output = '';
|
||||
my $status = 0; # OK
|
||||
|
||||
$output = "Uptime (in day): $days|uptime=" . $days . "day(s)\n";
|
||||
|
||||
print_response($ERRORS{$MYERRORS{$status}} . "|$output\n");
|
||||
}
|
||||
|
||||
1;
|
Loading…
x
Reference in New Issue
Block a user