Network scanner with DNS, UniFi query and switch port/PoE infoDecember 2017
At home I currently run a Nortel 48 port switch with PoE, as well as a UniFi controller controlling two UniFi AP-AC-LITE access points. For monitoring, I wanted to be able to track which devices are connected to the network, how they are connected, and (if applicable) how much power they are using, and then have HTML output that I can embed in another page.
Originally this code had been developed as a basic network scanner with HTML output, but has grown from there.
This script uses arping to check all hosts on a network, which is by no means 'foolproof', but is good enough for this purpose. Switch port and PoE information is requested via SNMP from the switch. This was tested on a Nortel BayStack 5520 48T-PWR switch - your switch may or may not support the OIDs used. A UniFi controller is needed to provide an API for getting wireless information, and also requires an account on the UniFi controller.
Very little error checking is included in this code, however it has proven to be reasonably reliable for home use.