#!/usr/local/bin/perl # interesting vars @match = ("Unknown", "A", "NS", "CNAME", "SOA", "WKS", "PTR", "HINFO", "MX", "TXT", "AAAA", "AXFR", "ANY"); $total = $diff = 0; $restart = ''; while (<>) { chomp; @arr = split; next if (@arr[5] ne 'NSTATS'); # catch nameserver restarts if (@arr[7] ne $restart) { $prime = 1; $restart = @arr[7]; } # prime ototal if ($prime) { $ototal = 0; for ($x = 8; $x < @arr; ++$x) { $num = @arr[$x]; $num =~ s/^.*=//; $ototal += $num; } $prime = 0; } for ($x = 8; $x < @arr; ++$x) { $num = @arr[$x]; $num =~ s/^.*=//; $total += $num; for ($y = 0; $y < @match; ++$y) { if ( @arr[$x] =~ /^@match[$y]=(\d+)/ ) { # print "@arr[$x] @match[$y] $x $y \n"; last; } else { # print "NOT @arr[$x] @match[$y] $x $y\n"; } } } $diff = $total - $ototal; # print "@arr[6] $diff $total $ototal\n"; print "@arr[6] $diff\n"; $ototal = $total; $total = 0; }