Add a script to correlate sender and receiver logs.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 28 May 2012 12:25:51 +0000 (14:25 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 28 May 2012 12:25:51 +0000 (14:25 +0200)
correlate.pl [new file with mode: 0755]

diff --git a/correlate.pl b/correlate.pl
new file mode 100755 (executable)
index 0000000..04cc9d4
--- /dev/null
@@ -0,0 +1,36 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+
+my $fh;
+my %seen_recv = ();
+
+# Receiver
+open $fh, "<", $ARGV[1]
+       or die "$ARGV[1]: $!";
+while (<$fh>) {
+       tr/\r\n//d;
+       /^(\d+)$/ or next;
+       $seen_recv{$1} = 1;
+}
+close $fh;
+
+# Sender
+open $fh, "<", $ARGV[0]
+       or die "$ARGV[0]: $!";
+while (<$fh>) {
+       tr/\r\n//d;
+       /^\d+(?: \d+)* $/ or next;
+       for my $n (split) {
+               if (exists($seen_recv{$n})) {
+                       print "$n ";
+               } else {
+                       print "$n* ";
+               }
+       }
+       print "\n";
+}
+close $fh;
+
+