myslog 0.0.11 → 0.1.0
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/.travis.yml +2 -0
- data/CHANGELOG.md +3 -0
- data/lib/myslog.rb +2 -0
- data/myslog.gemspec +2 -2
- data/spec/myslog_spec.rb +95 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01ae65979b5ba26faf80d43e15c9a0f8178e0f61
|
4
|
+
data.tar.gz: 8e4c38a14bf1fdd953ee165423e5fea39395fed0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 781f661946cde324e8ae78e5ee30aaed434478d07344b3abe699fc6993d5b18e1d93e1685b88f0026c0e3be97438bddb063c8562361474c2e4b048b2d330e4aa
|
7
|
+
data.tar.gz: 8d4965c1611b43bbc04a1d911da3d0e2ae6a978bf621e80c057cd2add85ebd0b9ba00693071c452ef8919a94537e8505a61ffb728a00749f097831c3b6f68c62
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
data/lib/myslog.rb
CHANGED
@@ -52,6 +52,8 @@ class MySlog
|
|
52
52
|
elems = record[2..-1].strip().split " "
|
53
53
|
if elems.size == 3 && elems[0] == "Time:"
|
54
54
|
response[:date] = Time.parse(elems[1]+" "+elems[2])
|
55
|
+
elsif elems.size == 2 && elems[0] == "Time:"
|
56
|
+
response[:date] = Time.parse(elems[1][0..9]+" "+elems[1][11..18])
|
55
57
|
else
|
56
58
|
elems.each_with_index do |elem,i|
|
57
59
|
if elem.include?(":") && !elems[i+1].include?(":")
|
data/myslog.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "myslog"
|
3
|
-
spec.version = "0.0
|
3
|
+
spec.version = "0.1.0"
|
4
4
|
spec.authors = ["taka84u9"]
|
5
5
|
spec.email = ["taka84u9@gmail.com"]
|
6
6
|
spec.summary = "MySQL slow query parser."
|
7
7
|
spec.description = "MySQL slow query parser."
|
8
|
-
spec.homepage = "https://github.com/
|
8
|
+
spec.homepage = "https://github.com/yuku-t/myslog"
|
9
9
|
|
10
10
|
spec.files = `git ls-files -z`.split("\x0")
|
11
11
|
spec.require_paths = ["lib"]
|
data/spec/myslog_spec.rb
CHANGED
@@ -41,6 +41,18 @@ use webtie;
|
|
41
41
|
tm.to_id = 21259 and
|
42
42
|
tm.to_group = 'retard_user' and
|
43
43
|
tms.description = 'new';
|
44
|
+
# Time: 2016-01-29T05:45:46.299805Z
|
45
|
+
# User@Host: root[root] @ localhost [] Id: 2
|
46
|
+
# Query_time: 1.000537 Lock_time: 0.000000 Rows_sent: 1 Rows_examined: 0
|
47
|
+
SET timestamp=1455094924;
|
48
|
+
select sleep(1);
|
49
|
+
# Time: 2016-02-10T18:02:16.411200+09:00
|
50
|
+
# User@Host: root[root] @ localhost [] Id: 2
|
51
|
+
# Query_time: 2.000361 Lock_time: 0.000000 Rows_sent: 1 Rows_examined: 0
|
52
|
+
use mysql;
|
53
|
+
SET timestamp=1455094936;
|
54
|
+
select
|
55
|
+
sleep(2);
|
44
56
|
EOF
|
45
57
|
end
|
46
58
|
|
@@ -97,6 +109,19 @@ use webtie;
|
|
97
109
|
expect(record[0]).to eq(
|
98
110
|
"# Time: 010626 10:44:51"
|
99
111
|
)
|
112
|
+
|
113
|
+
record = results[4]
|
114
|
+
expect(record.size).to eq(4)
|
115
|
+
expect(record[0]).to eq(
|
116
|
+
"# Time: 2016-01-29T05:45:46.299805Z"
|
117
|
+
)
|
118
|
+
|
119
|
+
record = results[5]
|
120
|
+
expect(record.size).to eq(4)
|
121
|
+
expect(record[0]).to eq(
|
122
|
+
"# Time: 2016-02-10T18:02:16.411200+09:00"
|
123
|
+
)
|
124
|
+
|
100
125
|
end
|
101
126
|
end
|
102
127
|
|
@@ -151,6 +176,76 @@ use webtie;
|
|
151
176
|
end
|
152
177
|
end
|
153
178
|
|
179
|
+
context "given full log by UTC in MySQL5.7 and later" do
|
180
|
+
describe "response" do
|
181
|
+
before :each do
|
182
|
+
@date = Time.at(1317619058)
|
183
|
+
@user = "root[root]"
|
184
|
+
@host = "localhost"
|
185
|
+
@host_ip = ""
|
186
|
+
@query_time = 0.000270
|
187
|
+
@lock_time = 0.000097
|
188
|
+
@rows_sent = 1
|
189
|
+
@rows_examined = 0
|
190
|
+
@sql = "SET timestamp=1317619058; SELECT * FROM life;"
|
191
|
+
@lines = [
|
192
|
+
"# Time: #{@date.strftime("%y-%m-%dT%H:%M:%S.%6N")}Z",
|
193
|
+
"# User@Host: #{@user} @ #{@host} [#{@host_ip}]",
|
194
|
+
"# Query_time: #{@query_time} Lock_time: #{@lock_time} Rows_sent: #{@rows_sent} Rows_examined: #{@rows_examined}",
|
195
|
+
@sql
|
196
|
+
]
|
197
|
+
@response = @myslog.parse_record(@lines)
|
198
|
+
end
|
199
|
+
|
200
|
+
it "should have expected values" do
|
201
|
+
expect(@response[:date].to_i).to eq(@date.to_i)
|
202
|
+
expect(@response[:user]).to eq(@user)
|
203
|
+
expect(@response[:host]).to eq(@host)
|
204
|
+
expect(@response[:host_ip]).to eq(@host_ip)
|
205
|
+
expect(@response[:query_time]).to eq(@query_time)
|
206
|
+
expect(@response[:lock_time]).to eq(@lock_time)
|
207
|
+
expect(@response[:rows_sent]).to eq(@rows_sent)
|
208
|
+
expect(@response[:rows_examined]).to eq(@rows_examined)
|
209
|
+
expect(@response[:sql]).to eq(@sql.strip)
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
context "given full log by JST in MySQL5.7 and later" do
|
215
|
+
describe "response" do
|
216
|
+
before :each do
|
217
|
+
@date = Time.at(1317619058)
|
218
|
+
@user = "root[root]"
|
219
|
+
@host = "localhost"
|
220
|
+
@host_ip = ""
|
221
|
+
@query_time = 0.000270
|
222
|
+
@lock_time = 0.000097
|
223
|
+
@rows_sent = 1
|
224
|
+
@rows_examined = 0
|
225
|
+
@sql = "SET timestamp=1317619058; SELECT * FROM life;"
|
226
|
+
@lines = [
|
227
|
+
"# Time: #{@date.strftime("%y-%m-%dT%H:%M:%S.%6N")}+09:00",
|
228
|
+
"# User@Host: #{@user} @ #{@host} [#{@host_ip}]",
|
229
|
+
"# Query_time: #{@query_time} Lock_time: #{@lock_time} Rows_sent: #{@rows_sent} Rows_examined: #{@rows_examined}",
|
230
|
+
@sql
|
231
|
+
]
|
232
|
+
@response = @myslog.parse_record(@lines)
|
233
|
+
end
|
234
|
+
|
235
|
+
it "should have expected values" do
|
236
|
+
expect(@response[:date].to_i).to eq(@date.to_i)
|
237
|
+
expect(@response[:user]).to eq(@user)
|
238
|
+
expect(@response[:host]).to eq(@host)
|
239
|
+
expect(@response[:host_ip]).to eq(@host_ip)
|
240
|
+
expect(@response[:query_time]).to eq(@query_time)
|
241
|
+
expect(@response[:lock_time]).to eq(@lock_time)
|
242
|
+
expect(@response[:rows_sent]).to eq(@rows_sent)
|
243
|
+
expect(@response[:rows_examined]).to eq(@rows_examined)
|
244
|
+
expect(@response[:sql]).to eq(@sql.strip)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
154
249
|
context "given partial log" do
|
155
250
|
describe "response" do
|
156
251
|
before :each do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: myslog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- taka84u9
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- ".coverrails.yml"
|
63
63
|
- ".gitignore"
|
64
64
|
- ".travis.yml"
|
65
|
+
- CHANGELOG.md
|
65
66
|
- Gemfile
|
66
67
|
- LICENSE
|
67
68
|
- README.md
|
@@ -70,7 +71,7 @@ files:
|
|
70
71
|
- myslog.gemspec
|
71
72
|
- spec/myslog_spec.rb
|
72
73
|
- spec/spec_helper.rb
|
73
|
-
homepage: https://github.com/
|
74
|
+
homepage: https://github.com/yuku-t/myslog
|
74
75
|
licenses: []
|
75
76
|
metadata: {}
|
76
77
|
post_install_message:
|
@@ -89,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
90
|
version: '0'
|
90
91
|
requirements: []
|
91
92
|
rubyforge_project:
|
92
|
-
rubygems_version: 2.
|
93
|
+
rubygems_version: 2.4.5.1
|
93
94
|
signing_key:
|
94
95
|
specification_version: 4
|
95
96
|
summary: MySQL slow query parser.
|