#!/usr/local/bin/perl # take a raptor log and count bytes rcvd and bytes sent my @subnets=("172.16.", "172.17.", "172.18.", "172.19.", "172.20.", "172.21.", "172.22.", "172.23.", "172.24.", "172.25.", "172.26.", "172.27.", "172.28.", "172.29.", "172.30.", "172.31.", "172.32.") ; while (<>) { if(/sent=([\d]+).*rcvd=([\d]+).*src=([\d]+\.[\d]+\.[\d]+)/) { $totalrcvd{"$3"}+=$2; $totalsent{"$3"}+=$1; } } foreach $subnet (@subnets) { for ( $i = 0 ; $i <255 ; $i++) { $j = "$subnet$i" ; printf ("%12u bytes recieved and %12u bytes sent by %s\r\n",$totalrcvd{$j}, $totalsent{$j}, $j) if ($totalrcvd{$j}); } } exit 0;