[ZBX-15224] Zabbix 4.0 is not collecting data with special characters Created: 2018 Nov 27  Updated: 2024 Apr 10  Resolved: 2019 Jan 05

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: 4.0.1
Fix Version/s: 4.0.4rc1, 4.2.0alpha3, 4.2 (plan)

Type: Problem report Priority: Major
Reporter: Rodney Antonio Ramos Assignee: Vladislavs Sokurenko
Resolution: Fixed Votes: 1
Labels: 4.0.1, items, server
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Zabbix Server, Proxy and agent all in 4.0.1 version.


Attachments: PNG File charset_problem.png     PNG File charset_problem_2.png     File teste.txt.iso88591     File teste.txt.utf8    
Team: Team A
Team: Team A
Sprint: Sprint 47, Dec 2018
Story Points: 0.5

 Description   

I have a UserParameter to collect the "ipconfig /all" from Windows Server like that:

UserParameter=ipconfig,ipconfig /all

However I started to have problem with this UserParameter after the upgrade from 3.2.10 to 4.0.1 version last Saturday.

The problem is relatated with special characters, because some servers are installed in Portuguese Language and the result of "ipconfig /all" is:

"Configuração de IP do Windows ...."

However in the item Latest data is only "Configura" string. Eveything after the "ç" character is ignored.

 

Can anyone help, please?

 



 Comments   
Comment by Alexey Pustovalov [ 2018 Nov 27 ]

Do you have Zabbix database with utf8 codepage?

Comment by Rodney Antonio Ramos [ 2018 Nov 27 ]

Yes.

 - Zabbix Server DB:

Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8

  • Zabbix Proxy DB:

Server characterset: latin1
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8

 

The database codepage is the same as in 3.2.10 version, and the problem didn´t happen in this version, only when I´ve made the upgrade to the 4.0.1 version.

 

 

Comment by Rodney Antonio Ramos [ 2018 Nov 28 ]

I´ve made a simple test now. I´ve created a file called "/tmp/test.txt" with the line:

"Configuração"

After that, I´ve add the UserParameter:

UserParameter=test,cat /tmp/test.txt

If the file charset is UTF-8, Zabbix collects everyhing OK.

If the file charset is ISO-88591, Zabbix collects only "Configura".

This means that there is a problem with Zabbix 4.0 when collecting data from a charset different of UTF-8.

Comment by Alexey Pustovalov [ 2018 Nov 28 ]

Zabbix works with UTF-8 only: https://www.zabbix.com/documentation/4.0/manual/installation/requirements/best_practices?#utf-8_encoding. Please convert it to UTF-8.

Comment by Oleksii Zagorskyi [ 2018 Nov 28 ]

Show result of this SQL on zabbix database server:

show create database zabbix;
Comment by Rodney Antonio Ramos [ 2018 Nov 29 ]

MariaDB [(none)]> show create database zabbix;

Database Create Database
zabbix CREATE DATABASE `zabbix` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8mb4_bin */

 

The same for the Zabbix Server and Zabbix Proxy.

Comment by Oleksii Zagorskyi [ 2018 Dec 06 ]

DB is created correctly. Schema should be fine.

Attach please here the /tmp/test.txt file as is.

Comment by Glebs Ivanovskis [ 2018 Dec 07 ]

I have a suspicion that the problem can be due to encoding used by Windows shell. E.g. if it uses UTF-16 and Zabbix agent does not do any conversion (because there is no way agent could know the encoding) then it will send the result as is, with 0x00 and 0xC7 bytes. As we know, byte 0x00 is used in Zabbix agent protocol to delimit value and optional error message and therefore Zabbix server/proxy takes only the text up to "ç" as the result discarding the rest (because it does not look past 0x00 byte unless agent returns ZBX_NOTSUPPORTED). I would try to capture traffic between server/proxy and agent to see what's there. I believe zabbix_get can be used as well to make capturing easier.

Comment by Rodney Antonio Ramos [ 2018 Dec 07 ]

