source: gs2-extensions/parallel-building/trunk/src/bin/script/strace_to_tsv.pl@ 28766

Last change on this file since 28766 was 28766, checked in by jmt12, 10 years ago

Removing an occasional few characters of garbage that turn up in the log lines (anything before the timestamp, basically) for reasons both unknown and mysterious

  • Property svn:executable set to *
File size: 2.4 KB
Line 
1#!/usr/bin/perl
2
3open(STRACEIN, '<:utf8', 'strace.out') or die('Error! Failed to open file for reading: strace.out');
4open(TSVOUT, '>:utf8', 'strace.tsv') or die('Error! Failed to open file for writing: strace.tsv');
5print TSVOUT "TIMESTAMP\tPID\tSYSCALL\tELAPSED\tTOTALDUR\tTOTALIO\tTOTALCPU\tARGS\tRESULT\n";
6
7my $io_function_list = {
8 'access'=>1,
9 'chmod'=>1, 'close'=>1, 'creat'=>1,
10 'fclose'=>1, 'fcntl'=>1, 'fgetpos'=>1, 'flock'=>1, 'fseek'=>1, 'fsetpos'=>1,
11 'fstat'=>1, 'fsync'=>1, 'ftell'=>1,
12 'getdents'=>1,
13 'ioctl'=>1, # John added
14 'llseek'=>1, 'lockf'=>1, 'lseek'=>1, 'lseek64'=>1,
15 'mkdir'=>1,
16 'open'=>1,
17 'read'=>1, 'readdir'=>1, 'rename'=>1, 'rewind'=>1, 'rewinddir'=>1,
18 'scandir'=>1, 'stat'=>1, 'stat64'=>1,
19 'telldir'=>1,
20 'unlink'=>1,
21 'write'=>1
22 };
23
24print "Converting 'strace.out' to 'strace.tsv'... ";
25my $line = '';
26my $total_duration = 0;
27my $total_io_duration = 0;
28my $total_cpu_duration = 0;
29my $pid = 0;
30my $start_time = 0;
31while ($line = <STRACEIN>)
32{
33 # Garbage
34 if ($line =~ /^[^\d]+(.*)$/)
35 {
36 $line = $1;
37 }
38 # PID Prefix
39 if ($line =~ /^(\d+)\s+(.*)$/)
40 {
41 $pid = $1;
42 $line = $2;
43 }
44 # Special Cases
45 # - exit_group
46 if ($line =~ /^(\d+\.\d+)\s+exit_group\(0\)\s+=\s+\?$/)
47 {
48 }
49 # Normal Command
50 elsif ($line =~/^(\d+\.\d+)\s+([a-z0-9_]+)\((.*)\)\s+=\s+(.+)\s+<(\d+\.\d+)>$/s)
51 {
52 my $timestamp = $1;
53 my $syscall = $2;
54 my $args = $3;
55 my $result = $4;
56 my $duration = $5;
57
58 if ($start_time == 0)
59 {
60 $start_time = $timestamp;
61 $timestamp = 0;
62 }
63 else
64 {
65 $timestamp = $timestamp - $start_time;
66 }
67
68 print TSVOUT sprintf("%0.6f", $timestamp) . "\t";
69 print TSVOUT $pid . "\t";
70 print TSVOUT $syscall . "\t";
71 print TSVOUT sprintf("%0.6f", $duration) . "\t";
72 print TSVOUT $args . "\t";
73 print TSVOUT $result . "\n";
74 }
75 else
76 {
77 chomp($line);
78 print 'Unparsed: |' . $line . "|\n";
79 }
80}
81close(STRACEIN);
82close(TSVOUT);
83
84print "Complete!\n\n";
85print " - Duration: " . $total_duration . "\n";
86print " - Total IO: " . $total_io_duration . "\n";
87exit;
881;
Note: See TracBrowser for help on using the repository browser.