myslog 0.1.0 → 0.1.1
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/lib/myslog.rb +4 -9
- data/myslog.gemspec +2 -2
- data/spec/myslog_spec.rb +46 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: acc2b4218401ea178a7879e7af86a35cb421833f
|
|
4
|
+
data.tar.gz: 3fd0187e5be618194825df871deab6b7b2e6429b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0b0b5b8e7db1e435d4d22a033deb05f6bba7a9cea5657d1e77959df88dccea4e273f7b26eacb5cc7fc91b0f190ce696d0c7826973501428431609a057a6cbca6
|
|
7
|
+
data.tar.gz: 47b2f84d9b281e5f8df98cf65767e076ce5058a54af25c8ca2b0cabcea0882c3027efaddcb3cb6ef9f865ad589f247c9c5607196c1369e20bc87445f90064ff3
|
data/lib/myslog.rb
CHANGED
|
@@ -38,15 +38,10 @@ class MySlog
|
|
|
38
38
|
|
|
39
39
|
if record.start_with? "# User@Host:"
|
|
40
40
|
|
|
41
|
-
elems = record.split(
|
|
42
|
-
response[:user]
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
response[:host_ip] = elems[4].strip[1...-1]
|
|
46
|
-
else
|
|
47
|
-
response[:host] = elems[4].strip
|
|
48
|
-
response[:host_ip] = elems[5].strip[1...-1]
|
|
49
|
-
end
|
|
41
|
+
elems = record.split(/ /, 7)
|
|
42
|
+
response[:user] = elems[2].strip
|
|
43
|
+
response[:host] = elems[4].empty? ? nil : elems[4].strip
|
|
44
|
+
response[:host_ip] = elems[5].strip[1...-1]
|
|
50
45
|
elsif record.start_with? "#"
|
|
51
46
|
|
|
52
47
|
elems = record[2..-1].strip().split " "
|
data/myslog.gemspec
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Gem::Specification.new do |spec|
|
|
2
2
|
spec.name = "myslog"
|
|
3
|
-
spec.version = "0.1.
|
|
4
|
-
spec.authors = ["
|
|
3
|
+
spec.version = "0.1.1"
|
|
4
|
+
spec.authors = ["Yuku Takahashi"]
|
|
5
5
|
spec.email = ["taka84u9@gmail.com"]
|
|
6
6
|
spec.summary = "MySQL slow query parser."
|
|
7
7
|
spec.description = "MySQL slow query parser."
|
data/spec/myslog_spec.rb
CHANGED
|
@@ -53,6 +53,12 @@ use mysql;
|
|
|
53
53
|
SET timestamp=1455094936;
|
|
54
54
|
select
|
|
55
55
|
sleep(2);
|
|
56
|
+
# Time: 160219 21:58:25
|
|
57
|
+
# User@Host: root[root] @ [192.168.10.1] Id: 1
|
|
58
|
+
# Query_time: 0.000985 Lock_time: 0.000985 Rows_sent: 1 Rows_examined: 1
|
|
59
|
+
use test_db;
|
|
60
|
+
SET timestamp=1455886705;
|
|
61
|
+
select * from test_table;
|
|
56
62
|
EOF
|
|
57
63
|
end
|
|
58
64
|
|
|
@@ -121,7 +127,13 @@ sleep(2);
|
|
|
121
127
|
expect(record[0]).to eq(
|
|
122
128
|
"# Time: 2016-02-10T18:02:16.411200+09:00"
|
|
123
129
|
)
|
|
124
|
-
|
|
130
|
+
|
|
131
|
+
record = results[6]
|
|
132
|
+
expect(record.size).to eq(4)
|
|
133
|
+
expect(record[0]).to eq(
|
|
134
|
+
"# Time: 160219 21:58:25"
|
|
135
|
+
)
|
|
136
|
+
|
|
125
137
|
end
|
|
126
138
|
end
|
|
127
139
|
|
|
@@ -277,7 +289,40 @@ sleep(2);
|
|
|
277
289
|
expect(@response[:sql]).to eq(@sql.strip)
|
|
278
290
|
end
|
|
279
291
|
end
|
|
292
|
+
end
|
|
280
293
|
|
|
294
|
+
context "given unexist localhost and exist Id" do
|
|
295
|
+
describe "response" do
|
|
296
|
+
before :each do
|
|
297
|
+
@user = "root[root]"
|
|
298
|
+
@host = nil
|
|
299
|
+
@host_ip = "192.168.10.1"
|
|
300
|
+
@query_time = 0.000985
|
|
301
|
+
@lock_time = 0.000985
|
|
302
|
+
@rows_sent = 1
|
|
303
|
+
@rows_examined = 1
|
|
304
|
+
@sql = "SET timestamp=1455886705; SELECT * FROM test_table;"
|
|
305
|
+
@lines = [
|
|
306
|
+
"# User@Host: #{@user} @ #{@host} [#{@host_ip}] Id: 1",
|
|
307
|
+
"# Query_time: #{@query_time} Lock_time: #{@lock_time} Rows_sent: #{@rows_sent} Rows_examined: #{@rows_examined}",
|
|
308
|
+
@sql
|
|
309
|
+
]
|
|
310
|
+
@response = @myslog.parse_record(@lines)
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
it "should have expected values" do
|
|
314
|
+
expect(@response[:date].utc.to_s).to eq("2016-02-19 12:58:25 UTC")
|
|
315
|
+
expect(@response[:user]).to eq(@user)
|
|
316
|
+
expect(@response[:host]).to eq(@host)
|
|
317
|
+
expect(@response[:host_ip]).to eq(@host_ip)
|
|
318
|
+
expect(@response[:query_time]).to eq(@query_time)
|
|
319
|
+
expect(@response[:lock_time]).to eq(@lock_time)
|
|
320
|
+
expect(@response[:rows_sent]).to eq(@rows_sent)
|
|
321
|
+
expect(@response[:rows_examined]).to eq(@rows_examined)
|
|
322
|
+
expect(@response[:sql]).to eq(@sql.strip)
|
|
323
|
+
end
|
|
324
|
+
end
|
|
281
325
|
end
|
|
326
|
+
|
|
282
327
|
end
|
|
283
328
|
end
|
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.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
7
|
+
- Yuku Takahashi
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-02-
|
|
11
|
+
date: 2016-02-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|