[Swift-commit] r7435 - trunk/bin

davidk at ci.uchicago.edu davidk at ci.uchicago.edu
Tue Dec 17 14:00:26 CST 2013


Author: davidk
Date: 2013-12-17 14:00:26 -0600 (Tue, 17 Dec 2013)
New Revision: 7435

Modified:
   trunk/bin/swiftdebug
Log:
Task struct
Keep tasks stored in a hash by "jobid" value from log, also keep a simple incrementing task number associated with it


Modified: trunk/bin/swiftdebug
===================================================================
--- trunk/bin/swiftdebug	2013-12-17 18:17:42 UTC (rev 7434)
+++ trunk/bin/swiftdebug	2013-12-17 20:00:26 UTC (rev 7435)
@@ -3,7 +3,20 @@
 use strict;
 use warnings;
 use File::Basename;
+use Class::Struct;
 
+# Task structure
+struct Task          => { 
+    taskNumber       => '$',
+    thread           => '$',
+    host             => '$',
+    replicationGroup => '$',
+};
+
+# Hash for storing all tasks
+my %tasks = ();
+my $taskCounter = 0;
+
 # Print basic usage info
 sub usage() {
    &crash("Usage: $0 <logdir>");
@@ -15,26 +28,45 @@
    exit(1);
 }
 
-# Check usage
-if ( !$ARGV[0] ) {
-   &usage();
-}
-
-# Given a Swift log entry, decide if we want to it or not
+# Logic for what to do with a log entry
 sub processLogEntry() {
    (my $date, my $time, my $loglevel, my $class, my $message) = split(/\s+/, $_[0], 5);
    $time = (split(',', $time))[0];
+
    my @keywords_to_keep= ("VERSION", "ARGUMENTS", "SWIFT_CONFIGURATION", "SITES:", "TC:",
-                          "file:", "Using tc.data:");
-   foreach my $keyword(@keywords_to_keep) {
-      if( $message =~ m/$keyword/ ) {
-      # if( grep /$keyword/, @messageArray ) {
-         print "$time $message";
-         last;
-      }
+                          "SWIFTSCRIPT:" );
+   my $keyword_regexp = join('|', @keywords_to_keep);
+
+   # Define tasks
+   if ( $message =~ m/THREAD_ASSOCIATION/ ) {
+      &createTask($message);
+      return;
    }
+
+   # Reformat a message that matches a keyword we care about
+   if ( $message =~ m/$keyword_regexp/ ) {
+      print "$time $message";
+      return;
+   }
 }
 
+# Gather information about a task
+sub createTask() {
+
+   # Input: THREAD_ASSOCIATION jobid=sleep-n5t2pajl thread=R-4 host=westmere replicationGroup=null
+   $_[0] =~ s/jobid=|thread=|host=|replicationGroup=//g;
+   my ( $ignore, $taskid, $thread, $host, $replicationGroup ) = split(/\s+/, $_[0]);
+
+   my $t = Task->new();
+   $t->taskNumber($taskCounter);
+   $t->thread($thread);
+   $t->host($host);
+   $t->replicationGroup($replicationGroup);
+
+   $tasks{$taskid} = $t; 
+   $taskCounter += 1;
+}
+
 # Return true if input string starts with a date stamp
 sub hasDateStamp() {
    my $input = $_[0];
@@ -44,6 +76,11 @@
    return 0;
 }
 
+# Check usage
+if ( !$ARGV[0] ) {
+   &usage();
+}
+
 # Verify $run_directory
 my $run_directory = $ARGV[0];
 if ( ! -d "$run_directory" ) {
@@ -58,7 +95,7 @@
 my @multiline_entry = ();
 my $previous_line = "";
 
-# Parse each log entry, figure out if they're multiline entries or not
+# Read log, and send each entry (single or multi-line) to processLogEntry()
 while(my $line = <SWIFTLOG>) {
    if ( &hasDateStamp($line) ) {
       if ( &hasDateStamp($previous_line) ) {
@@ -69,3 +106,10 @@
       $previous_line .= "$line";
    }
 }
+
+# Print tasks
+while ( my ($key, $value) = each(%tasks) ) {
+   printf "Task %s => taskNumber=%d, thread=%s, host=%s, replicationGroup=%s\n",
+      $key, $value->taskNumber, $value->thread, $value->host, $value->replicationGroup;
+}
+




More information about the Swift-commit mailing list