Daily Email w/ WiFi Connection Count

Post new topic   Reply to topic    DD-WRT Forum Index -> Contributions Upload
Author Message
Jmeier
DD-WRT User


Joined: 27 Oct 2010
Posts: 219

PostPosted: Thu Jun 23, 2011 2:17    Post subject: Daily Email w/ WiFi Connection Count Reply with quote
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.
Sponsor
Jmeier
DD-WRT User


Joined: 27 Oct 2010
Posts: 219

PostPosted: Mon Jun 27, 2011 4:33    Post subject: Reply with quote
Sorry, didn't realize I cut off a part of the script. It's good now.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Contributions Upload All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum