I guess this might be better titled as the Quick and Dirty Perl Script… but here we go:

#!/usr/bin/perl -w
use strict;
use warnings;
my (@failhost);

open (MYINPUTFILE, "/var/log/asterisk/$ARGV[0]") or die "\n", $!, "Does log file file exist\?\n\n";

while (<MYINPUTFILE>) {
	my ($line) = $_;
	if ($line =~ m/\' failed for \'(.*?)\' - No matching peer found/) {

if (@failhost) {
} else {
	print "no failed registrations.\n";

sub count_unique {
    my @array = @_;
    my %count;
    map { $count{$_}++ } @array;
	#print them out:
    map {print "$_ = ${count{$_}}\n"} sort keys(%count);


And while we duck from @Merlyn’s criticisms (although we love his criticism), the basic usage is:

perl [Whatever you named it].pl messages
or perl [Whatever you named it].pl messages.1

Results look like: = 13586 = 9895 = 9960

Or “no failed registrations.” if you have no failed attempts.