strace_log 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +90 -0
- data/lib/strace_log.rb +6 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60912730fd9e97f6be5618218c74dbe050c5e01f
|
4
|
+
data.tar.gz: b3e0abf9c2c8b62ef9b223fce27cd02f3fe32e6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 950e8007b438cf96b95ab82c545e73df6ea695b1091fa044c988dbc096f98fe26d187f9916fc4df6bdc41571441813c517a173ea126bee20afe535949851ee31
|
7
|
+
data.tar.gz: 535ef872af158736e7431b964b7a9a932b7bb0e6e7237a56df080211c1d5a53424abd0012e35c0a9c1fda5b67722ff4754d88042b12a040bd7b0cacff66a6b2d
|
data/README.md
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
Parse logs generated by Strace (system call tracer) and obtain statistics.
|
4
4
|
|
5
|
+
* [GitHub](https://github.com/masa16/strace_log)
|
6
|
+
* [RubyGems](https://rubygems.org/gems/strace_log)
|
7
|
+
|
5
8
|
## Installation
|
6
9
|
|
7
10
|
Add this line to your application's Gemfile:
|
@@ -34,6 +37,93 @@ Print statistics of strace log:
|
|
34
37
|
* StraceLog::IOCounter
|
35
38
|
* StraceLog::Stat
|
36
39
|
|
40
|
+
## Example
|
41
|
+
|
42
|
+
$ strace -ttt -T -o strace.log dd if=/dev/zero of=tmpfile count=10000
|
43
|
+
|
44
|
+
$ strace-stat strace.log
|
45
|
+
count={
|
46
|
+
execve: 1,
|
47
|
+
brk: 3,
|
48
|
+
mmap: 16,
|
49
|
+
access: 1,
|
50
|
+
open: 42,
|
51
|
+
stat: 19,
|
52
|
+
read: 10005,
|
53
|
+
fstat: 6,
|
54
|
+
mprotect: 7,
|
55
|
+
close: 11,
|
56
|
+
arch_prctl: 1,
|
57
|
+
set_tid_address: 1,
|
58
|
+
set_robust_list: 1,
|
59
|
+
futex: 2,
|
60
|
+
rt_sigaction: 6,
|
61
|
+
rt_sigprocmask: 1,
|
62
|
+
getrlimit: 1,
|
63
|
+
dup2: 2,
|
64
|
+
lseek: 1,
|
65
|
+
clock_gettime: 2,
|
66
|
+
write: 10003,
|
67
|
+
munmap: 1,
|
68
|
+
exit_group: 1,
|
69
|
+
}
|
70
|
+
|
71
|
+
time={
|
72
|
+
execve: 0.000479,
|
73
|
+
brk: 0.000376,
|
74
|
+
mmap: 0.001751,
|
75
|
+
access: 0.000157,
|
76
|
+
open: 0.004224,
|
77
|
+
stat: 0.001602,
|
78
|
+
read: 1.176440,
|
79
|
+
fstat: 0.000697,
|
80
|
+
mprotect: 0.000647,
|
81
|
+
close: 0.006732,
|
82
|
+
arch_prctl: 0.000101,
|
83
|
+
set_tid_address: 0.000127,
|
84
|
+
set_robust_list: 0.000111,
|
85
|
+
futex: 0.000232,
|
86
|
+
rt_sigaction: 0.000718,
|
87
|
+
rt_sigprocmask: 0.000116,
|
88
|
+
getrlimit: 0.000091,
|
89
|
+
dup2: 0.000213,
|
90
|
+
lseek: 0.000112,
|
91
|
+
clock_gettime: 0.000343,
|
92
|
+
write: 1.229899,
|
93
|
+
munmap: 0.000110,
|
94
|
+
}
|
95
|
+
|
96
|
+
/bin/dd:
|
97
|
+
ok={execve:1}
|
98
|
+
time={execve:0.000479}
|
99
|
+
|
100
|
+
/dev/zero:
|
101
|
+
ok={close:2, dup2:1, lseek:1, open:1, read:10000}
|
102
|
+
size={read:5120000}
|
103
|
+
time={close:0.000224, dup2:0.000112, lseek:0.000112, open:0.000119, read:1.176062}
|
104
|
+
|
105
|
+
/etc/ld.so.preload:
|
106
|
+
fail={access:1}
|
107
|
+
time={access:0.000157}
|
108
|
+
|
109
|
+
...
|
110
|
+
|
111
|
+
/usr/share/locale/locale.alias:
|
112
|
+
ok={close:1, fstat:1, open:1, read:2}
|
113
|
+
size={read:2512}
|
114
|
+
time={close:0.000202, fstat:0.000216, open:0.000124, read:0.000221}
|
115
|
+
|
116
|
+
stderr:
|
117
|
+
ok={close:1, write:3}
|
118
|
+
size={write:90}
|
119
|
+
time={close:0.000022, write:0.000243}
|
120
|
+
|
121
|
+
tmpfile:
|
122
|
+
ok={close:2, dup2:1, open:1, write:10000}
|
123
|
+
size={write:5120000}
|
124
|
+
time={close:0.005866, dup2:0.000101, open:0.000154, write:1.229656}
|
125
|
+
|
126
|
+
|
37
127
|
## Contributing
|
38
128
|
|
39
129
|
1. Fork it ( https://github.com/masa16/strace_log/fork )
|
data/lib/strace_log.rb
CHANGED
@@ -2,13 +2,13 @@ require 'strscan'
|
|
2
2
|
|
3
3
|
module StraceLog
|
4
4
|
|
5
|
-
VERSION = "0.1.
|
5
|
+
VERSION = "0.1.3"
|
6
6
|
|
7
7
|
class ParsedCall
|
8
8
|
ESCAPES = [ /x[\da-f][\da-f]/i, /n/, /t/, /r/, /\\/, /"/, /\d+/]
|
9
9
|
|
10
10
|
def initialize(line)
|
11
|
-
if /^(?:(\d\d:\d\d:\d\d|\d+)(?:\.(\d+))? )
|
11
|
+
if /^(?:(\d\d:\d\d:\d\d|\d+)(?:\.(\d+))? )?[+-]{3}.*[+-]{3}$/ =~ line
|
12
12
|
@mesg = line
|
13
13
|
else
|
14
14
|
s = StringScanner.new(line)
|
@@ -137,7 +137,7 @@ module StraceLog
|
|
137
137
|
end
|
138
138
|
if !@time.empty?
|
139
139
|
keys = @time.keys.sort
|
140
|
-
Kernel.print " time={"+keys.map{|k| "%s:%.
|
140
|
+
Kernel.print " time={"+keys.map{|k| "%s:%.6f"%[k,@time[k]]}.join(", ")+"}\n"
|
141
141
|
end
|
142
142
|
if !@rename.empty?
|
143
143
|
Kernel.print " rename={#{@rename.join(', ')}}\n"
|
@@ -200,8 +200,8 @@ module StraceLog
|
|
200
200
|
fd = pc.args[0].to_i
|
201
201
|
count_fd(fd,pc)
|
202
202
|
if pc.ret != "-1"
|
203
|
-
|
204
|
-
@fd2path[
|
203
|
+
fd2 = pc.ret.to_i
|
204
|
+
@fd2path[fd2] = @fd2path[fd]
|
205
205
|
end
|
206
206
|
|
207
207
|
when /^mmap$/
|
@@ -253,7 +253,7 @@ module StraceLog
|
|
253
253
|
Kernel.print "}\n\n"
|
254
254
|
Kernel.print "time={\n"
|
255
255
|
@spent.each do |m,t|
|
256
|
-
Kernel.printf " %s: %.
|
256
|
+
Kernel.printf " %s: %.6f,\n",m,t
|
257
257
|
end
|
258
258
|
Kernel.print "}\n\n"
|
259
259
|
files = @stat.keys.select{|x| x.class==String}.sort
|