[apps::vmware::connector::plugin]: Issue with ESX-Uptime-Global plugin when ESXi host is in a different timezone
Hello,
I’m facing an issue with the ESX-Uptime-Global mode in the VMware vCenter connector. One of my ESXi hosts is located in Japan (UTC+9), while my Centreon central server is in France (UTC+1/UTC+2 depending on DST).
When this ESXi host reboots, the plugin reports a negative uptime value, which seems to be caused by the timezone difference between the host and the Centreon poller.
Expected behavior: The plugin should calculate the uptime correctly regardless of the timezone, ideally by relying only on absolute values (e.g. UTC) rather than local time.
Current behavior:
ESXi in Japan (UTC+9)
Centreon Central in France (UTC+1/UTC+2)
After a reboot, the uptime check returns a negative value.
Question: Is there an existing option to handle timezone offsets in the plugin, or would it be possible to add such a feature?
Thanks in advance for your help!
Hi, can you add these two lines
use Data::Dumper;
print STDERR Dumper($response->{data}->{$host_id});
at this place in the code of /usr/lib/centreon/plugins/centreon_vmware_connector_client.pl:
foreach my $host_id (keys %{$response->{data}}) {
my $host_name = $response->{data}->{$host_id}->{name};
my $offset;
if (defined($response->{data}->{$host_id}->{boot_time})) {
use Data::Dumper;
print STDERR Dumper($response->{data}->{$host_id});
my $timestamp = Date::Parse::str2time($response->{data}->{$host_id}->{boot_time});
$offset = time() - $timestamp;
}
$self->{host}->{$host_name} = {
display => $host_name,
state => $response->{data}->{$host_id}->{state},
offset => $offset,
date => $response->{data}->{$host_id}->{boot_time}
};
}
And then run the plugin again to get the exact string returned by the vCenter.
Hi,
I’ve added the two debug lines as requested in /usr/lib/centreon/plugins/centreon_vmware_connector_client.pl and ran the plugin again. Here is the output of the Dumper for the ESXi host in Japan:
$VAR1 = {
'state' => 'connected',
'name' => 'JAPESX01',
'boot_time' => '2025-09-09T21:30:34.508821Z'
};
OK: Host 'JAPESX01' : status connected, Uptime: 23 day(s) | 'uptime'=2024414.49s;;1800:;;
Please let me know if you need me to run additional tests or provide more details.
Thanks!
Hi @JBElect, The value given by VMware indicates that the server rebooted at '2025-09-09T21:30:34.508821Z' (Z means UTC). Can you check if this value is right or wrong?