#!/usr/bin/awk -f

/^\[/ {
       hits[" served documents total"] += 1;
       { FS="]";
         if ($2 != " ")
               { hits[$2]+=1; }
               else { hits[" invalid selector"] += 1; }
       }
       split($0, addr, "|");
       if (addr[2] == "localhost") { hits[" via tor"] += 1 }
}

END {
       for (h in hits) {
               print hits[h], h
       }
}