fusioninventory / fusioninventory-agent

FusionInventory Agent
http://fusioninventory.org/
GNU General Public License v2.0
254 stars 126 forks source link

[NetDiscovery] Network Equipment discovered instead of Computer #946

Closed mathieumd closed 3 years ago

mathieumd commented 3 years ago

When I'm running NetDiscovery (with SNMP creds) on an IP range, it discovers a Network Equipement, while it's a really a Computer. According to network discovery documentation, the OID SNMPv2-MIB::sysObjectID.0 is checked agains /usr/share/fusioninventory/sysobject.ids. If I try this myself the result correctly gives me a Computer:

snmpwalk -On 10.0.0.1 SNMPv2-MIB::sysObjectID.0
.1.3.6.1.2.1.1.2.0 = OID: .1.3.6.1.4.1.8072.3.2.10

grep 8072.3.2.10 /usr/share/fusioninventory/sysobject.ids
8072.3.2.10     Net-SNMP        COMPUTER        Linux

So why the netdisco task found a network equipment?

2021-09-24 20:36:32 En cours d'exécution    1 périphériques trouvés
2021-09-24 20:36:32 En cours d'exécution    [Détail] Ajouter un objet Matériel réseau synodisksta

Running fusioninventory-netdiscovery manualy gives this, which looks like it's correct too (except the MAC!):

sudo fusioninventory-netdiscovery --first 10.0.0.1 --last 10.0.0.1 --credentials version:1,community:xxx
<?xml version="1.0" encoding="UTF-8" ?>
<REQUEST>
  <CONTENT>
    <DEVICE>
      <AUTHSNMP>1</AUTHSNMP>
      <CONTACT>admin@diskstation</CONTACT>
      <DESCRIPTION>Linux synodisksta 3.10.105 #25556 SMP Thu Mar 18 12:51:03 CST 2021 x86_64</DESCRIPTION>
      <DNSHOSTNAME>10.0.0.1</DNSHOSTNAME>
      <IP>10.0.0.1</IP>
      <IPS>
        <IP>10.0.0.1</IP>
        <IP>10.1.1.1</IP>
        <IP>127.0.0.1</IP>
        <IP>169.254.224.240</IP>
        <IP>169.254.98.187</IP>
      </IPS>
      <LOCATION>Unknown</LOCATION>
      <MAC>00:00:00:00:00:00</MAC>
      <MANUFACTURER>Synology</MANUFACTURER>
      <MODEL>RS3614xs+</MODEL>
      <NETBIOSNAME>SYNODISKSTA</NETBIOSNAME>
      <SERIAL>xxx</SERIAL>
      <SNMPHOSTNAME>synodisksta</SNMPHOSTNAME>
      <TYPE>STORAGE</TYPE>
      <UPTIME>9 days, 18:29:29.12</UPTIME>
      <USERSESSION>SYNODISKSTA</USERSESSION>
      <WORKGROUP>WORKGROUP</WORKGROUP>
    </DEVICE>
    <MODULEVERSION>4.1</MODULEVERSION>
    <PROCESSNUMBER>1</PROCESSNUMBER>
  </CONTENT>
  <DEVICEID>foo</DEVICEID>
  <QUERY>NETDISCOVERY</QUERY>
</REQUEST>
g-bougard commented 3 years ago

Hi @mathieumd

thanks you for your complete reporting, and thank you to have read the doc so carefully ;-)

There's only one point you missed that could have make you understand why your Nas has been recognized as it wouldn't have been if it was only seen as COMPUTER. If you run the the agent or the netdiscovery script in debug level 2 (just use --debug --debug on the command line), you would have found there's another processing after the famous sysobject.ids database look up. This a feature I develop and name MibSupport which permit other advanced checkup since few versions. In your case, the following code should have been triggered: LinuxAppliance.pm.

And then, yes, the documentation is not up to date. Sorry for that but so few people read it in the way you did ;-)

