One unfortunate thing about ServerMatrix‘s service is their lack of publically accessible authoritative bandwidth usage. This is nothing that a little WWW::Mechanize can’t solve:
# User Agent
my $a = WWW::Mechanize->new();
$a->agent_alias('Mac Mozilla');
# TokeParser
my $stream;
# Login
$a->get('https://orbit.theplanet.com/');
$a->field('username', $login);
$a->field('password', $passwd);
$a->submit();
# Get Bandwidth
$a->get('https://orbit.theplanet.com/nav_hardware/a1_bandwidth_utilization.html'
);
$stream = HTML::TokeParser->new($a->content());
while(my $token = $stream->get_tag('td')) {
my $text = $stream->get_text();
if($text =~ /^Estimated RAW Usage: /) {
my @t = split(' ', $text);
print "muffins bw:
";
print $t[3] . 'GB, ';
printf('%3.1f%%', $t[3]/12);
}
}
This runs on cron and gives me a nice little output like so on my desktop (care of GeekTool):