Log harvesting scripts for the Manifold
authorVictor Grishchenko (mughal) <victor.grishchenko@gmail.com>
Wed, 10 Feb 2010 19:06:05 +0000 (20:06 +0100)
committerVictor Grishchenko (mughal) <victor.grishchenko@gmail.com>
Wed, 10 Feb 2010 19:06:05 +0000 (20:06 +0100)
mfold/dohrv [new file with mode: 0755]
mfold/swlognm [new file with mode: 0755]

diff --git a/mfold/dohrv b/mfold/dohrv
new file mode 100755 (executable)
index 0000000..a61c878
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+if [ ! $SERVERS ]; then
+    SERVERS="servers.txt"
+fi
+
+rm -rf harvest
+mkdir harvest
+
+for s in `cat $SERVERS`; do
+    (if ssh $s "cat ./swift/lout.gz" | gunzip | \
+        perl -ne 's/(#\d+)/'$s' $1/ && print' \
+        > harvest/$s.log ; then
+        echo $s harvest OK
+    else
+        echo $s harvest FAIL
+    fi) &
+done  
+
+wait
+echo 'harvested all; sorting'
+sort -m harvest/*.log | ./swlognm | gzip > harvest/swarm.log.gz
+
+echo DONE
diff --git a/mfold/swlognm b/mfold/swlognm
new file mode 100755 (executable)
index 0000000..da42a29
--- /dev/null
@@ -0,0 +1,29 @@
+#!/usr/bin/perl -w
+
+#
+#   This script detects handshake patterns
+#   and changes channel numbers for host names
+#
+#0_05_01_981_298 node309 #45 +hs f33dff82
+#0_05_02_039_313 lossy #16 -hs f33dff82
+my %HSSRC = ();
+my %CH = ();
+
+while (<>) {
+    / (\S+) (\#\d+)/ || next;
+    my $src = $1;
+    my $ch = $2;
+    if ( exists $CH{"$src$ch"} ){
+        s/$ch/$CH{"$src$ch"}$ch/ or die $_;
+    } elsif (/[\+\-]hs ([a-f0-9]+)$/) {
+        if ( exists $HSSRC{$1} ) {
+            $CH{"$src$ch"} = $HSSRC{$1};
+            my $srckey = $HSSRC{$1}.$HSSRCCH{$1};
+            $CH{$srckey} = $src;
+        } else {
+            $HSSRC{$1} = $src;
+            $HSSRCCH{$1} = $ch;
+        }
+    }
+    print;
+}