Then a last point, without the MibSupport feature, your device would have been ignored during import as COMPUTER type is not supported as a valid SNMP type and STORAGE type is directly translated by FI4G as NETWORKING type. The only really supported FI4G types are: NETWORKING, STORAGE (but translated) and PRINTER. COMPUTER is there in sysobject.ids as it was a wish to support it in FI4G, but this didn't happen as anyway it is practically impossible to prepare a full COMPUTER inventory based on SNMP found values.

And yes, that last point is also not in the doc and it should have been since years ^^

mathieumd commented 3 years ago

OK, thanks @g-bougard for your quick and detailed reply!

I'm not sure I share the opinion that NAS are Network Equipments rather than Computers, but, if that's a limitation of FusInv, well, it can't be helped I guess! ;-)

The bottom line of this discussion is that FI4G lacks a lot of details in it's log: Task logs, for example, only says what it did, while it should also say why it dit it, and what rules were applied too. (Or maybe it's a setting I missed somewhere?)

So, I've now got a logical question: do you have any idea how I could merge these two items? Because the Computer version of this NAS were already existing and I was expecting FusInv to update it, instead of creating a new Network Equipment. I would hate to lose the history of the Computer, and of course I don't want to maintain both versions.

PS: I tried a PR for update to the two documentations (I know it should have been a single PR, but I failed that :/)

mathieumd commented 3 years ago

Oh, and just for the reference, the fusioninventory-netdiscovery with --debug --debug, where we can indeed see the sysobjectid: linux mib support enabled:

sudo fusioninventory-netdiscovery --first 10.0.0.1 --last 10.0.0.1 --community xxx
[debug] scanning block 10.0.0.1-10.0.0.1
[debug] creating 1 worker threads
[debug] [thread 1] creation
[debug] [thread 1] #1, scanning 10.0.0.1
[debug] [thread 1] #1, full match for sysobjectID .1.3.6.1.4.1.8072.3.2.10 in database
[debug2] [thread 1] #1, sysobjectid: linux mib support enabled
[debug] [thread 1] #1, - scanning 10.0.0.1 with SNMP, credentials 1: success
[debug] [thread 1] #1, - scanning 10.0.0.1 with netbios: success
[debug] [thread 1] #1, - scanning 10.0.0.1 with echo ping: success
[debug2] [thread 1] #1, executing ip neighbor show 10.0.0.1
[debug] [thread 1] #1, - scanning 10.0.0.1 in arp table: no result
<?xml version="1.0" encoding="UTF-8" ?>
<REQUEST>
  <CONTENT>
...
  <QUERY>NETDISCOVERY</QUERY>
</REQUEST>
[debug2] [thread 1] processed 1 scans
[debug] [thread 1] termination
[debug] All netdiscovery threads terminated
g-bougard commented 3 years ago

Hi @mathieumd

thank you for your involvement ;-)

That's okay for the 2 docs PR, this is not a big issue. I proposed you an update for one as a point is not more up-to-date for nmap support as I dropped it since few years because of a license issue. You just have to accept the update and I'll merge that last doc PR.

About your questions, the NAS not being a computer... indeed the problem is more in the way GLPI handles assets type. We have a limited number of assets type and for a NAS I would prefer to say it is a STORAGE (IMHO but yes this is really a tiny computer like a lot of networking appliances). But anyway FI4G can't handle COMPUTER type from NetDiscovery and NetInventory tasks as I explained. So having a device as COMPUTER and NETWORKING DEVICE is still possible. Can you explain how you still have that asset as COMPUTER ? I guess it was created manually, but I may be wrong... In that case, you should probably just keep the COMPUTER asset if you want to keep that history. But it depends if the NetInventory task if collecting informations you finally need too. Anyway, to only keep the Computer version, just create a rule in FI4G to ignore the device during the netdiscovery and netinventory tasks. To do so, you can at least create a rule to ignore the device based on its mac address. If only the computer asset history is interesting for you, there's maybe a way to import it with some SQL request... but I personally won't try to even investigate it :-D Good luck if you try as this could be really dangerous ! Then sorry I don't see any other solution at the moment.

mathieumd commented 3 years ago

Thanks @g-bougard!