I´ve attached 2 files: teste.txt.utf8 and teste.txt.iso88591.

With the teste.txt.utf8 everuthing is OK. With the teste.txt.iso88591 not.

It is a very simple test, running in a Linux server. Everyone can replicate it.

Again, I ddin´t have this problema with Zabbix 3.x.

Thanks.

 

Comment by Glebs Ivanovskis [ 2018 Dec 07 ]

Again, I ddin´t have this problema with Zabbix 3.x.

Sorry, hard to believe. I'll put my money on the fact that if you downgrade your agent to 3.x your problem won't go away.

If I do cat teste.txt.iso88591 my shell displays non-ASCII characters incorrectly, which is kinda expected. If you want to read files with Zabbix agent you need to use vfs.file.contents[] item where you can specify encoding.

I think this issue should be closed as a duplicate of ZBXNEXT-878.

Comment by Rodney Antonio Ramos [ 2018 Dec 07 ]

I do not agree. The issue is not the same. The problem is with version 4.x.

I could see  in the latest data. After the upgrade the values were cut after special characters. Before the upgrade, not.

I keep data on history only for 7 days. So, I don´t have old values anymore.

Anyway, I´ve used the "teste.txt" files just to show the problem. In production, my item doesn´t read a file, but run "ipconfig /all" in Windows Server. I need this information. As some Windows are in Portuguese, that´s the problem.

As I said, it is very simple to replicate this problem using this "teste.txt" files. 

Comment by Glebs Ivanovskis [ 2018 Dec 07 ]

Can you downgrade the agent to 3.x and demonstrate Latest data with values of your problematic item and agent.version before and after the downgrade?

Can you capture network traffic between zabbix_get and your agent when doing that problematic check?

Comment by Rodney Antonio Ramos [ 2018 Dec 07 ]

The agent is in 3.0.3 version.

I´ve made the test with zabbix_get, and there is no problem, I mean, no characters is cut. (see below)

The characters are changed, but it is normal, because my shell is in iso88591.

 

UTF-8 file

  1. zabbix_get -s host -k teste
    Configuração

ISO88591 file

  1. zabbix_get -s host -k teste
    Configuração

I´ve attached a image with the Latest data of this item. The times when we see "Configura", the charset of the "teste.txt" is iso8859-1. The times when we see "Configuração", the charset of the "teste.txt" is utf-8.

 

Comment by Glebs Ivanovskis [ 2018 Dec 07 ]

Is it active or passive check?

I've tried to reproduce the issue on Linux agent using your test file in "wrong" encoding system.run[cat ...], I've tried passive check on Zabbix server, passive and active on proxy... Result is the same - non-UTF-8 characters are replaced with "?" characters and that's it, no characters are lost. I was using current trunk with MySQL.

This is very puzzling... You experience the issue with 3.x agent, which means that this is a server/proxy issue. But on the other hand I wasn't able to reproduce it on Linux, which means this must be Windows-specific and therefore agent problem. How can this be possible? Of course, the chances are that MySQL and MariaDB behave differently...

Comment by Rodney Antonio Ramos [ 2018 Dec 10 ]

My environment is: Sever - 4.0.1, Proxy - 4.0.1 (active), Agent - 3.0.3 (item Zabbix agent active).

I´ve changed the item to "Zabbix agent" (passive) and the characters were replaced to "?', what is the correct way.

This means that the problem happens only with "Zabbix agent active" items.

I´ve upgrade the agent to 4.0.2, but the problem remains.

I´ve attached the screen with the latest data collected, zabbix agent active and passive.

 

 

Comment by Glebs Ivanovskis [ 2018 Dec 13 ]

I'll redo my testing. Perhaps I wasn't patient enough and my proxy hasn't received configuration with Zabbix agent (active) item type.

Comment by Glebs Ivanovskis [ 2018 Dec 13 ]

