OCSInventory-NG / UnixAgent

This is the OCS unified agent for Unix operating systems
http://www.ocsinventory-ng.org/en/
GNU General Public License v2.0
89 stars 83 forks source link

Cannot Submit XML #401

Closed tcapacci closed 2 years ago

tcapacci commented 2 years ago

It's hard to solve a problem when important details are missing, that why we added this template, to help you and us.

General informations

Operating system : MacOSX 12.2.1 Perl version : 5.30

OCS Inventory informations

Unix agent version : 2.9.0

Problem's description

Cannot submit XML error when running the agent

Inventory log

ocsinventory-agent % tail -f /var/log/ocsng.log [Tue Mar 15 11:17:11 2022][error] Invalid XML: not well-formed (invalid token) at line 1672, column 21, byte 46713 at /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/XML/Parser.pm line 187. XML::Simple called at /Applications/OCSNG.app/Contents/Resources//lib/Ocsinventory/Agent/Network.pm line 106. [Tue Mar 15 11:17:11 2022][error] Cannot submit XML! Abort... [Tue Mar 15 11:20:34 2022][error] Cannot establish communication : 500 Can't connect to remcorpinv02:80 (nodename nor servname provided, or not known) [Tue Mar 15 11:22:18 2022][error] Invalid XML: not well-formed (invalid token) at line 1672, column 21, byte 46713 at /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/XML/Parser.pm line 187. XML::Simple called at /Applications/OCSNG.app/Contents/Resources//lib/Ocsinventory/Agent/Network.pm line 106. [Tue Mar 15 11:22:18 2022][error] Cannot submit XML! Abort... [Tue Mar 15 11:29:52 2022][error] Invalid XML: not well-formed (invalid token) at line 1672, column 21, byte 46713 at /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/XML/Parser.pm line 187. XML::Simple called at /Applications/OCSNG.app/Contents/Resources//lib/Ocsinventory/Agent/Network.pm line 106. [Tue Mar 15 11:29:52 2022][error] Cannot submit XML! Abort...

Brennwert commented 2 years ago

I encounter the same problem on MacOS 12.2.1 with UnixAgent 2.9.0:

[Thu Mar 17 17:23:23 2022][error] Invalid XML: not well-formed (invalid token) at line 1672, column 21, byte 46687 at /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/XML/Parser.pm line 187.
XML::Simple called at /Applications/OCSNG.app/Contents/Resources//lib/Ocsinventory/Agent/Network.pm line 106.
[Thu Mar 17 17:23:23 2022][error] Cannot submit XML! Abort...
[Thu Mar 17 17:32:07 2022][error] Invalid XML: not well-formed (invalid token) at line 1672, column 21, byte 46687 at /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/XML/Parser.pm line 187.
XML::Simple called at /Applications/OCSNG.app/Contents/Resources//lib/Ocsinventory/Agent/Network.pm line 106.
[Thu Mar 17 17:32:07 2022][error] Cannot submit XML! Abort...
Christian1und0 commented 2 years ago

I have an identical problem

General informations

Operating system : MacOSX 12.2.1 Perl version : 5.30.3

OCS Inventory informations

MacOS agent version : 2.9.0

Problem's description

"Cannot submit XML!" error when running the agent

Inventory log

[Wed Mar 23 14:26:07 2022][error] Invalid XML: not well-formed (invalid token) at line 1667, column 22, byte 46512 at /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/XML/Parser.pm line 187.
XML::Simple called at /Applications/OCSNG.app/Contents/Resources//lib/Ocsinventory/Agent/Network.pm line 106.
[Wed Mar 23 14:26:07 2022][error] Cannot submit XML! Abort...

The part of the XML File with invalid characters

<MEMORIES>
      <CAPACITY>4096</CAPACITY>
      <CAPTION>Status: ok</CAPTION>
      <DESCRIPTION>DæãìÞ</DESCRIPTION>
      <NUMSLOTS>BANK 0/ChannelA-DIMM0</NUMSLOTS>
      <SERIALNUMBER>55000000</SERIALNUMBER>
      <SPEED>2133 MHz</SPEED>
      <TYPE>LPDDR3</TYPE>
    </MEMORIES>
    <MEMORIES>
      <CAPACITY>4096</CAPACITY>
      <CAPTION>Status: ok</CAPTION>
      <DESCRIPTION>DæãìÞ</DESCRIPTION>
      <NUMSLOTS>BANK 2/ChannelB-DIMM0</NUMSLOTS>
      <SERIALNUMBER>55000000</SERIALNUMBER>
      <SPEED>2133 MHz</SPEED>
      <TYPE>LPDDR3</TYPE>
    </MEMORIES>

Hardware info about the RAM that produces the invalid characters

MacBook pro 13" (2019) - Modell A2159
intel Core i5 1,4GhZ
MacOS monterey 12.2.1
2x 4GB ram
Details der einzelnen:
Size: 4Gb
Type: LPDDR3
Speed: 2133 MHz
Manufacturer: Samsung
Partnumber: K4E6E304EC-EGCG
Serial number: 55000000
Slots:
BANK 0/ChannelA-DIMM0
BANK 2/ChannelB-DIMM0
Brennwert commented 2 years ago

For the record: I upgraded to MacOS 12.3 and the problem persists.

Christian1und0 commented 2 years ago

Update:

In Unix agent (Mac OS) 2.9.0 in file common.pm the line

1053 $clean_content =~ tr/\x00-\x08\x0B\x0C\x0E-\x1F//d; # remove forbidden char in XML

from commit https://github.com/OCSInventory-NG/UnixAgent/commit/23872084f81a5881b1f28872a519d98ba8e3abe2

is missing.

Manually adding the line did not help.

Christian1und0 commented 2 years ago

2.9.1 solved the problem with this fix: https://github.com/OCSInventory-NG/UnixAgent/commit/da9cce4f2c1b81ad91b3c74f94e8e732a6dff038

In lib/Ocsinventory/Agent/Backend/OS/MacOS/Mem.pm line 55 it replaced if ($desc !~ /empty/) { with if ($desc !~ /empty/ && $desc =~ s/^0x//) {

Thank you very much!!!