glpi-project / glpi-inventory-plugin

GLPI Inventory plugin
GNU Affero General Public License v3.0
43 stars 24 forks source link

SNMP inventory problem with disconnecting devices from the switch #482

Open r0bertk opened 4 months ago

r0bertk commented 4 months ago

Describe the bug

Good morning, I use glpi inventory version 1.3.5 and the latest Glpi Agent 1.7.1 I would like to present a problem in connecting network ports between switches and devices

To reproduce

I have several Huawei switches. I would like to describe my example based on the following scenario.

A computer named a17129 and Mac address xx:xx:xx:d4:92:90 is connected directly to the Huawei switch named PD1-STACK on port number 0/0/16. When I execute glpi-injector switchPD1-STACK.xml, the computer will connect to the appropriate port on the Huawei screen switch: image Huawei PD1-STACK switch is connected to another Huawei CORE switch. All other switches in the company are connected to the CORE switch and if a glpi-injector of another switch is performed, e.g. Switch PD1-POE, the a17129 computer is disconnected from the correct Switch PD1-Stack port 0/0/16 and is connected to Hub > N /And below is the screenshot after executing the command glpi-injector switchPD1-POE.xml image Glpi has created an Unmanaged devices Hub that looks like this: image After analyzing the .xml files, I noticed that glpi works like this when in the section there are many connections with different MAC addresses and if there is a computer's MAC in this section, it will then create a hub. Below is a screenshot with a fragment of the xml file and the mac address of the computer marked a17129 image when I remove the Mac address of the computer a17129 from the xml file and execute glpi-injector, the computer will remain intact. In the above example, the PD1-POE switch on the XGigabitEthernet0/0/1 port is a Trunk VLAN port 1-4092, therefore it displays all MAC addresses of computers.

I tried to work around this problem via rules. I noticed that the port is removed by the Update only mac address (mac on switch port) rule, I tried to modify it by adding e.g. criteria Asset>Network port>Port number in not 55 however the rule does not seem to work. Please help me how to solve this problem. Maybe I'm doing something wrong?

Expected behavior

I would like this problem to be fixed

Operating system

Linux

GLPI Agent version

Other (See additional context below)

GLPI version

10.0.12

GLPIInventory plugin

1.3.5

Additional context

Thank you for your help

trasher commented 4 months ago

I've tried to reproduce on my side, but if I could have strange behavior; I did not see the exact one you talk about here. But I've built myself XML files, and maybe did I create use cases that does not exists.

Please provide inventory files we can use to reproduce on a fresh GLPI instance and inspect on our side. It can be very light versions, no need for 200+ ports nor all computer hardware/software list to get that specific issue reproduced.

r0bertk commented 4 months ago

Hello, thank you for the answer. please let me know what address I should send the inventory files to

trasher commented 4 months ago

There is no private way to send data for community support. You can post them here, just ensure to remove sensitive data before (as said, most of the file content won't be required to reproduce the issue you describe).

stonebuzz commented 4 months ago

The agent name is created the first time it is run

a GLPI-Agent.dump file is created and reused each time it is run

The only way to update the agent name is to reinstall it or delete this file

trasher commented 4 months ago

The agent name is created the first time it is run

a GLPI-Agent.dump file is created and reused each time it is run

The only way to update the agent name is to reinstall it or delete this file

Wrong issue ;)

r0bertk commented 4 months ago

Hello, I prepared files that I uploaded to the new version of glpi 11 nightly build main-23caf39.tar.gz. The effect is the same as on my production version. Below I am sending you a detailed step-by-step scenario Step 1 On a new glpi installation, we add the computer from the file: a17129_clear_new2.json a17129_clear_new2.json

I imported from the Administration->Inventory->Import from file->Upload tab After importing, we have added a computer named a17129 obraz Step2. Then we import switch_PD1-STACK from the file: switch_PD1-STACK.xml switch_PD1-STACK.zip

Administration->Inventory->Import from file->Upload After importing, a switch called PD1-STACK will appear, which has 102 ports. The a17129 computer will be connected to port 0/0/16 obraz When we go to the Computers->Networks ports tab, we see that the computer is Connected to PD1-STACK obraz Step 3 Then we import switch_PD1-POE from the file: switch_PD1-POE.xml switch_PD1-POE.zip

Administration->Inventory->Import from file->Upload After importing, there will be a switch called PD1-POE which has 27 ports. On port XGigabitEthernet2/0/1 obraz When we go to the Computers->Network ports tab, we see that the computer has been connected to the new Hub obraz

trasher commented 4 months ago

OK, I can reproduce with provided files; thank you. I'll take a closer look.

trasher commented 4 months ago

I've inspected provided files, and GLPI actual behaviour seems correct. Computer's MAC address is present on both switches XML. Therefore, when you import the first switch, a link is done, but it's replaced when importing the second one; and that seems logic. I have no idea how switches ports are retrieved; but provided data tend to demonstrate computer is plugged on both switches with same mac, I don't think this is possible.

r0bertk commented 4 months ago

Have I understood correctly that there is not much that can be done about it? If nothing can be done about it, I would like to use a rule that will skip the inventory of this port. However, when I tried the Update only mac address (mac on switch port) rule, I tried to modify it by adding e.g. criteria Asset>Network port>Port number in not (number port) however the rule does not seem to work.

trasher commented 4 months ago

Have I understood correctly that there is not much that can be done about it?

If XML you provide are correct (ie you did not edit mac list by hand on "PD1-STACK" and made mistakes); I do not see what we could do GLPI side. Maybe agent can do something, but there also are chances that data provided from your switches is incorrect - I can't say.

Attaching assets to a switch at inventory time is not related to rules if I remember correctly; it's just about the mac address presence. Rule works on asset level; not on what they contain; therefore you cannot choose to not inventory a port that is present - as far as I know.