glpi-project / glpi-agent

GLPI Agent
GNU General Public License v2.0
242 stars 60 forks source link

Glpi-agent 1.10 : JSON does not validate #781

Open Alexander272 opened 5 days ago

Alexander272 commented 5 days ago

Bug reporting acknowledgment

Yes, I read it

Professional support

None

Describe the bug

In toolbox plugin, a netdiscovery/inventory in local files work perfectly When try to remote on glpi server, an error occur while import json file :

[debug] #1, full snmp scan of 192.168.70.247 with credentials 1
[debug] #1, full match for sysobjectID .1.3.6.1.4.1.11.2.3.9.1 in database
[debug] #1, sysobjectID match: hp-peripheral mib support enabled
[debug] #1, unknown consumable type 1: Waste Toner
[debug] #1, invalid consumable color ID 5 for : Imaging Unit S/N:
[debug] #1, unknown consumable type 1: Tray 1 Roller
[debug] #1, unknown consumable type 1: Tray1 Friction Pad
[error] #1, [http client] communication error: 500 Internal Server Error, Array, (,     [0] => JSON does not validate. Violations:, "2000-0-0,00:00:00" does not match to ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ at #->properties:content->properties:firmwares->items[0]:0->properties:date->$ref[#/definitions/date], )
[debug] #1, Netinventory worker terminated
[debug] #1, Remote inventory task execution disabled: no remote setup
[debug] #1, NetDiscovery task execution not requested

response from glpi-netinvenotry

[debug] using 1 netinventory worker
[debug] #1, full snmp scan of 192.168.70.247 with credentials 1
[debug] #1, full match for sysobjectID .1.3.6.1.4.1.11.2.3.9.1 in database
[debug] #1, sysobjectID match: hp-peripheral mib support enabled
[debug] #1, unknown consumable type 1: Waste Toner
[debug] #1, unknown consumable type 1: Tray 1 Roller
[debug] #1, unknown consumable type 1: Tray1 Friction Pad
<?xml version="1.0" encoding="UTF-8"?>
<REQUEST>
  <CONTENT>
    <DEVICE>
      <CARTRIDGES>
        <DRUMBLACK>42</DRUMBLACK>
        <FUSERKIT>53</FUSERKIT>
        <TONERBLACK>0</TONERBLACK>
        <TONERCYAN>47</TONERCYAN>
        <TONERMAGENTA>41</TONERMAGENTA>
        <TONERYELLOW>36</TONERYELLOW>
        <TRANSFERKIT>53</TRANSFERKIT>
      </CARTRIDGES>
      <FIRMWARES>
        <DATE>2000-0-0,00:00:00</DATE>
        <DESCRIPTION>device firmware</DESCRIPTION>
        <MANUFACTURER>Hewlett-Packard</MANUFACTURER>
        <NAME>HP Color Laser 150</NAME>
        <TYPE>device</TYPE>
        <VERSION>V3.82.01.11     DEC-20-2021</VERSION>
      </FIRMWARES>
      <INFO>
        <COMMENTS>HP Color Laser 150; V3.82.01.11     DEC-20-2021;Engine V1.00.14 2019-03-04;NIC V6.01.01;S/N CNB1R3PFKR</COMMENTS>
        <CONTACT>Administrator</CONTACT>
        <FIRMWARE>V3.82.01.11     DEC-20-2021</FIRMWARE>
        <ID>0</ID>
        <IPS>
          <IP>127.0.0.1</IP>
          <IP>192.168.70.247</IP>
        </IPS>
        <LOCATION>room-master-hp-150nw-color</LOCATION>
        <MAC>c0:18:03:b0:f4:ad</MAC>
        <MANUFACTURER>Hewlett-Packard</MANUFACTURER>
        <MEMORY>0</MEMORY>
        <MODEL>HP Color Laser 150</MODEL>
        <NAME>HPC01803B0F4AD</NAME>
        <RAM>64</RAM>
        <SERIAL>CNB1R3PFKR</SERIAL>
        <TYPE>PRINTER</TYPE>
        <UPTIME>5 days, 07:59:57.00</UPTIME>
      </INFO>
      <PAGECOUNTERS>
        <COLOR>2322</COLOR>
        <TOTAL>2405</TOTAL>
      </PAGECOUNTERS>
      <PORTS>
        <PORT>
          <IFDESCR>Embedded Ethernet Controller, 10/100 Mbps, v1.0, UTP RJ-45, connector A1, 100 full duplex</IFDESCR>
          <IFINERRORS>232631</IFINERRORS>
          <IFINOCTETS>2777448867</IFINOCTETS>
          <IFINTERNALSTATUS>1</IFINTERNALSTATUS>
          <IFLASTCHANGE>0.00 seconds</IFLASTCHANGE>
          <IFMTU>1500</IFMTU>
          <IFNAME>Embedded Ethernet Controller, 10/100 Mbps, v1.0, UTP RJ-45, connector A1, 100 full duplex</IFNAME>
          <IFNUMBER>1</IFNUMBER>
          <IFOUTERRORS>0</IFOUTERRORS>
          <IFOUTOCTETS>130691507</IFOUTOCTETS>
          <IFSPEED>100000000</IFSPEED>
          <IFSTATUS>1</IFSTATUS>
          <IFTYPE>6</IFTYPE>
          <IP>192.168.70.247</IP>
          <IPS>
            <IP>192.168.70.247</IP>
          </IPS>
          <MAC>c0:18:03:b0:f4:ad</MAC>
        </PORT>
        <PORT>
          <IFDESCR>Loopback Interface</IFDESCR>
          <IFINERRORS>0</IFINERRORS>
          <IFINOCTETS>12842</IFINOCTETS>
          <IFINTERNALSTATUS>1</IFINTERNALSTATUS>
          <IFLASTCHANGE>0.00 seconds</IFLASTCHANGE>
          <IFMTU>1500</IFMTU>
          <IFNAME>Loopback Interface</IFNAME>
          <IFNUMBER>2</IFNUMBER>
          <IFOUTERRORS>0</IFOUTERRORS>
          <IFOUTOCTETS>25852</IFOUTOCTETS>
          <IFSPEED>10000</IFSPEED>
          <IFSTATUS>1</IFSTATUS>
          <IFTYPE>24</IFTYPE>
          <IP>127.0.0.1</IP>
          <IPS>
            <IP>127.0.0.1</IP>
          </IPS>
        </PORT>
      </PORTS>
    </DEVICE>
    <MODULEVERSION>6.3</MODULEVERSION>
    <PROCESSNUMBER>1</PROCESSNUMBER>
  </CONTENT>
  <DEVICEID>foo</DEVICEID>
  <QUERY>SNMPQUERY</QUERY>
