Jmeier DD-WRT User
Joined: 27 Oct 2010 Posts: 219
|
Posted: Thu Jun 23, 2011 2:17 Post subject: Daily Email w/ WiFi Connection Count |
|
Simple script that runs every 30 seconds and counts the number of clients connected. It stores that info and sends an email at midnight with the MACs and total number of clients that connected.
Uncomment the interfaces you want to see info for
Save this script as /jffs/etc/config/wificount.startup and chmod +x the file.
Note that I have not placed it in /jffs/etc/config but rather, I use firmware mod kit to put it in /etc/config YMMV.
Code: | while sleep 30
do
# Dump the current list of wireless clients
# Don't need private interface so comment it out unless desired
# wl -i eth1 assoclist >> /jffs/wllist
wl -i wl0.1 assoclist >> /jffs/wllist
# Sort and remove dupes, keep same file
sort /jffs/wllist | uniq > /jffs/wllist.sorted
rm -rf /jffs/wllist
mv /jffs/wllist.sorted /jffs/wllist
# Check to see if it's 11:59pm, copy the day's list to a csv, count the # of MACs, declare variable with the output, email results, delete temp file
if date | grep 23:59:*; then
DAILYCONNECT=`wc -l /jffs/wllist | awk -F " " '{print $1}'`
DETAIL=`cat /jffs/wllist`
sendmail -S"mail.server.com" -u"username" -p"password" -F"Full Name" -f"email@domain.com" -s"WiFi Details" -m"Total clients seen today: $DAILYCONNECT From the following MAC addresses $DETAIL" youremail@server.com
rm /jffs/wifi/wllist
# If it's not, don't do anything
else echo "Nothing to do"
fi
done
|
I'm working on extending this to include bandwidth used but I wouldn't expect it soon. |
|