-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs_chk_strace.pl
executable file
·87 lines (66 loc) · 1.71 KB
/
js_chk_strace.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/perl
##########################################
# program name : js_chk_strace.pl
# Copyright ? 2020 Jun Su Lee. All rights reserved.
# Author : Jun Su Lee ( [email protected] )
# Description : checking linux strace output with time option.
# ex) strace -tt -F -T -o strace.out time ./db2locssh nitdbo01 hostname
# Note :
#
# Category : DB2 support
# Usage
# js_view_stacks.pl -f='FODC_Trap*/*trap.txt'
# Date : Feb.21, 2019
# Revision History
# - Aug. 24, 2019 : Split each stack with empty rows
#
##########################################
# format
# 9004 16:11:24.978954 read(7, "Name:\tkworker/0:0\nUmask:\t0000\nSt"..., 2048) = 905 <0.000023>
use Getopt::Long;
use File::Basename;
my $fileName;
my @fileList;
my $pattern;
my $DEBUG;
my $totalTime;
my $totalCnt=0;
sub usage{
print <<AUD ;
Usage :
$prog -f <filename> -p <Regular experesson pattern to grep>
example :
$prog -f 'strace.out_time' -p 'read('
AUD
exit;
}
&usage if( scalar(@ARGV) < 2 );
GetOptions(
"filename=s" => \$fileName,
"pattern=s" => \$pattern,
"debug=i" => \$DEBUG
)
or die "Incorrect usage ! \n";
@fileList = glob($fileName);
sub doParseStrace {
my ( $fn ) = @_ ;
open FH, $fn or die "can't open the file $fn \n\n";
print "\n\n== $fn : ==\n\n";
while ( <FH> ) {
##
if ( m/$pattern.+(\d+\.\d+)/ ) {
print $_;
$deltaTime=$1;
$totalTime=$totalTime + $1;
$totalCnt=$totalCnt + 1;
print "$pattern : $deltaTime\n";
}
}
print "\n";
}
foreach my $inputFile (@fileList){
doParseStrace $inputFile;
}
print "========================================\n";
print "Pattern : totalCount : totalTime\n";
print "$pattern : $totalCnt : $totalTime\n";