#!/usr/bin/perl -W
$ploticus_chron = 'ploticus png -prefab chron data=- x=1 y=2 xgrid=color=0.8 ygrid=color=0.8 datefmt=yyyymmdd mode=line gapmissing=yes yrange=0 -font Arial -diagfile /dev/null';
$bar_width = 600;
################################################################################
use Time::Local;
%capacity_day = ();
%players_day = ();
%capacity_hour = ();
%players_hour = ();
%capacity_10m = ();
%players_10m = ();
%map = ();
%game = ();
%map7 = ();
%game7 = ();
$grand_total = 0;
$grand_total7 = 0;
$now = time;
while ($line = <>) {
chomp $line;
($datetime, $game, $mission, $map, $maxplayers, $players) = split /\t/, $line;
next if $map eq '';
$datetime =~ m|(....)(..)(..)/(..)(..)| or die 'match failed';
$year = $1;
$month = $2;
$day = $3;
$date = "$year$month$day";
$hour = $4;
$min = $5;
$time = timegm(0, $min, $hour, $day, $month - 1, $year);
# $gmm = "$game: $mission: $map";
$gmm = $map;
$gm = "$game: $mission";
$players = 0 if ($players < 0);
$maxplayers = 0 if ($maxplayers < 0);
$grand_total += $players;
# all time stats
if (exists $players_day{$date}) {
$players_day{$date} += $players;
$capacity_day{$date} += $maxplayers;
} else {
$players_day{$date} = $players;
$capacity_day{$date} = $maxplayers;
}
if ($players != 0) {
if (exists $map{$gmm}) {
$map{$gmm} += $players;
} else {
$map{$gmm} = $players;
}
if (exists $game{$gm}) {
$game{$gm} += $players;
} else {
$game{$gm} = $players;
}
}
# last 7 days
next unless ($now - 7 * 24 * 60 * 60 < $time);
$grand_total7 += $players;
if (exists $players_hour{"$date.$hour"}) {
$players_hour{"$date.$hour"} += $players;
$capacity_hour{"$date.$hour"} += $maxplayers;
} else {
$players_hour{"$date.$hour"} = $players;
$capacity_hour{"$date.$hour"} = $maxplayers;
}
if ($players != 0) {
if (exists $map7{$gmm}) {
$map7{$gmm} += $players;
} else {
$map7{$gmm} = $players;
}
if (exists $game7{$gm}) {
$game7{$gm} += $players;
} else {
$game7{$gm} = $players;
}
}
# last 24 hours
next unless ($now - 24 * 60 * 60 < $time);
if (exists $players_10m{"$date.$hour:$min"}) {
$players_10m{"$date.$hour:$min"} += $players;
$capacity_10m{"$date.$hour:$min"} += $maxplayers;
} else {
$players_10m{"$date.$hour:$min"} = $players;
$capacity_10m{"$date.$hour:$min"} = $maxplayers;
}
}
################################################################################
$now = gmtime;
open INDEX, '>', '../index.html';
print INDEX < This page updated every hour, last update $now UTC. All times in UTC.
Data collected every 10 minutes by QStat,
processed by a script, and graphs plotted
with ploticus. All available data, averaged over each day: Last 7 days, averaged over each hour: Last 24 hours, sampled every 10 minutes: all available data,
last 7 days.
$game_types game types.Tribes 2 Europe Statistics
Average server places available
Percentage server places used
END
################################################################################
$game_types = keys %game;
print INDEX <
$pct%
$pct7%
all available data, last 7 days. $maps maps. Follow the link to search for a map on Tribes2Maps.
END $i = 0; foreach $gmm (sort { $map{$b} <=> $map{$a} } keys %map) { $players = $map{$gmm}; $players7 = exists $map7{$gmm} ? $map7{$gmm} : 0; $propn = $players / $grand_total; $propn7 = $players7 / $grand_total7; $max = $propn if $i == 0; $width = int($propn / $max * $bar_width); $width7 = int($propn7 / $max * $bar_width); $pct = sprintf "%.3g", $propn * 100; $pct7 = sprintf "%.3g", $propn7 * 100; $class = $i % 2; $search = $gmm; $search =~ s/([^\w()'*~!.-])/sprintf '%%%02x', ord $1/eg; $search =~ s/^Euro2_//; print INDEX <