[ZBX-15142] LC_ALL=en_US.UTF-8 locale on server causes issue for vmware monitoring - Cannot parse DateTime value Created: 2018 Nov 07  Updated: 2024 Apr 10  Resolved: 2018 Nov 08

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Proxy (P), Server (S)
Affects Version/s: 3.0.23, 4.0.1
Fix Version/s: 3.0.24rc1, 4.0.2rc1, 4.2.0alpha1, 4.2 (plan)

Type: Problem report Priority: Blocker
Reporter: Oleksii Zagorskyi Assignee: Michael Veksler
Resolution: Fixed Votes: 0
Labels: locale, regression, vmware
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Causes
caused by ZBX-12990 VMware Datastore usage mismatch Closed
Duplicate
Team: Team A
Team: Team A
Sprint: Sprint 46, Nov 2018
Story Points: 0.125

 Description   

Zabbix server generates an request, having these XML tags:

<ns0:startTime>2018-11-06T08:14:33 AMZ</ns0:startTime>

which causes lots of such errors:

 10763:20181106:111434.165 vmware_service_retrieve_perf_counters() SOAP response: <?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
 xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault><faultcode>ServerFaultCode</faultcode><faultstring>
Cannot parse &quot;2018-11-06T08:14:33 AMZ&quot; as a DateTime value

while parsing serialized value of type vmodl.DateTime
at line 1, column 415

while parsing property &quot;startTime&quot; of static type dateTime

while parsing serialized DataObject of type vim.PerformanceManager.QuerySpec
at line 1, column 345

while parsing call information for method QueryPerf
at line 1, column 274

while parsing SOAP body
at line 1, column 264

while parsing SOAP envelope
at line 1, column 38

while parsing HTTP request for method queryStats
on object of type vim.PerformanceManager
at line 1, column 0</faultstring><detail><InvalidRequestFault xmlns="urn:vim25" xsi:type="InvalidRequest"></InvalidRequestFault></detail></soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
 10763:20181106:111434.166 End of vmware_service_retrieve_perf_counters()

It was a puzzle what the AMZ timezone is. Later we spot that it changed to PMZ and we understood that it's related to en_US locale, where we know about AM/PM.

Yes, our zabbix server is configured to have LC_ALL=en_US.UTF-8 locale

Related code is:

			{
				time_t	st_raw;
				struct	tm st;
				char	st_str[ZBX_XML_DATETIME];

				/* add startTime for entity performance counter request for decrease XML data load */
				st_raw = zbx_time() - SEC_PER_HOUR;
				st = *gmtime(&st_raw);
				strftime(st_str, sizeof(st_str), "%Y-%m-%dT%XZ", &st);
				zbx_snprintf_alloc(&tmp, &tmp_alloc, &tmp_offset, "<ns0:startTime>%s</ns0:startTime>",
						st_str);
			}

where %X is probably a mistake, better option would be %T to have timestamp in  ISO 8601
http://man7.org/linux/man-pages/man3/strftime.3.html

mentioned code was implemented in -ZBX-12990-

We changed in is sources (changing %X to %T), recompiled and it resolved our issue.

 

The fix tested on VMware 6.0 and 6.7



 Comments   
Comment by Glebs Ivanovskis [ 2018 Nov 07 ]

May be a good idea to replace gmtime() with gmtime_r() as well.

Comment by Michael Veksler [ 2018 Nov 08 ]

Available in:

  • 3.0.24rc1 r86661
  • 4.0.2rc1 r86662
  • 4.2.0alpha1 (trunk) r86663
Generated at Fri Apr 19 18:59:29 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.