Monthly Archive for October, 2006

Colubris Multiservice Controller Scrape

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 ….

Plot of Authenticated Users

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!

Lighttpd Rocks

I have come to the conclusion that Lighttpd rocks. Seriously, it does!

I have a VPS (Virtual Private Server) somewhere in the states. It’s very handy, actually, and it gives me the power of a very large bandwidth (I often get speeds of up to 20MBps, and a limit of about 100GB of transfer). However it’s got very little memory, only about 128MB. As such, serving a website from it is a bit tricky when your load goes up.

Enter Lighttpd. It’s got a really small memory footprint and is easily optimised to make it even smaller. I can support a good few thousand clients on my little VPS with Lighttpd. With Apache2 it started to wobble at about 300 or so.

As an added bonus, you can also run it on Windows without much of a problem. Lighttpd on Windows by Kevin Worthington makes it stupidly easy to set up. I got a server configured running in around the 30 second mark – that’s how easy.

It supports PHP, CGI .. all of that good stuff. I’ve not really tried that just yet – I’ve not really had the need. I might sort out a bit of PHP to display my graphs.

Speaking of which, I’ve been dabbling with a bit of network load measurement recently. The connection I’m on is a shared one, with a Colombis Multiservice Controller as the gateway. I wrote a little perl script to grab the number of authenticated users from it’s status page – currently I’m tweaking it so that it uses LWP rather than wget as it did previously. That should mean it’ll work under Windows too. As soon as it’s done I’ll post it :)

How to freak out a HP Rep

PC World customers are weird. Almost as weird as the shop itself.

Today, I was selling photo printers. I don’t actually work for PC World, rather for a company that represents HP for product demonstrations there (among other shops).

You get some odd questions. A lot of people don’t quite grasp the fact that having a HP polo shirt and card means that you represent HP. People kept asking me about Lexmark printers and cartridges. Including the PC WORLD STAFF. That’s just not right. Asking to compare features of two printers which have similar features which includes a HP one (which obviously I’m going to try and sell…) – yeah that’s fine. Comparing two printers, neither of which are HP, is silly.

One man decided to tell me that HP sauce had been banned from the Houses of Parliament. He was with his daughter, who was quite hot in a Gothic sort of way.  She told him where he could put that piece of useless information!

At one point I had to try and explain to a man who could only tentatively speak English why he couldn’t print with only the colour cartridge. No, you can’t mix all the inks to make black – it’d make brown. He made some very interesting movements with the packaging for the cartage’s to indicate installing them into the machine. It was pretty hard to keep a straight face.

But how to really freak a rep out? Here’s what you do. Get a small child. Any one will do. Have them run around wildly shouting their head off (shouldn’t be too hard, it seems to come naturally to most small children). Here’s the key. Go after them, and grab them to tell them to stop, and then – you lick your finger, put it in the air and make a hissing noise whilst looking at the rep intensely in the eye. Then scuttle away.

Guaranteed, instant, confusion.