With active agent I have the following errors in proxy log (same story with agents compiled from trunk, 3.4 and 3.0):

  7168:20181213:221023.519 [Z3005] query failed: [1366] Incorrect string value: '\xE7\xE3o' for column 'value' at row 1 [insert into proxy_history (itemid,clock,ns,value) values (28250,1544731821,785229755,'Configura��o');

Nothing reaches server.

mysql> show create database trunk_mysql_p\G
*************************** 1. row ***************************
       Database: trunk_mysql_p
Create Database: CREATE DATABASE `trunk_mysql_p` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */
1 row in set (0.00 sec)

Maybe it is MariaDB which truncates the result starting at invalid character?

Like described here. However, I'm not sure, that it is NO_ENGINE_SUBSTITUTION to blame. My settings:

mysql> select @@sql_mode\G
*************************** 1. row ***************************
@@sql_mode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
1 row in set (0.00 sec)
Comment by Rodney Antonio Ramos [ 2018 Dec 14 ]

I´d like just to remember that I didn´t upgrade de Mariadb.

I´ve just upgraded the Zabbix Server and Zabbix Poxy from 3.2.10 to 4.0.1.

With Zabbix Server/Proxy 3.2.10 we didn´t have this problem.

Comment by Glebs Ivanovskis [ 2018 Dec 14 ]

Can you show your sql_mode settings? I know that you haven't upgraded DB server, but since I'm not able to reproduce the behaviour you see (you have truncated data, I have no data at all and SQL errors) there must be something different in our setups.

Comment by Rodney Antonio Ramos [ 2018 Dec 14 ]

Zabbix Server DB:

MariaDB [(none)]> select @@sql_mode\G
1. row
@@sql_mode: NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Zabbix Proxy DB:

MariaDB [(none)]> select @@sql_mode\G
1. row
@@sql_mode:

Comment by Glebs Ivanovskis [ 2018 Dec 14 ]

Hm, consider adding STRICT_TRANS_TABLES? From MySQL documentation:

STRICT_TRANS_TABLES
If a value could not be inserted as given into a transactional table, abort the statement. For a nontransactional table, abort the statement if the value occurs in a single-row statement or the first row of a multiple-row statement. More details are given later in this section.

Comment by Glebs Ivanovskis [ 2018 Dec 14 ]

However, there is no denying that there is a bug.

  1. Zabbix agent should check results for being proper UTF-8 before dumping them into JSON and sending to server/proxy.
  2. Zabbix proxy/server should validate what agent has sent and reject invalid results or at least replace invalid characters with "?" before inserting into the database.
Comment by Vladislavs Sokurenko [ 2018 Dec 14 ]

Looks like caused by ZBXNEXT-1443

This should fix the issue:

Index: src/libs/zbxdbhigh/proxy.c
===================================================================
--- src/libs/zbxdbhigh/proxy.c	(revision 87848)
+++ src/libs/zbxdbhigh/proxy.c	(working copy)
@@ -2436,7 +2436,7 @@
 				SET_LOG_RESULT(&result, log);
 			}
 			else
-				SET_TEXT_RESULT(&result, zbx_strdup(NULL, value->value));
+				set_result_type(&result, ITEM_VALUE_TYPE_TEXT, value->value);
 		}
 
 		if (0 != value->meta)
Comment by Vladislavs Sokurenko [ 2019 Jan 02 ]

Fixed in development branch:
svn://svn.zabbix.com/branches/dev/ZBX-15224

Comment by Andris Zeila [ 2019 Jan 03 ]

Successfully tested.

 

Had some problems reproducing the issue. It turns out ny MariDB server version 10.1.37 (default setup) silently replaced the bad symbols with '?' and was working fine - with or without fix. So tested with postgresql which gave the expected results.

 

Comment by Vladislavs Sokurenko [ 2019 Jan 03 ]

Fixed in:

  • pre-4.0.4rc1 r88232
  • pre-4.2.0alpha3 (trunk) r88237
Generated at Thu Apr 18 07:38:29 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.