Npm function @network-utils/arp-lookup weird Promise output

tried that but still giving the same error
when i bypass that code (the code which writes the second address line) and edit the xml file so the localhost has 2 address entries i am advanding a little more

however second error

"TypeError: Cannot read property 'AC:AC:0B:E9:6A:FF' of undefined"

it seems to try and read the ip address belonging to that mac address(the first one in the xml file)

i think it halts at this line

network[mac].ipaddr = host.address[0].$.addr

this is what is in the xml file (note there is no vendor info, deleting the vendor code will not help either)

<host><status state="up" reason="arp-response" reason_ttl="0"/>
<address addr="192.168.1.1" addrtype="ipv4"/>
<address addr="AC:AC:0B:E9:6A:FF" addrtype="mac"/>
<hostnames>
<hostname name="RT-AC66U-27E8" type="PTR"/>
</hostnames>
<times srtt="632" rttvar="5000" to="100000"/>
</host>

when translated to json still i see no strange things
image

If you put a debug node set to show the full msg after the XML node, you should get something like:

image

If you put one on the output of the file read node, it should look something like:

image

The lack of vendor info doesn't matter.

host.address[0].$.addr should return your router's address quite happily on the first line as you show in the debug output. You can prove that by using some node.warn() functions in the function node.

No, hang-on, just re-read that error. hasOwnProperty is only used once:

    // Create the entry if it doesn't exist
    if ( ! network.hasOwnProperty(mac) ) {
        // ID = mac for anything coming from nmap
        network[mac] = { id: mac, 'mac': mac }
        newnetwork[mac] = host
    }

That means that the variable network doesn't exist which means that it failed to read it.

To fix that, try changing the first line to:

const network = global.get('network','file') || {}

such a simple solution, i was totally looking in the wrong direction.

thanks

no i have to use that data in my flow

got it working but i have one question.

every device shows up in the global.get
however when you disable a device(let's say your iphone) and run the flow again the entry for the iphone disappears.
i thought al the entries which were scanned are supposed to stay in the global.get and only the status(ipstate) should change.

so over time the global.get has all the existing devices but the status depends on whether they are switched on or off.

i currently us an exec node which i feed with an ip address and executes arp -a
this looks in the arp cache table and also displays the status
if i get an incomplete message it means the unit is not connected, when it responds with the mac address it means it is on.
when it can not find the entry it means the device is off and has never been seen before

my synology does not repond with anything (but it is on and available)
somehow it does not show up in the arp cache that is why i wanted to use nmap as a backup

problem with nmap seems to be(with option sn) that it shows up when on but does not show up when off.

That should be what is happening and I think it is happening on mine ... yes, just checked. I started off with about 61 devices discovered and I now have 70.

My Synology NAS shows up fine using nmap:

image

I only have 1 LAN port connected at the moment as I'm short of switch sockets but it is certainly responding as expected.

That is expected. That's why the flow should be accumulating data and records the last update timestamp. This is certainly working for me. So you may want to go back to my original flow and check what is different in yours.

did the whole thing again.

now it seems to stick (getting square eyes from all that code)

my network flows are based on ip address and not mac so i changed the code a bit so instead of having mac entries i now have ip entries

regarding my flow.
i will go back to my old flow
ip node, arp node and function node
combined which the global info from your flow it will give me all the data from my net work as well as a really quick response to see if a device is up and down.

thanks for your help. really nice work

image

Great stuff, glad things are working.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.