[ZBX-11512] Zabbix agent is affected by number separators Created: 2016 Nov 22  Updated: 2017 Nov 23  Resolved: 2016 Dec 13

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Agent (G)
Affects Version/s: 2.2.15, 3.0.5, 3.2.1
Fix Version/s: None

Type: Incident report Priority: Trivial
Reporter: Alexey Pustovalov Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: locale
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux


Attachments: File num_locale.c     File setlocale.c    
Issue Links:
Duplicate

 Description   

Depends on LANG in OS, number separator could be comma or dot. Zabbix does not work with commas. For example, lv_LV and ru_RU use default number separator as comma.

Received value [97,677710] is not suitable for value type [Numeric (float)]


 Comments   
Comment by Alexey Pustovalov [ 2016 Nov 22 ]
$ printf "test %f\n" 0,214
test 0,214000

$ env | grep LC_NU
LC_NUMERIC=da_DK

$ unset LC_NUMERIC      

$ printf "test %f\n" 0,214
-bash: printf: 0,214: invalid number
test 0.000000

$ printf "test %f\n" 0.214
test 0.214000

For some numeric conversions a radix character ("decimal point") or thousands' grouping character is used. The actual character used depends on the LC_NUMERIC part of the locale. The POSIX locale uses '.' as radix character, and does not have a grouping character. Thus,

printf("%'.2f", 1234567.89);
results in "1234567.89" in the POSIX locale, in "1234567,89" in the nl_NL locale, and in "1.234.567,89" in the da_DK locale.

Comment by richlv [ 2016 Nov 22 ]

ha, i mentioned that on my zabbixconf talk this year

but that's not a zabbix agent problem directly, is it ?
it only happens with userparameters. it is also not limited to the agent - same thing with external checks on server/proxy.

not much could be done besides setting locale in the initscripts or making zabbix accept comma (optionally)

edit : ah, just accepting the comma would not be enough as the separators could still mess up everything...

Comment by Aleksandrs Saveljevs [ 2016 Dec 13 ]

Could not reproduce the problem so far. Variables LC_XXX have no effect without a call to setlocale(), but we do not invoke setlocale() ourselves.

wiper and glebs.ivanovskis had an idea that setlocale() may be called by a library or a module that Zabbix agent uses. In order to find this out, they have prepared setlocale.c file (and an accompanying num_locale.c for testing, see attached).

In order to use this file, first compile the shared library from setlocale.c:

$ gcc setlocale.c -shared -fPIC -o setlocale.so -ldl

The purpose of this shared library is to track calls to setlocale(). So the next step would be to launch a Zabbix agent or another Zabbix binary as follows:

$ LD_PRELOAD=/path/to/setlocale.so zabbix_agentd ...

If there are any calls to setlocale(), they should appear in the Zabbix log file. Here is an example of how it should look like using num_locale.c file:

$ gcc num_locale.c -o num_locale
$ LD_PRELOAD=./setlocale.so ./num_locale
Probing environment variable LC_NUMERIC...
System locale is: "(null)"

Probing runtime locale settings...........
setlocale(1, "(null)") = "C"
./setlocale.so(+0x8d2)[0x7fde422078d2]
./setlocale.so(+0x945)[0x7fde42207945]
./setlocale.so(setlocale+0x27)[0x7fde4220796e]
./num_locale[0x400677]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7fde41e7db45]
./num_locale[0x400559]
Runtime locale is: "C"; numbers look like: 1234567.8900

Setting runtime locale from environment...
setlocale(1, "") = "ru_RU.utf8"
./setlocale.so(+0x8d2)[0x7fde422078d2]
./setlocale.so(setlocale+0x27)[0x7fde4220796e]
./num_locale[0x4006c2]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7fde41e7db45]
./num_locale[0x400559]
Runtime locale is: "ru_RU.utf8"; numbers look like: 1 234 567,8900
Comment by Aleksandrs Saveljevs [ 2016 Dec 13 ]

If the issue appears again, we can use the method documented above to investigate. For now, this issue should be closed as "Cannot Reproduce".

Comment by Aleksandrs Saveljevs [ 2016 Dec 13 ]

It does not seem to be mentioned in the issue description, but values like 97,677710 are returned by built-in items like system.cpu.util[].

Comment by Glebs Ivanovskis (Inactive) [ 2017 Aug 10 ]

ZBX-12383 provides an evidence that some of ODBC drivers call setlocale().

Comment by Glebs Ivanovskis (Inactive) [ 2017 Nov 23 ]

ZBX-13053 provides an evidence that Net-SNMP library calls setlocale() too.

Generated at Fri Apr 04 10:24:42 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.