"name": "ARP Scan (sudo)",
"x": 290,
"y": 1305,
"wires": [
[
"d66c29e1.3f3718"
],
[
"3c6a062f.6b7bfa"
],
[
"3c6a062f.6b7bfa"
]
]
},
{
"id": "dde7941.059d168",
"type": "comment",
"z": "c919054f.36e6f8",
"name": "Use arp-scan to track active IP devices",
"info": "",
"x": 216,
"y": 1238,
"wires": []
},
{
"id": "d66c29e1.3f3718",
"type": "function",
"z": "c919054f.36e6f8",
"name": "",
"func": "\n// Record the date/time of the response\nvar timestamp = new Date();\n\n// Split the response into lines\nvar lines = msg.payload.split(\"\\n\");\n\n// Trim unwanted lines (pop takes off the end, shift off the start)\nlines.pop(); // Last line is empty\nvar info = lines.pop(); // Tells us what happened and how long it took \nlines.pop();lines.pop(); // 1 empty and 1 unneeded line\nlines.shift();lines.shift(); // 2 unneeded lines at start\n\n// For each of the returned responses\nfor (var line of lines) {\n // line is tab separated\n // IP Address, MAC Address, Device/Manufacturer Name\n var data = line.split(\"\\t\");\n \n //devicescan,mac=e4:98:d1:47:1d:70,device=Microsoft\\ Mobile\\ Oy value=1,ip=\"192.168.1.106\"\n data[2] = data[2].replace(' ', '\\ ').replace(',', '\\,').replace(\"'\", '');\n node.send([{'payload': \n 'devicescan,MAC=' + data[1] + ' value=1,IP=\"' + data[0] + '\",' + 'Name=' + data[2]\n }, {\n 'payload': {\n 'timestamp': timestamp,\n 'IP': data[0],\n 'MAC': data[1],\n 'Name': data[2]\n },\n 'topic': 'DEVICES/ARP/' + data[1]\n }]);\n}\n\n// \"Ending arp-scan 1.8.1: 256 hosts scanned in 2.904 seconds (88.15 hosts/sec). 14 responded\"\ninfo = info.replace(\n /Ending arp-scan .*\\: 256 hosts scanned in (.*) seconds \\(.* hosts\\/sec\\)\\. (.*) responded/, \n replacer);\n \nnode.status({'text': info });\n\n//return msg;\n\nfunction replacer(match, p1, p2, offset, string) {\n return p2 + ' responses in ' + p1 + ' seconds';\n}",
"outputs": "2",
"noerr": 0,
"x": 470,
"y": 1285,
"wires": [
[],
[
"df18df28.d8765",
"7f19a739.f455f8"
]
]
},
{
"id": "3c6a062f.6b7bfa",
"type": "debug",
"z": "c919054f.36e6f8",
"name": "",
"active": false,
"console": "false",
"complete": "true",
"x": 470,
"y": 1365,
"wires": []
},
{
"id": "7f19a739.f455f8",
"type": "mqtt out",
"z": "c919054f.36e6f8",
"name": "DEVICES/ARP/<mac>",
"topic": "",
"qos": "1",
"retain": "false",
"broker": "3b2726f7.c4d8da",
"x": 660,
"y": 1343,
"wires": []
},
{
"id": "3b2726f7.c4d8da",
"type": "mqtt-broker",
"z": "",
"broker": "localhost",
"port": "1883",
"clientid": "Pi2_NR-Live",
"usetls": false,
"verifyservercert": true,
"compatmode": false,
"keepalive": "15",
"cleansession": true,
"willTopic": "DEVICES/PI2NR-LIVE",
"willQos": "1",
"willRetain": "false",
"willPayload": "Offline",
"birthTopic": "DEVICES/PI2NR-LIVE",
"birthQos": "1",
"birthRetain": "false",
"birthPayload": "Online"
}
]