ianperrin / mmm-networkscanner Goto Github PK
View Code? Open in Web Editor NEWA module for MagicMirror which determines the status of devices on the network based on their MAC or IP address
License: MIT License
A module for MagicMirror which determines the status of devices on the network based on their MAC or IP address
License: MIT License
I get the following error when I run MagicMirror after installing NetWorkScanner
MMM-NetworkScanner received SCAN_NETWORK
MMM-NetworkScanner is performing arp-scan
Whoops! There was an uncaught exception...
TypeError: Cannot read property 'devices' of undefined
at Class.scanNetworkIP (/home/birkelund/MagicMirror/modules/MMM-NetworkScanner/node_helper.js:91:74)
at Class.socketNotificationReceived (/home/birkelund/MagicMirror/modules/MMM-NetworkScanner/node_helper.js:30:18)
at Socket.<anonymous> (/home/birkelund/MagicMirror/modules/node_modules/node_helper/index.js:98:10)
at emitTwo (events.js:106:13)
at Socket.emit (events.js:191:7)
at /home/birkelund/MagicMirror/node_modules/socket.io/lib/socket.js:503:12
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at Immediate._tickCallback (internal/process/next_tick.js:98:9)
at runCallback (timers.js:649:20)
at tryOnImmediate (timers.js:622:5)
MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?
If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues
I think the problem is here:
nextState = this.config.devices.map(device => {
As this loops on this.config.devices, it basically excludes all those devices that are not in that array.
I did not have time to go deeper, I will check better asap and maybe propose some possible solution.
Please help me to install arp-scan on windows
The columns are misaligned depending if the module position is on left or right side (e.g. top_right
or top_left
). Ideally there should be a CSS left justification somewhere in the DOM. (And right just for 3rd and last column.)
Also need column space when last seen not enabled/available.
Related to #29
Hello,
I don't know why but I no all the icons are working.
If I take "phone", it's displayed by the module but no "mobile".
And yet, they are both "solid icons" (because at the beginning, I was thinking that only "solid icons" were working but no "regular icons", for example - but this is no the case).
How can we change that ?
Thanks !
variable network is not declared in .js default values , giving errors
@ianperrin
I would like to be able to have 2 columns to show my network connections. One just isn't enough for all the stuff on my network.
Hi, I'm currently testing this out on a normal Ubuntu Server 14.04.5 as serveronly install.
It seems that the NetworkScanner module only works if I run MM with sudo "sudo node serveronly".
If I don't do that I only get "Loading..." on the module.
Is there anything I can do to not need to run MM as root?
Best regards Erik
This is due to the keepAlive only being respected when showOffline is active.
I will leave a patch here, as this repository does not seem to be maintained. Alternatively, you may provide some instructions on what a pull request should contain.
--- MMM-NetworkScanner.js
+++ MMM-NetworkScanner.js
@@ -14,7 +14,7 @@
defaults: {
devices: [], // an array of device objects e.g. { macAddress: "aa:bb:cc:11:22:33", name: "DEVICE-NAME", icon: "FONT-AWESOME-ICON"}
network: "-l", // a Local Network IP mask to limit the mac address scan, i.e. `192.168.0.0/24`. Use `-l` for the entire localnet
- showUnknown: true, // shows devices found on the network even if not specified in the 'devices' option
+ showUnknown: true, // shows devices found on the network even if not specified in the 'devices' option
showOffline: true, // shows devices specified in the 'devices' option even when offline
showLastSeen: false, // shows when the device was last seen e.g. "Device Name - last seen 5 minutes ago"
keepAlive: 180, // how long (in seconds) a device should be considered 'alive' since it was last found on the network
@@ -87,31 +87,30 @@
})
);
- if (this.config.showOffline) {
- var networkDevicesByMac = getKeyedObject(this.networkDevices, 'macAddress');
- var payloadDevicesByMac = getKeyedObject(nextState, 'macAddress');
+ var networkDevicesByMac = getKeyedObject(this.networkDevices, 'macAddress');
+ var payloadDevicesByMac = getKeyedObject(nextState, 'macAddress');
- nextState = this.config.devices.map(device => {
- if (device.macAddress) {
- var oldDeviceState = networkDevicesByMac[device.macAddress];
- var payloadDeviceState = payloadDevicesByMac[device.macAddress];
- var newDeviceState = payloadDeviceState || oldDeviceState || device;
+ nextState = this.config.devices.map(device => {
+ if (device.macAddress) {
+ var oldDeviceState = networkDevicesByMac[device.macAddress];
+ var payloadDeviceState = payloadDevicesByMac[device.macAddress];
+ var newDeviceState = payloadDeviceState || oldDeviceState || device;
- var sinceLastSeen = newDeviceState.lastSeen ?
- moment().diff(newDeviceState.lastSeen, 'seconds') :
- null;
- var isStale = (sinceLastSeen >= this.config.keepAlive);
+ var sinceLastSeen = newDeviceState.lastSeen ?
+ moment().diff(newDeviceState.lastSeen, 'seconds') :
+ null;
+ var isStale = (sinceLastSeen >= this.config.keepAlive);
- newDeviceState.online = (sinceLastSeen != null) && (!isStale);
+ newDeviceState.online = (sinceLastSeen != null) && (!isStale);
- return newDeviceState;
- } else {
- return device;
- }
- });
- }
+ return newDeviceState;
+ } else {
+ return device;
+ }
+ });
- this.networkDevices = nextState;
+ this.networkDevices = this.config.showOffline ?
+ nextState : nextState.filter(d => { return d.online; });
// Sort list by known device names, then unknown device mac addresses
if (this.config.sort) {
@@ -213,7 +212,7 @@
deviceRow.appendChild(deviceCell);
// When last seen
- if ((self.config.showLastSeen && device.lastSeen && !self.config.showLastSeenWhenOffline) ||
+ if ((self.config.showLastSeen && device.lastSeen && !self.config.showLastSeenWhenOffline) ||
(self.config.showLastSeen && !device.lastSeen && self.config.showLastSeenWhenOffline)) {
var dateCell = document.createElement("td");
dateCell.classList.add("date", "dimmed", "light");
It will be awesome if we can see the IP of a machine in our network.
I set all my device via Mac address because their IP change frequently and i dream to be able to see their IP next to their name.
I enabled showLastSeen
option, but the last seen is not shown.
Does this depend on some other options?
It seems like it not possible to have multiply configs, when i have everything in one it seems to work fine, but when i have it separated it seems to be harder for it to work.
And that's a bit fun, as the other starts works as well when everything is in the first one, anyways i could be good whit more then only "one" headline" for the differtent things you will check...
I have try to do it like this
{
module: 'MMM-NetworkScanner',
position: 'top_left',
header: "Network",
config: {
devices: [
{
macAddress: "1a:1b:1c:1a:1b:1c",
name: "Desktop",
icon: "desktop"
},
{
macAddress: "2a:2b:2c:2a:2b:2c",
name: "Server",
icon: "server"
},
],
showUnknown: false,
showOffline: true,
showLastSeen: true,
showLastSeenWhenOffline: true,
keepAlive: 300,
updateInterval: 5
}
},
{
module: 'MMM-NetworkScanner',
position: 'top_left',
header: "Phones",
config: {
devices: [
{
macAddress: "3a:3b:3c:3a:3b:3c",
name: "Me",
icon: "mobile"
},
{
macAddress: "4a:4b:4c:4a:4b:4c",
name: "Other",
icon: "mobile"
},
],
showUnknown: false,
showOffline: true,
showLastSeen: true,
showLastSeenWhenOffline: true,
keepAlive: 300,
updateInterval: 5,
sort: false
}
},
And if i change the two mac-adresses from the "Phones" to the "Network", both starts to work just fine....
Hi,
I have the following issue with the module :
TypeError: Bad argument at TypeError (native) at ChildProcess.spawn (internal/child_process.js:289:26) at exports.spawn (child_process.js:380:9) at sudo (/root/MagicMirror/modules/mmm-networkscanner/node_modules/sudo/lib/sudo.js:30:17) at Class.scanNetwork (/root/MagicMirror/modules/mmm-networkscanner/node_helper.js:33:19) at Class.socketNotificationReceived (/root/MagicMirror/modules/mmm-networkscanner/node_helper.js:24:18) at Socket.<anonymous> (/root/MagicMirror/modules/node_modules/node_helper/index.js:98:10) at emitTwo (events.js:106:13) at Socket.emit (events.js:191:7) at /root/MagicMirror/node_modules/socket.io/lib/socket.js:503:12 at _combinedTickCallback (internal/process/next_tick.js:67:7) at process._tickCallback (internal/process/next_tick.js:98:9)
Thanks
Currently, when using the showLastSeen
option, your entire lists, shows:
a few seconds ago
, which is redundant, IMO.
Instead, it would be preferred that the last seen is:
keepAlive
interval.2 min ago
.I realize this may be dependent on showOffline
.
@ianperrin
What do you think?
Hello.
The module itself is great and works well with IPv4.
The problem is, though, that operation with IPv6 doesn't work. The module finds neither IP not MAC address in the network.
Is it possible to update the Module to IPv6?
Thanks.
not sure why but got error saying this.config is undefined in node_helper.js line 42
working with adding this.config again from the main config. Very new to MMM so no idea where the issue comes from, might be me...
start: function function_name () {
if(!this.config){
this.config = config.modules.find(m=>m.module=='MMM-NetworkScanner').config;
}
this.log("Starting module: " + this.name);
}
Hi, sorry this is not a bug.
I think it would be cool if you could specify that we only scan for occupants during a specific time range. For example I don't want or need it to scan if I am on the network while I'm sleeping.
Hello, when i follow the readme, i get this "error" with the arp-scan
`pi@Magic-Mirror:/usr/share/arp-scan $ sudo get-iab -v -u http://standards.ieee.org/develop/regauth/iab/iab.txt
Unknown option: u
Usage: get-iab [options]
Fetch the Ethernet IAB file from the IEEE website, and save it in the format
used by arp-scan.
'options' is one or more of:
-h Display this usage message.
-f FILE Specify the output IAB file. Default=ieee-iab.txt
-u URL Specify the URL to fetch the IAB data from.
Default=http://standards.ieee.org/regauth/oui/iab.txt
-v Give verbose progress messages.`
what can i do?
Hello,
Thanks for your module, i've tried your config file but i got some syntax issues.
I've change ";" by "," when necessary and it works now :
Here my config file :
{
module: 'MMM-NetworkScanner',
position: 'top_left',
config: {
devices: [
{ macAddress: "1a:1b:1c:1a:1b:1c", name: "Server", icon: "server"},
{ macAddress: "2a:2b:2c:2a:2b:2c", name: "Desktop", icon: "desktop"},
{ macAddress: "3a:3b:3c:3a:3b:3c", name: "Laptop", icon: "laptop"},
{ macAddress: "4a:4b:4c:4a:4b:4c", name: "Laptop", icon: "laptop"}
],
showUnknown: false,
showOffline: true,
keepAlive: 300,
updateInterval: 5
}
}
Mac address works fine however IP Address always shows offline no matter what. Ip address input as fqdn and as ip address.
keepAlive: how long (in seconds) a device should be considered 'alive' since it was last found on the network
It appears that after every updateInterval all devices that are not detected are set as offline (dimmed). I would expect devices that had previously been detected (within keepAlive time window) to be displayed as not-dimmed even though they were not found during the last scan.
Example:
keepAlive: 300 seconds
updateInterval: 15 seconds
My phone got detected 20 seconds ago. In the first scan it got detected and displayed as online (not-dimmed). During the second scan my phone was not online and did not get detected, even though it is within the keepAlive time period my phone will get displayed as offline (dimmed)
Am i misunderstanding how keepAlive works ?
Here is my config:
config: {
devices: [
{ macAddress: "--:--:--:--:--:--", name: "Thijs", icon: "mobile"},
{ macAddress: "--:--:--:--:--:--", name: "Name", icon: "mobile"},
{ macAddress: "--:--:--:--:--:--", name: "Name", icon: "mobile"},
{ macAddress: "--:--:--:--:--:--", name: "Name", icon: "mobile"},
],
showUnknown: false,
showOffline: true,
showLastSeen: true,
keepAlive: 300,
updateInterval: 15,
residents: ["Thijs","Name","Name","Name"],
occupiedCMD: {},
vacantCMD: {},
}
So after 6d5d1b1 keepalive works as intended, but only when I name the device without a space in it, for example Nexus6P
vs Nexus 6P
When I name the device Nexus 6P
as soon as android does its sleep wifi business where MMM-NetworkScanner no longer finds it for a bit the screen turns off.
If I name it Nexus_6P
this behavior is no longer seen. In fact, I see when android drops the wifi connection temporarily, because MMM-NetworkScanner now says NO DEVICES ONLINE
, however because of the working keepalive is long enough it stays on until android decides to refresh some feed or pull emails or what have you where it needs an active wifi connection again
Btw - I've found 5min (300s) is an adequate time for Android phones to keep MMM-NetworkScanner to keep the screen on and not have intermittent screen off time due to Androids erratic wifi behavior.
Config:
{ module: "MMM-NetworkScanner", position: "bottom_left", config: { devices: [ { macAddress: "A0:28:ED:69:8B:20", name: "Nokia_7P", icon: "mobile"}, { macAddress: "04:D6:AA:7C:B4:85", name: "Samsung_S8", icon: "mobile"} ], showUnknown: false, showOffline: false, keepAlive: 300, updateInterval: 10, residents: "Nokia_7P", occupiedCMD: {notification: "REMOTE_ACTION", payload: {action: "MONITORON"}}, vacantCMD : {notification: "REMOTE_ACTION", payload: {action: "MONITOROFF"}} } },
Now I do not have a degree in CS or anything, but my little experience with programming leads me to believe the variable for the device name just simply wasn't wrapped in quotes somewhere. Therefore the space breaks out of the variable too early and therefore breaks the keepalive functionality. Just my guess though. Thought it might at least lead someone onto the correct track..
The device list look different when using a remote MM client connection as compared to the main MM screen.
Latest version requires the ping
node module, this is not mentioned in the docs.
I installed according to instructions and am getting the below error. Any ideas? Running on Raspberry Pi 4, Debian Bullseye.
TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received null
at validateString (internal/validators.js:120:11)
at normalizeSpawnArguments (child_process.js:411:3)
at spawn (child_process.js:547:16)
at sudo (/opt/magic_mirror/modules/MMM-NetworkScanner/node_modules/sudo/lib/sudo.js:30:17)
at Class.scanNetworkMAC (/opt/magic_mirror/modules/MMM-NetworkScanner/node_helper.js:43:19)
at Class.socketNotificationReceived (/opt/magic_mirror/modules/MMM-NetworkScanner/node_helper.js:30:18)
at Socket.<anonymous> (/opt/magic_mirror/js/node_helper.js:109:11)
at Socket.emit (events.js:314:20)
at Socket.emitUntyped (/opt/magic_mirror/node_modules/socket.io/dist/typed-events.js:69:22)
at /opt/magic_mirror/node_modules/socket.io/dist/socket.js:428:39 {
code: 'ERR_INVALID_ARG_TYPE'
}
Hi Ian,
Can you please describe how to use the residents option?
Because our arp-scan require sudo, we get excessive logs, every time it is ran.
you can check this with journalctl -b
or cat /var/log/auth.log
:
May 10 11:28:03 sudo[26437]: pi : TTY=unknown ; PWD=/home/pi/MagicMirror ; USER=root ; COMMAND=/usr/bin/arp-scan -q -l
May 10 11:28:03 sudo[26437]: pam_unix(sudo:session): session opened for user root by (uid=0)
May 10 11:28:07 sudo[26437]: pam_unix(sudo:session): session closed for user root
Would be great to find a way to remove this noise, since it is also using up SD space and keeping more important messages from showing in journalctl logs.
I have this setup and working great! I mask the devices with a name and an icon, sweet! I'm attempting to change the size/color by modifying the custom.css. The size changes but the color stays the same light gray. What gives?
.MMM-NetworkScanner .small {
font-size: 35px;
font-color: #7FFF00;
line-height: 35px;
}
It would be great to get a MM notification for newly connected devices that are not in the list.
In that case, instead of the name, we can show the MAC and/or IP in the name fields, perhaps in red or orange color with an icon of exclamation-triangle or user-secret
or snapchat-ghost
?
So for me this module is only displaying "Loading ..." instead of, you know, not that. Running the latest version of MM. I ran node serveronly
on a console and it threw this error on every refresh:
at ChildProcess.<anonymous> (/home/pi/MagicMirror/modules/MMM-NetworkScanner/node_helper.js:63:22)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:920:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:230:5)
I have tried removing and reinstalling, and I've quadruple checked my config. I even tried running serveronly under sudo (not that I expected it to change anything, but ๐คทโโ๏ธ might as well) to no avail.
At some point I'll try to sort through the code myself, but to be honest my only java/nodejs experience is setting up the MM config, so there's not a whole lot I know how to do. Not sure how to reproduce the error outside of my setup but I'm happy to help however I can!
Hello,
After a few attempts, I decided to check the code so I discovered the property name is not "color" as written in the documentation but "colored"
The readme says: network "-l"
... (Is hard to tell if it is an uppercase i
or a lower case L
!)
It's a lowercase L.
But how to use that option and when?
man pages for arp-scan:
--localnet or -l
Generate addresses from network interface configuration. Use the network interface IP address and network mask to generate the list of target host addresses. The list will include the network and broadcast addresses, so an interface address of 10.0.0.1 with netmask 255.255.255.0 would generate 256 target hosts from 10.0.0.0 to 10.0.0.255 inclusive. If you use this option, you cannot specify the --file option or specify any target hosts on the command line. The interface specifications are taken from the interface that arp-scan will use, which can be changed with the --interface option.
I want to to able to display the entries in the order they are configured, it seems to reorder them to be Alphabetical which is not great (for me!). Is it possible to not Alphabetise them or be able to disable the sorting?
I have been trying to get this to monitor my mobile phone (Android v7). It finds my phone but only when the screen is on. Once the screen is off it no longer finds my phone. This is probably an issue with the way Android handles WiFi. I have set WiFi to stay on in standby with the phone though and I can ping it via the raspberry pi running my magic mirror.
I was hoping to use this so me and the other half can know if the other is home :)
Where can I find a list of available icons?
Hello.
I would like to use my presence of the Magic Mirror. So this will be always the same.
I want to make 2 channels in the MQTT server. One for me and One for My girlfriend.
And depending of the visualization on the mirror it must send : CH: Paul "at home" or "Away"
CH: Debbie "at home" or "Away"
I made Already a python script for something else with a MQTT client / server. here I use paho.mqtt.publish this is working.
So my question is: What do I need to do to send information to my MQTT client ?
From arp-scan man pages:
The vendor decoding uses the files ieee-oui.txt, ieee-iab.txt and mac-vendor.txt, which are supplied with arp-scan. The ieee-oui.txt and ieee-iab.txt files are generated from the OUI and IAB data on the IEEE website at http://standards.ieee.org/regauth/oui/ieee-oui.txt and http://standards.ieee.org/regauth/oui/iab.txt. The Perl scripts get-oui and get-iab, which are included in the arp-scan package, can be used to update these files with the latest data from the IEEE website. The mac-vendor.txt file contains other MAC to Vendor mappings that are not covered by the IEEE OUI and IAB files, and can be used to add custom mappings.
check links:
Hi,
I would like to just show what is in my network online and offline but it doesn't show any devices and I really don't understand why.
Please can someone help me.
Cheers
I'd like to use this module as part of a more general MM info page, but the current DOM does not look good when module is moved around or on the right side, for example. I would very much like to see a CSS file connected with this module so that:
LLR
Possibility to save the last seen and still have it after restart of the software..
Maybe have the last seen stuff in an sqlite database or text file or whatever that works :)
no matter which way I try I'm unable to run the script. I keep getting permission denied even as sudo. please help
$ ./arps2mm.sh
-bash: ./arps2mm.sh: Permission denied
sudo ./arps2mm.sh
sudo: ./arps2mm.sh: command not found
I use sth0 connected to 192.168.2.0 and wlan0 connected to 192.168.1.0
For both interfaces to run arp-scan in their own network i need the -I option.
I just installed this module and I can't seem to get it to scan. Am I doing something wrong? I specifically assigned IP addresses to each phone.
{
module: 'MMM-NetworkScanner',
position: 'top_left',
config: {
devices:[
{ ipAddress: "192.168.1.**", name: "Sister", icon: "fas fa-female"},
{ ipAddress: "192.168.1.**", name: "Mom", icon: "fas fa-female"},
{ ipAddress: "192.168.1.**", name: "Dad", icon: "fas fa-male"},
]
}
},
In the latest release all network items appears twice, independent of their status. Am I doing something wrong in my config, or is this a known bug?
This occurs in a particular case:
command
is nullA possible trivial fix:
if (command) this.sendNotification(command.notification, command.payload);
Is there a way to sort so one device to always appear at the top of the list?
And if all devices are connected can i get it to priorities devices over other devices?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.