git-svn-id: http://svn.merethis.net/centreon-esxd/trunk@48 a5eaa968-4c79-4d68-970d-af6011b5b055
This commit is contained in:
Quentin Garnier 2013-02-04 16:49:21 +00:00
parent dffa8b3a7b
commit d153fe1bfd
2 changed files with 44 additions and 1 deletions

View File

@ -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;

View 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;