</REQUEST>

To reproduce

Running Network Inventory (SNMP) Task for HP Color Laser 150 Printer

Expected behavior

remote netinventory to GLPI server

Operating system

Linux

GLPI Agent version

v1.10

GLPI version

10.0.15

GLPIInventory plugin or other plugin version

GLPI Inventory v1.3.5

Additional context

No response

g-bougard commented 4 days ago

Hi @Alexander272

it seems <FIRMWARE/> -> <DATE/> content is wrong. Removing it from the XML makes import works.

Can you provide snmpwalk output in the expected format for this printer to find the best solution ?

Alexander272 commented 3 days ago

HI @g-bougard Yes after removing <DATE/> the import works. I have never used the snmpwalk utility. You are talking about a similar output

.1.3.6.1.2.1.4.20.1.1.127.0.0.1 = IpAddress: 127.0.0.1
.1.3.6.1.2.1.4.20.1.1.192.168.70.247 = IpAddress: 192.168.70.247
.1.3.6.1.2.1.4.20.1.2.127.0.0.1 = INTEGER: 2
.1.3.6.1.2.1.4.20.1.2.192.168.70.247 = INTEGER: 1
.1.3.6.1.2.1.4.20.1.3.127.0.0.1 = IpAddress: 255.255.255.255
.1.3.6.1.2.1.4.20.1.3.192.168.70.247 = IpAddress: 255.255.252.0
.1.3.6.1.2.1.4.20.1.4.127.0.0.1 = INTEGER: 1
.1.3.6.1.2.1.4.20.1.4.192.168.70.247 = INTEGER: 1
.1.3.6.1.2.1.4.20.1.5.127.0.0.1 = INTEGER: 10000
.1.3.6.1.2.1.4.20.1.5.192.168.70.247 = INTEGER: 10000
g-bougard commented 3 days ago

Yes I am.