glpi-project / glpi

GLPI is a Free Asset and IT Management Software package, Data center management, ITIL Service Desk, licenses tracking and software auditing.
https://glpi-project.org
GNU General Public License v3.0
4.34k stars 1.3k forks source link

GLPI 10.0.1 - Glpi inventory spam logs, creating thousands of entries, same device move all the time between computers and changes manufacturer #11805

Closed SteadEXE closed 2 years ago

SteadEXE commented 2 years ago

Code of Conduct

Is there an existing issue for this?

Version

10.0.1

Bug description

I discovered that everytime an agent inventories a computer a lot of USB/Network Interface devices get added and immediately deleted. It creates thousands lines of logs everyday. At the moment I added a purge task to prevent database from growing.

image

It appears to occurs for docks/usb devices. Maybe there is a way to identify them in a more reliable way.

My computer (another example): image

Relevant log output

No response

Page URL

No response

Steps To reproduce

No response

Your GLPI setup information

Anything else?

After some investigation it looks like, the same device is detected on multiple computer. Probably because the device has a generic serial number. This issue seems to be related from using docks/hub or even switches. Everytime a computer perform an inventory with the bugged/dupplicated device, the device move from one computer to another, creating logs entries. For example my network card adapter is a Realtek on a HP dock, but it has the same serial number on all computers.

steph461 commented 2 years ago

To avoid a lot of logs, I purged the logs, I had to keep it for 1 year but I set it to 6 months

Log before changement over 6 month image

after : image

steph461 commented 2 years ago

I have same issue, this generates too many logs over a long period of time image

SteadEXE commented 2 years ago

To avoid a lot of logs, I purged the logs, I had to keep it for 1 year but I set it to 6 months

Log before changement over 6 month image

after : image

I did the same to prevent bloating the database.

SteadEXE commented 2 years ago

I have a device USB Device #573 that get removed all the time, I went on the device itself, it has 65000 lines of history, everytime it moves from one computer to another. It changes manufacturer all the time too.

SteadEXE commented 2 years ago

I have same issue, this generates too many logs over a long period of time image

I am pretty sure if you go on this device 1270 you will get a lot of history for it and I am sure this device is used by a lot of computers.

SteadEXE commented 2 years ago

Here is an example of a device moving all the day:

image

image

steph461 commented 2 years ago

@SteadEXE

device 1270, same issue ping pong on two computer

image

image

steph461 commented 2 years ago

But I don't have this problem on all computers. For the moment , I found two computer that have this bug

steph461 commented 2 years ago

I try delete USB Composite Device (1270)

Scan agent glpi my computer , create USB Composite Device (1846) Scan the second computer , USB Composite Device (1846).

maybe delete the two computer and then new create with agent GLPI, i wil try. My data is a migration 9.5.7 ==> 10.0.0 ( april 2022)

SteadEXE commented 2 years ago

On my side, I guess this is because we use dock/usb hub so a lot of computers detect devices with same serial number. I don't know if somebody from GLPI team has an idea of how can we mitigate the issue in this case

trasher commented 2 years ago

Could you please provide anonymized inventory files that permit to reproduce this issue?

SteadEXE commented 2 years ago

inventory files.zip

