What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Wireless log

jpdsc

Regular Contributor
Hi all,

Is it possible to know when a wifi devices was logged on the network and logged off?
I have jffs enabled so I could use a script if anyone has one already.

Thanks in advance.

Cheers,
 
There has been a few different threads asking about this, particularly with regard to home automation systems. If you search for those threads they might have what you are looking for.
 
Thanks Colin, I checked but no real solution. Shame the syslog does not log when a wireless client connects and disconnected :-(
 
AFAIK the only way would be to periodically poll the list of associated clients. By comparing "before" and "after" lists you could determine which clients have been added or removed.

http://www.snbforums.com/threads/wl-assoclist-command-with-two-ssids.21497/

Depending on the router (you don't mention which one you have) this might be simple enough. It starts getting a bit cumbersome if you have guest networks as well as the normal 2.4 & 5 GHz bands.
 
Hi @jpdsc , I've put together a quick and dirty script which might help you. I haven't tested it very much but it seems to work.;)

It's not fool proof and doesn't distinguish between different bands, but it's something to start with.

/jffs/scripts/wireless_monitor.sh
Code:
#!/bin/sh

oldlist=/tmp/assoclist.old
newlist=/tmp/assoclist.new
touch $oldlist          # Create an empty file the first time through

while sleep 15
do
        for iface in $(nvram get wl_ifnames)
        do
                wl -i $iface assoclist | awk '{print $2}' >> $newlist
        done

        for macaddr in $(grep -vxFf $oldlist $newlist)
        do
                arpinfo="$(arp -a | grep -iF $macaddr | awk '{print $1 " " $2}')"
                logger -t wireless $macaddr $arpinfo "has connected."
        done

        for macaddr in $(grep -vxFf $newlist $oldlist)
        do
                arpinfo="$(arp -a | grep -iF $macaddr | awk '{print $1 " " $2}')"
                logger -t wireless $macaddr $arpinfo "has disconnected."
        done

        mv $newlist $oldlist
done

/jffs/scripts/services-start
Code:
#!/bin/sh
/jffs/scripts/wireless_monitor.sh &
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top