
My next step is to write a python script to run on the raspberry pi which ssh into the router and monitors (via python package watchdog) /proc/net/arp for immediate notifications on association and dissociation. You could compare this again the dnsmasq.leases to get machine name (matching on MAC), but as MAC is all I need I wont be doing that. I have already achieved this objective with Selenium-wire (MITM Proxy), but Django doesn't like to work. You get a list of clients, not all currently connected, so filter by the flag being 2 (connected) I'm starting a new Django project, I'm trying to capture the network traffic with Selenium. Leaselist = read_whole_file("/var/lib/misc/dnsmasq.leases") ĭoing some tests reveals that /proc/net/arp is exactly what I need, if you ssh into your router and run * Obtain lease list - we still need the arp list forĬases where a device uses a static IP rather than DHCP */
#Python monitor network code
here's the relevant code snippetĪrplist = read_whole_file("/proc/net/arp")

Viewing the source of the page reveals it calls a function get_wl_status()ĭigging around the c code, I found (via ej_wl_status_2g_array) that this appears to get a lot of it's data from two key files. The Python interface is a straightforward transliteration of the Unix system call and library interface for sockets to Pythons object-oriented style: the. Remote monitor instances can send their results back to a central location.


It is designed to be quick and easy to set up and lacks complex features that can make things like Nagios, OpenNMS and Zenoss overkill for a small business or home network. Verifying the Network Connection to Snowflake with SnowCD. After digging around the web pages and c files, here's what I found (note my router is at 192.168.2.1) SimpleMonitor is a Python script which monitors hosts and network connectivity. The sample code at the end of this topic combines the examples into a single, working Python program.
