On Mon, 25 Apr 2005 12:30:42 +0100, "John" <(E-Mail Removed)>
wrote:
>I've been testing WiFi Defense to log visitor activity on my network, ie
>time online on the network, start and end time of the visit etc, but
>although this program does the required tasks, I have been having lots of
>problems with it locking up part way through its network scan. Does anyone
>know of a similar program that will log:
>
>Wireless visitors to the network
>Log-on time/date
>Log-off time/date
In Linux you can just go through /var/lib/dhcp/dhcpd.leases to get the
number of visitors and entry time/date. I use this to generate:
http://www.nam-vets.org/frampton/status.php
....however that doesn't log exit times. Also, I'm running a community
hotspot so I'm not trying to deny anyone access, merely get a vague
log of usage. Below is the source code I wrote to generate the stats.
--
Andrew Oakley andrew/atsymbol/aoakley/stop/com
#!/usr/bin/perl
# hotspot-stats.pl
# PUBLIC DOMAIN by Andrew Oakley
# This program works out how many DHCP allocations have been
# handed out in the last 48 hours. This gives a rough count
# of how many people have visited the network.
use Date::Manip;
$inputfile='/var/lib/dhcp/dhcpd.leases';
$outputfile='/var/www/html/hotspot-stats.html';
$recenthours=48; # Period considered "recent", eg. last 2 days
$recentseconds=$recenthours*60*60;
$totalleases=0;
$recentleases=0;
$timenow=time;
$earliestlease=$timenow;
if ( open (INFILE,"$inputfile") )
{
while ( $line=<INFILE> )
{
if (
$line=~/^\s*starts\s+[0-9]+\s+([0-9][0-9][0-9][0-9])\/([0-9][0-9]?)\/([0-9][0-9]?)\s+([0-9][0-9]?)\

[0-9][0-9]?)[^0-9]/i
)
{
$yyyy=$1;
$mm=$2;
$dd=$3;
$hh=$3;
$nn=$3;
$leasetime=Date_SecsSince1970($mm,$dd,$yyyy,$hh,$n n);
$totalleases++;
if ( $leasetime>$timenow-$recentseconds )
{
$recentleases++;
}
if ( $leasetime<$earliestlease )
{
$earliestlease=$leasetime;
}
}
}
$earliestlease=UnixDate(ParseDate("epoch $earliestlease"),"%e %b
%Y");
$lastupdated=UnixDate(ParseDate("epoch $timenow"),"%H:%M on %e %b
%Y");
close(INFILE);
if ( open (OUTFILE,">$outputfile") )
{
print OUTFILE "<P>Users in the last $recenthours hours:
$recentleases\n";
print OUTFILE "<BR>Total users since $earliestlease:
$totalleases\n";
print OUTFILE "<BR>Statistics last updated at $lastupdated.\n";
close (OUTFILE);
}
else
{
die ("Could not open output file '$outputfile'\n");
}
}
else
{
die ("Could not open input file '$outputfile'\n");
}