Those are two computers (my collegue's one and mine).

We apparently share RTL8153 Gigabit Ethernet Adapter and USB Composite Devices.

SteadEXE commented 2 years ago

I guess a fix would be to allow a device to be used by more than one computer. For real devices it will not change anything. And for dupplicated serial number it will stop the ping pong. Another fix would be to use a combo agent+serial number, but it prevents moving a device from one computer to another which is not ideal for stock management.

trasher commented 2 years ago

Thanks for inventory files, I'll take a look next week

trasher commented 2 years ago

I've inspected and tested provided inventory files; and it seems there is nothing we can really do; those peripherals are strictly the same on both computers.

There is an option in the peripheral form called "Management type" you can set to "Global management" to prevent that kind of case. You have to inventory the first computer, set "dumb" peripherals to global management and then import all other computers. Doing that, all linked peripherals stay on first computer, no entries in log (all is OK on that side), but as far as I've seen, those ones are never linked at all on second computer (which is maybe a bug).

Could you please test?

SteadEXE commented 2 years ago

I did it on "dump" devices. Do you think it is possible to add a crontask to automatically detect those devices and change their management mode to global management if it moves more than x times over y days ? So people who want to keep their database clean can enable the crontask. Maybe it could be a fix.

I guess without changing anything it can uses "link created" entries of history.

I am still new with GLPI source code.

SteadEXE commented 2 years ago

Update: With global management it keeps changing the manufacturer of these devices and some infos. It's a really hard task to fix everything by hand on a huge park of computers

trasher commented 2 years ago

could you please provide same inventories in xml format?

trasher commented 2 years ago

I just made a test on glpi9.5 with the fusioninventory plugin; and the behavior is exactly the same.

trasher commented 2 years ago

pull request #11915 improves default blacklist on serials; this exclude several entries

steph461 commented 2 years ago

Hello

I try, Its ok with this fix. Thanks @trasher

SteadEXE commented 2 years ago

By the way there is something weird happening, I set global management, I locked the manufacturer field but it keeps trying to update it:

image

image

steph461 commented 2 years ago

Ah yes in the log USB composite DEVICE

image

trasher commented 2 years ago

We made several changes you can test with latest nightly:

SteadEXE commented 2 years ago

It may be related but when I global management I got my php-errors spammed by:

[2022-07-01 01:57:42] glpiphplog.WARNING: *** PHP User Warning (512): getFromDBByCrit expects to get one result, 11 found in query "SELECT id FROM glpi_computers_items WHERE itemtype = 'Peripheral' AND items_id = '3'". in E:\GLPI\src\CommonDBTM.php at line 396 Backtrace : src\CommonDBTM.php:396 trigger_error() src\Inventory\Asset\InventoryAsset.php:361 CommonDBTM->getFromDBByCrit() src\Inventory\Asset\Peripheral.php:250 Glpi\Inventory\Asset\InventoryAsset->addOrMoveItem() src\Inventory\Asset\MainAsset.php:811 Glpi\Inventory\Asset\Peripheral->handle() src\Inventory\Asset\MainAsset.php:731 Glpi\Inventory\Asset\MainAsset->handleAssets() src\RuleImportAsset.php:945 Glpi\Inventory\Asset\MainAsset->rulepassed() src\Rule.php:1510 RuleImportAsset->executeActions() src\RuleCollection.php:1591 Rule->process() src\Inventory\Asset\MainAsset.php:550 RuleCollection->processAllRules() src\Inventory\Inventory.php:697 Glpi\Inventory\Asset\MainAsset->handle() src\Inventory\Inventory.php:331 Glpi\Inventory\Inventory->handleItem() src\Inventory\Request.php:360 Glpi\Inventory\Inventory->doInventory() src\Inventory\Request.php:90 Glpi\Inventory\Request->inventory() src\Agent\Communication\AbstractRequest.php:325 Glpi\Inventory\Request->handleAction() src\Agent\Communication\AbstractRequest.php:237 Glpi\Agent\Communication\AbstractRequest->handleJSONRequest() front\inventory.php:86 Glpi\Agent\Communication\AbstractRequest->handleRequest() plugins\glpiinventory\front\communication.php:72 include_once() plugins\glpiinventory\index.php:45 include_once()

The 11 results are the 11 computers sharing the same global device.

cedric-anne commented 2 years ago

It may be related but when I global management I got my php-errors spammed by:

[2022-07-01 01:57:42] glpiphplog.WARNING: *** PHP User Warning (512): getFromDBByCrit expects to get one result, 11 found in query "SELECT id FROM glpi_computers_items WHERE itemtype = 'Peripheral' AND items_id = '3'". in E:\GLPI\src\CommonDBTM.php at line 396 Backtrace : src\CommonDBTM.php:396 trigger_error() src\Inventory\Asset\InventoryAsset.php:361 CommonDBTM->getFromDBByCrit() src\Inventory\Asset\Peripheral.php:250 Glpi\Inventory\Asset\InventoryAsset->addOrMoveItem() src\Inventory\Asset\MainAsset.php:811 Glpi\Inventory\Asset\Peripheral->handle() src\Inventory\Asset\MainAsset.php:731 Glpi\Inventory\Asset\MainAsset->handleAssets() src\RuleImportAsset.php:945 Glpi\Inventory\Asset\MainAsset->rulepassed() src\Rule.php:1510 RuleImportAsset->executeActions() src\RuleCollection.php:1591 Rule->process() src\Inventory\Asset\MainAsset.php:550 RuleCollection->processAllRules() src\Inventory\Inventory.php:697 Glpi\Inventory\Asset\MainAsset->handle() src\Inventory\Inventory.php:331 Glpi\Inventory\Inventory->handleItem() src\Inventory\Request.php:360 Glpi\Inventory\Inventory->doInventory() src\Inventory\Request.php:90 Glpi\Inventory\Request->inventory() src\Agent\Communication\AbstractRequest.php:325 Glpi\Inventory\Request->handleAction() src\Agent\Communication\AbstractRequest.php:237 Glpi\Agent\Communication\AbstractRequest->handleJSONRequest() front\inventory.php:86 Glpi\Agent\Communication\AbstractRequest->handleRequest() plugins\glpiinventory\front\communication.php:72 include_once() plugins\glpiinventory\index.php:45 include_once()

The 11 results are the 11 computers sharing the same global device.

Please open a new issue. Multiple changes have been made on this part, and it would probably better to consider this as another bug and start its analysis from scratch.

SteadEXE commented 2 years ago

Sure I'll do it.