As I said before, I’m behind a shared Internet connection at the moment. Out of curiosity more than anything, I tracerouted a connection out and found a Colubris Multiservice Controller (5200 Series) as the gateway. Interestingly on the page it shows to unauthenticated users, it also has the number of currently authenticated users.
This is handy as it tells me whether my connection is going to be slow or not. Also if I want to show my ISP that the hardware isn’t up to the job, I can do that too.
So, I decided to make a quick perl script to grab the number for me so I could log it. I thought it might be interesting to know when the least people are online so I can schedule downloads for that time.
#!/usr/bin/perl -w
# -----------------
# GetAuthedUsers.pl
# -----------------
# Retrieves number of Authenticated Users.
# == TESTED ON ==
# Colubris Multiservice Controller (5200 series)
my $host = "172.16.30.1"; # The IP or hostname of the Controller
use LWP 5.64;
my $url = 'https://'.$host.'/home.asp';
my $browser = LWP::UserAgent->new;
my $response = $browser->get($url);
# It just so happens that the first match of this regexp
# is the number we're looking for. Handy!
# The other match is Authenticated MAPs.
if ($response->content =~ /span class=\"label\"><b>([0-9]*)< /b>/s)
{
print $1;
print "n";
}
To be honest, this was the second permutation. For some reason I got it into my head that you couldn’t get documents over a SSL connection with perl – SILLY ME! I was grabbing the file with wget first, then processing it. That was pretty nasty – this is WAY neater.
Now time for the fun! We make a little data logger with it.
#!/usr/bin/perl -w
# This script will log the number of users logged on over time, in a delimited format
# timestamp users
my $LOG_PERIOD = 10;
use LWP 5.64;
open LOGFILE ,">>users_log.txt";
while (1) { # loop forever!
my $users;
my $host = "172.16.30.1"; # The IP or hostname of the Controller
my $url = 'https://'.$host.'/home.asp';
my $browser = LWP::UserAgent->new;
my $response = $browser->get($url);
$users = 0;
if ($response->content =~ /span class=\"label\"><b>([0-9]*)/s)
{
$users = $1;
}
my $myTime = time; # Get the timestamp (for processing later)
if ($users != 0) {
print LOGFILE "$myTime $usersn"; # print to logfile.
print "$myTime $usersn";
}
sleep $LOG_PERIOD; # Wait for a while.
}
That will make a file called user_log.txt, which will have the timestamp and then the number of authenticated users at that time. Load it into your favourite graph plotting program (like GNU Plot) and ….

I’m sure you could get all sorts of interesting information out of one of these things – but that’s the one that imediately sprung to mind. Have fun!
