#!/usr/athena/bin/perl
open(TXNS, "txns");
while(<TXNS>) {
  chop;
  open(OUT, "dsgrep -t $_ -p usenet-stats |");
  $read = $post = $bytes = $hosts = $cxns = 0;
  while(<OUT>) {
    if(/^Article readings:\s+(\d+)$/) {
      $read=$1;
    } elsif(/^Articles read:\s+(\d+)$/) {
      $read=$1;
    } elsif(/^Article postings:\s+(\d+)$/) {
      $post=$1;
    } elsif(/^Articles posted:\s+(\d+)$/) {
      $post=$1;
    } elsif(/^Connections:\s+(\d+)$/) {
      $cxns=$1;
    } elsif(/^Bytes transferred:\s+([\d\.]+)G$/) {
      $bytes=$1;
    } elsif(/^Distinct hosts:\s+(\d+)$/) {
      $hosts=$1;
    }
  }
  close(OUT);
  printf "%d %d %d %d %.2f %d\n", $idx++, $read, $post, $cxns, $bytes, $hosts;
}
close(TXNS);
