OCSInventory-ocsreports icon indicating copy to clipboard operation
OCSInventory-ocsreports copied to clipboard

[BUG] "single" duplicate entries

Open jackburton79 opened this issue 2 years ago • 1 comments

OCS Inventory version Version : 2.9.2

Describe the bug Sometimes we get duplicated computers, but after merging, one entry remains. As you can see from this image, OCSInventory reports a duplicated MAC + serialnumber, but there is only one entry.

image

Thus, it's not possible to merge it with anything.

jackburton79 avatar Mar 07 '22 16:03 jackburton79

Hi, I have the same problem:

image

I figered out that in the table networks, in the column MACADDR there are duplicates values:

image

But the duplicate Hardware_ID doesn't exist in hardware table:

image

So, for some reason, in any time that I deleted a computer, or merged a duplicate computer, theses values or rows didn't delete.

After I delete manually these wrong duplicate values/entries where the HARDWARE_ID doesn't exist in hardware table (in my case the ID 10186), the single duplicate entry dissapeared.

jcervantes-sipecom avatar Jul 26 '22 14:07 jcervantes-sipecom

Hi @jackburton79,

There might be remaining entries from a deleted device in some of the tables linked to the duplicates. This query will give you the hardware_ids no longer linked to any device within the hardware table. SELECT networks.HARDWARE_ID FROM networks LEFT JOIN hardware ON networks.HARDWARE_ID = hardware.ID WHERE hardware.ID IS NULL;

And the following one will return a list of queries to clean every table from these deleted devices (replace HID with the list of IDs returned by the precedent statement and ocsweb with your database name.): SELECT CONCAT('DELETE FROM ',TABLE_NAME," WHERE hardware_id IN (HID, HID);") FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'ocsweb' AND COLUMN_NAME='hardware_id';

Could you try this and check if you still get single duplicates ?

Regards, Léa

Lea9250 avatar Sep 16 '22 14:09 Lea9250

I added a distinct because there were duplicate records in the result. Anyway:

SELECT distinct networks.HARDWARE_ID FROM networks LEFT JOIN hardware ON networks.HARDWARE_ID = hardware.ID WHERE hardware.ID IS NULL;

HARDWARE_ID 989 3511 3662 3793 3848

Executed the queries to delete records. No longer get single duplicates. Will see what happens next time I get a duplicate. Thanks for now.

jackburton79 avatar Sep 19 '22 06:09 jackburton79

Hi @jackburton79,

If you updated your OCS from an older version, these hardware IDs might date back to the previous version. Improvements have been made to the way a computer is deleted from OCS in the latest releases. Given that, I'll close this issue for now but feel free to open another one if you find out that the problem is still happening and we'll look more into it.

Regards, Léa

Lea9250 avatar Sep 19 '22 07:09 Lea9250