glpi-project / glpi-agent

GLPI Agent
GNU General Public License v2.0
212 stars 51 forks source link

PPC 930 Card Reader Device cannot be inventoried with Windows serial number #650

Closed erique-souza closed 4 weeks ago

erique-souza commented 2 months ago

Bug reporting acknowledgment

Yes, I read it

Professional support

Still not applicable

Describe the bug

I'm trying to inventory the USB device Card Reader model PPC 930 from Gertec, in Windows there is the full driver for the device, but the GLPI-Agent when importing only brings this data in the .json file

        {
            "caption": "PPC 920-930 Enumerator Device",
            "manufacturer": "GERTEC Telecomunicacoes Ltda.",
            "name": "PPC 920-930 Enumerator Device",
            "productid": "C902",
            "vendorid": "1753"
        },

The device's serial number is missing, but this information exists in the Windows registry in this path: Computer\HKEY_CURRENT_USER\Software\Gertec\PIN Pad as shown in the print below

image

I would really like to know how GLPI-Agent exactly collects information from device drivers to always try to check the correct path of how the reading should work

To reproduce

Expected behavior

The device inventory along with the computer inventory in the Devices tab linked to the asset

Operating system

Windows

GLPI Agent version

1.7.3

GLPI version

10.0.14

GLPIInventory plugin or other plugin version

GLPI Inventory v1.3.5

Additional context

No response

erique-souza commented 2 months ago

Below is the complete .json file for checking computer_36_36276 (7).json

Also follow my complete glpi-agent log with debug level 2 for debugging glpi-agent.log

g-bougard commented 2 months ago

Hi @erique-souza

the relevant file for USB devices inventory on windows is this one: https://github.com/glpi-project/glpi-agent/blob/develop/lib/GLPI/Agent/Task/Inventory/Win32/USB.pm

Actually, it only uses WMI to retrieve connected devices and nothing more is done to find more information like serialnumber if it is not found. You can see what's the agent analyses by running:

wmic path CIM_LogicalDevice get /format:list

From this list, only devices for which DeviceID field matches /^USB\\VID_(\w+)&PID_(\w+)\\(.*)/ regular expression will be recognized as USB devices. And we only try to extract S/N from this ProductID field.

Can you still share at least the entry related to your device ?

To support extracting S/N from registry for some case, dedicated modules will have to be created. My guess is we can use "productid": "C902" & "vendorid": "1753" to trigger the module, maybe just on vendorid like the way this is done for monitor in Screen.pm to trigger modules from lib/GLPI/Agent/Tools/Screen folder. Using this principle could permit users to develop their own module.

Can you share an export of HKEY_CURRENT_USER\Software\Gertec\PIN Pad to eventually use it in tests ?

erique-souza commented 2 months ago

Hi @erique-souza

the relevant file for USB devices inventory on windows is this one: https://github.com/glpi-project/glpi-agent/blob/develop/lib/GLPI/Agent/Task/Inventory/Win32/USB.pm

Actually, it only uses WMI to retrieve connected devices and nothing more is done to find more information like serialnumber if it is not found. You can see what's the agent analyses by running:

wmic path CIM_LogicalDevice get /format:list

From this list, only devices for which DeviceID field matches /^USB\\VID_(\w+)&PID_(\w+)\\(.*)/ regular expression will be recognized as USB devices. And we only try to extract S/N from this ProductID field.

Can you still share at least the entry related to your device ?

To support extracting S/N from registry for some case, dedicated modules will have to be created. My guess is we can use "productid": "C902" & "vendorid": "1753" to trigger the module, maybe just on vendorid like the way this is done for monitor in Screen.pm to trigger modules from lib/GLPI/Agent/Tools/Screen folder. Using this principle could permit users to develop their own module.

Can you share an export of HKEY_CURRENT_USER\Software\Gertec\PIN Pad to eventually use it in tests ?

Understood, I can no longer access the equipment to export the exact record, but I made a replica on my Windows and exported it if I was going to use the data for testing

Gertec test.reg.txt I renamed the .reg to .txt, just remove the .txt to access the file correctly

image

g-bougard commented 2 months ago

Okay, the wmic output would have been useful for automatic tests, but I still can guess it from the json output.

I think I can try to develop this support anyway as this could be an interesting update.

g-bougard commented 2 months ago

Hi @erique-souza

I see a problem in your registry export: it's under HKEY_CURRENT_USER hive... do you have the same keys under HKEY_LOCAL_MACHINE ? This is a problem as the service is running as LocalSystem user.

g-bougard commented 4 weeks ago

Hi @g-bougard

without feedback, I'm closing this issue. Feel free to reopen or comment.