fluent-plugin-perf-tools 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ed0360305defb0ee3fc7b8ec534ee4b9ee18077
|
4
|
+
data.tar.gz: 477a32460779d05cab3052ce594001e1c7ba8df7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7103ad358638e785b7d226653e2df8a27a758b7b74abc39e59128825cbb36e7ebc590e51f9ebd5b7f7b8a2b11fb6eaac7347ba6a2b146fe4a16bcba556240c73
|
7
|
+
data.tar.gz: 306d4853ec6dbe06147daed8390f2c38c2749901aa6276c3cc31d7ec04615b2faa1b7ee81a25777a0a11183493b25978c21ced5928a647a5a9393743e5a546b8
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Fluent
|
4
|
+
module Plugin
|
5
|
+
module PerfTools
|
6
|
+
# base class for all perf-tools command
|
7
|
+
# provides common behavior for all command
|
8
|
+
class Base
|
9
|
+
DEFAULT_INTERVAL = 30
|
10
|
+
DEFAULT_COMMAND_ARGS = ""
|
11
|
+
DEFAULT_TIME_KEY = "TIME"
|
12
|
+
|
13
|
+
class << self
|
14
|
+
attr_reader :command, :discard_regexp, :location
|
15
|
+
|
16
|
+
def set_command(command)
|
17
|
+
@command = command
|
18
|
+
end
|
19
|
+
|
20
|
+
def set_discard_regexp(regexp)
|
21
|
+
@discard_regexp = regexp
|
22
|
+
end
|
23
|
+
|
24
|
+
def set_location(location)
|
25
|
+
@location = location
|
26
|
+
end
|
27
|
+
|
28
|
+
def time_key
|
29
|
+
@time_key ||= DEFAULT_TIME_KEY
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_time_key(key)
|
33
|
+
@time_key = key
|
34
|
+
end
|
35
|
+
|
36
|
+
def command_path
|
37
|
+
File.expand_path(File.join(File.expand_path(__dir__), "../../../../perf-tools/#{location}/#{command}"))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
attr_reader :command_args, :interval, :time_key
|
42
|
+
|
43
|
+
def initialize(command_args:, interval:)
|
44
|
+
@command_args = command_args || DEFAULT_COMMAND_ARGS
|
45
|
+
@interval = interval || DEFAULT_INTERVAL
|
46
|
+
@time_key = DEFAULT_TIME_KEY
|
47
|
+
end
|
48
|
+
|
49
|
+
def stream
|
50
|
+
headers = nil
|
51
|
+
IO.popen("sudo #{command_path} #{command_args} #{interval}").each do |line|
|
52
|
+
next if discard_regexp && line.match(discard_regexp)
|
53
|
+
|
54
|
+
unless headers
|
55
|
+
headers = line.split
|
56
|
+
next
|
57
|
+
end
|
58
|
+
|
59
|
+
record = headers.zip(line.split).to_h
|
60
|
+
time = parse_time(record)
|
61
|
+
|
62
|
+
yield time, record
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def parse_time(record)
|
67
|
+
if time_key && record.respond_to?(:has_key?) && record.key?(time_key)
|
68
|
+
Fluent::EventTime.from_time(Time.parse(record[time_key]))
|
69
|
+
else
|
70
|
+
Fluent::EventTime.now
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def command_path
|
75
|
+
self.class.command_path
|
76
|
+
end
|
77
|
+
|
78
|
+
def discard_regexp
|
79
|
+
self.class.discard_regexp
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -1,62 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "base"
|
4
|
+
|
3
5
|
module Fluent
|
4
6
|
module Plugin
|
5
7
|
module PerfTools
|
6
|
-
class Cachestat
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
EXTRA_INFO_REGEXP = /^Counting cache functions...|^Ending tracing.../
|
11
|
-
TIME_KEY = 'TIME'
|
12
|
-
|
13
|
-
def self.command
|
14
|
-
COMMAND
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.command_path
|
18
|
-
File.expand_path(File.join(File.expand_path(__dir__), "../../../../perf-tools/fs/#{COMMAND}"))
|
19
|
-
end
|
20
|
-
|
21
|
-
attr_reader :command_args, :interval
|
22
|
-
|
23
|
-
def initialize(command_args:, interval:)
|
24
|
-
@command_args = command_args || DEFAULT_COMMAND_ARGS
|
25
|
-
@interval = interval || DEFAULT_INTERVAL
|
26
|
-
end
|
27
|
-
|
28
|
-
def command_path
|
29
|
-
self.class.command_path
|
30
|
-
end
|
31
|
-
|
32
|
-
def time_key
|
33
|
-
TIME_KEY
|
34
|
-
end
|
35
|
-
|
36
|
-
def stream
|
37
|
-
headers = nil
|
38
|
-
IO.popen("sudo #{command_path} #{command_args} #{interval}").each do |line|
|
39
|
-
next if line.match(EXTRA_INFO_REGEXP)
|
40
|
-
|
41
|
-
unless headers
|
42
|
-
headers = line.split
|
43
|
-
next
|
44
|
-
end
|
45
|
-
|
46
|
-
record = headers.zip(line.split).to_h
|
47
|
-
time = parse_time(record)
|
48
|
-
|
49
|
-
yield time, record
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def parse_time(record)
|
54
|
-
if time_key && record.respond_to?(:has_key?) && record.has_key?(time_key)
|
55
|
-
Fluent::EventTime.from_time(Time.parse(record[time_key]))
|
56
|
-
else
|
57
|
-
Fluent::EventTime.now
|
58
|
-
end
|
59
|
-
end
|
8
|
+
class Cachestat < Base
|
9
|
+
set_command "cachestat"
|
10
|
+
set_location "fs"
|
11
|
+
set_discard_regexp /^Counting cache functions...|^Ending tracing.../
|
60
12
|
end
|
61
13
|
|
62
14
|
Command.reference(Cachestat)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-perf-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Tych
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bump
|
@@ -237,6 +237,7 @@ files:
|
|
237
237
|
- fluent-plugin-perf-tools.gemspec
|
238
238
|
- lib/fluent/plugin/in_perf_tools.rb
|
239
239
|
- lib/fluent/plugin/perf_tools.rb
|
240
|
+
- lib/fluent/plugin/perf_tools/base.rb
|
240
241
|
- lib/fluent/plugin/perf_tools/cachestat.rb
|
241
242
|
- lib/fluent/plugin/perf_tools/command.rb
|
242
243
|
- lib/fluent/plugin/perf_tools/version.rb
|