Wikis - Page

IDM Engine Trace Split Tool

1 Likes

#!#!/usr/bin/perl

###########################################################################
##  This perl script is created by Mike Labit, August 2013 Version=0.93  ##
##  I created this script so I can seperate out the Publisher and        ##
##  subscriber channels into two different traces files for              ##
##  troubleshooting purposes.                                            ##
##  I hope you find it useful.                                           ##
##  Please send any correspondance to mlabit@novell.com                  ##
##  									 ##
##  This script is free software: you can redistribute it and/or modify  ##
##  it under the terms of the GNU General Public License as published by ##
##  the Free Software Foundation, either version 3 of the License, or    ##
##  (at your option) any later version.                                  ##
##                                                                       ##
##  This program is distributed in the hope that it will be useful,      ##
##  but WITHOUT ANY WARRANTY; without even the implied warranty of       ##
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        ## 
##  GNU General Public License for more details.                         ##
##                                                                       ## 
###########################################################################

use strict;
use warnings;

(my $input, my $ST, my $PT) = @ARGV;

print "Usage: perl splitTrace input.log Subscriber.log, Publisher.log\n\n" unless $#ARGV == 2;

open IN, "<", $input or die "Cannot open $input: $!";
open ST, ">", $ST or die "Cannot open $ST: $!";
open PT, ">", $PT or die "Cannot open $PT: $!";

my $i;
my $kind;	# can be ST, PT or EV
while (<IN>) {
	if ($_ =~ /ST:/ and $_ =~ /\d{2}:\d{2}:\d{2}/ and $_ !~ /<.*>/) {
		$kind = "ST";
		print ST $_;
	} elsif ($_ =~ /PT:/ and $_ =~ /\d{2}:\d{2}:\d{2}/ and $_ !~ /<.*>/) {
		$kind = "PT";
		print PT $_;
	} elsif ($_ =~ /EV:|\s:/ and $_ =~ /\d{2}:\d{2}:\d{2}/ and $_ !~ /<.*>/) {
		$kind = "EV";
		print ST $_;
		print PT $_;		
	} else {
		print ST $_ if $kind and $kind eq "ST" or $kind eq "EV";
		print PT $_ if $kind and $kind eq "PT" or $kind eq "EV";
	}
}

close IN or die "Cannot close $input: $!";
close ST or die "Cannot close $ST: $!";
close PT or die "Cannot close $PT: $!";

The attached Perl script will take an input engine trace file and split the contents of it into two files, a subscriber channel file and a publisher channel file.  All neutral data is written into both files.  It does not modify the original trace file.

I created this Perl script because following an event in an IDM engine trace from a busy driver can be a challenge. Busy drivers can produce traces with intermixed publisher and subscriber channels making it somewhat difficult to follow the flow of a particular event. With this Perl script, you can now split the trace file, not losing any content, and having channel specific log files.

Usage:

Command line only and you need to have Perl 5.x or above. (may work with previous versions but not tested)

perl SplitTrace.pl <Input_Trace_File> <Subscriber_Output_File> <Publisher_Output_File>

ie.  perl SplitTrace.pl AD-Trace.log AD-Trace-SUB.log AD-Trace-PUB.log

ie. perl SplitTrace.pl /blah/Desktop/SAP_Trace.txt /tmp/SAP_SUB.txt /tmp/SAP_PUB.txt



 

Feel free to comment and make recommendations.

 

 

Labels:

Collateral
How To-Best Practice
Comment List
  • Seems the code as lost in one of the community migrations. Here's my copy of it

    #!#!/usr/bin/perl
    
    ###########################################################################
    ##  This perl script is created by Mike Labit, August 2013 Version=0.93  ##
    ##  I created this script so I can seperate out the Publisher and        ##
    ##  subscriber channels into two different traces files for              ##
    ##  troubleshooting purposes.                                            ##
    ##  I hope you find it useful.                                           ##
    ##  Please send any correspondance to mlabit@novell.com                  ##
    ##  									 ##
    ##  This script is free software: you can redistribute it and/or modify  ##
    ##  it under the terms of the GNU General Public License as published by ##
    ##  the Free Software Foundation, either version 3 of the License, or    ##
    ##  (at your option) any later version.                                  ##
    ##                                                                       ##
    ##  This program is distributed in the hope that it will be useful,      ##
    ##  but WITHOUT ANY WARRANTY; without even the implied warranty of       ##
    ##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        ## 
    ##  GNU General Public License for more details.                         ##
    ##                                                                       ## 
    ###########################################################################
    
    use strict;
    use warnings;
    
    (my $input, my $ST, my $PT) = @ARGV;
    
    print "Usage: perl splitTrace input.log Subscriber.log, Publisher.log\n\n" unless $#ARGV == 2;
    
    open IN, "<", $input or die "Cannot open $input: $!";
    open ST, ">", $ST or die "Cannot open $ST: $!";
    open PT, ">", $PT or die "Cannot open $PT: $!";
    
    my $i;
    my $kind;	# can be ST, PT or EV
    while (<IN>) {
    	if ($_ =~ /ST:/ and $_ =~ /\d{2}:\d{2}:\d{2}/ and $_ !~ /<.*>/) {
    		$kind = "ST";
    		print ST $_;
    	} elsif ($_ =~ /PT:/ and $_ =~ /\d{2}:\d{2}:\d{2}/ and $_ !~ /<.*>/) {
    		$kind = "PT";
    		print PT $_;
    	} elsif ($_ =~ /EV:|\s:/ and $_ =~ /\d{2}:\d{2}:\d{2}/ and $_ !~ /<.*>/) {
    		$kind = "EV";
    		print ST $_;
    		print PT $_;		
    	} else {
    		print ST $_ if $kind and $kind eq "ST" or $kind eq "EV";
    		print PT $_ if $kind and $kind eq "PT" or $kind eq "EV";
    	}
    }
    
    close IN or die "Cannot close $input: $!";
    close ST or die "Cannot close $ST: $!";
    close PT or die "Cannot close $PT: $!";
    
    

Related
Recommended