fluent-plugin-watch-process 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2d114a31b165c3feca90dac92247785d9f757e8951ded1aac49bc30806e505a1
4
+ data.tar.gz: 9a2aab2afb95873873e3e3581b2f5f23b12bd0e7062d456b7eebe257c7f8473a
5
+ SHA512:
6
+ metadata.gz: ad4b0bffb25faaed2082c8bab5904100750ee265113097a0f643d5c13305c53731a9afcb6bd0b661fba1d012b45e74294c57defd530a774fbaf052135bcb6f43
7
+ data.tar.gz: 8f4761bfec54a36ecb2f702d7749ce4fd21bb69f35834aaeef274167456de74e0e8c4d7d09bdaaa90dc9bc3647d66eafbeb16d81ca24aede35fb4d273edd7e43
data/.travis.yml CHANGED
@@ -10,11 +10,4 @@ before_install:
10
10
 
11
11
  gemfile:
12
12
  - Gemfile
13
- - gemfiles/fluentd_v0.12.gemfile
14
13
  - gemfiles/fluentd_v0.14.gemfile
15
-
16
- matrix:
17
- include:
18
- - rvm: 2.0.0
19
- gemfile: gemfiles/fluentd_v0.12.gemfile
20
-
data/README.md CHANGED
@@ -25,10 +25,10 @@ install with gem or fluent-gem command as:
25
25
  $ gem install fluent-plugin-watch-process
26
26
 
27
27
  # for td-agent
28
- $ sudo /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-watch-process -v 0.1.0
28
+ $ sudo /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-watch-process -v 0.1.1
29
29
 
30
30
  # for td-agent2 (recommend)
31
- $ sudo td-agent-gem install fluent-plugin-watch-process -v 0.1.0
31
+ $ sudo td-agent-gem install fluent-plugin-watch-process -v 0.1.1
32
32
  ```
33
33
 
34
34
  ## Configuration
@@ -68,14 +68,20 @@ $ tail -f /var/log/td-agent/td-agent.log
68
68
  * execute ps command with some options
69
69
  * [default] Linux: `LANG=en_US.UTF-8 && ps -ewwo lstart,user:20,pid,ppid,time,%cpu,%mem,rss,sz,s,comm,cmd`
70
70
  * [default] MacOSX: `LANG=en_US.UTF-8 && ps -ewwo lstart,user,pid,ppid,time,%cpu,%mem,rss,vsz,state,comm,command`
71
+ * [default] Windows: described in the next section, `About Windows`.
71
72
 
72
73
  * keys (Optional)
73
74
  * output record keys of the ps command results
74
- * [default] start_time user pid parent_pid cpu_time cpu_percent memory_percent mem_rss mem_size state proc_name command
75
+ * [default] Linux, MacOSX: `start_time,user,pid,parent_pid,cpu_time,cpu_percent,memory_percent,mem_rss,mem_size,state,proc_name,command`
76
+ * need to modify `command` too if you modify this value.
77
+ * [default] Windows: `StartTime,UserName,SessionId,Id,CPU,WorkingSet,VirtualMemorySize,HandleCount,ProcessName`
78
+ * in Windows only, you can fix this without fixing `command`. These keys can be specified from the properties of `System.Diagnostics.Process` object of `.NET`.
79
+ * `UserName` key needs administrator privilege. You can exclude this to avoid needing administrator privilege.
75
80
 
76
81
  * types (Optional)
77
82
  * settings of converting types from string to integer/float.
78
- * [default] pid:integer parent_pid:integer cpu_percent:float memory_percent:float mem_rss:integer mem_size:integer
83
+ * [default] Linux, MacOSX: `pid:integer,parent_pid:integer,cpu_percent:float,memory_percent:float,mem_rss:integer,mem_size:integer`
84
+ * [default] Windows: `SessionId:integer,Id:integer,CPU:float,WorkingSet:integer,VirtualMemorySize:integer,HandleCount:integer`
79
85
 
80
86
  * interval (Optional)
81
87
  * execute interval time
@@ -90,6 +96,54 @@ $ tail -f /var/log/td-agent/td-agent.log
90
96
  * to use short hostname, set `hostname -s` for this option on linux/mac.
91
97
  * [default] `hostname`
92
98
 
99
+ * powershell_command (Optional)
100
+ * settings for powershell command name. PowerShell Core had been renamed its command to `pwsh` and PowerShell 7 continues to use `pwsh` as its command name.
101
+ * [default] `powershell`
102
+ * [avaliables] `powershell`, `pwsh`
103
+
104
+ ### About Windows
105
+
106
+ Default `command` preset for Windows provides many of keys as below. Generally, you can pick up the columns with `keys` option.
107
+ If you need additional keys, consider to update `command` option.
108
+
109
+ `````powershell
110
+ powershell -command "Get-Process -IncludeUserName
111
+ | ?{$_.StartTime -ne $NULL -and $_.CPU -ne $NULL}
112
+ | Select-Object -Property StartTime,UserName,SessionId,Id,CPU,WorkingSet,VirtualMemorySize,HandleCount,ProcessName
113
+ | %{$_.StartTime = $_.StartTime.ToString('o'); return $_;}
114
+ | ConvertTo-Csv -NoTypeInformation"
115
+ `````
116
+
117
+ Confirmed versions are:
118
+
119
+ | Windows version | PowerShell version information | Note |
120
+ | ------------------------------ | ------------------------------------------------------------------------- |-----------------------------------------------|
121
+ | Windows 10 10.0.19042 (20H2) | PSVersion: 5.1.19041.906 (default installed version), PSEdition: Desktop | `powershell_command` as `powershell` (default)|
122
+ | Windows 10 10.0.19042 (20H2) | PSVersion: 7.1.2, PSEdition: Core | `powershell_command` as `pwsh` |
123
+
124
+
125
+ Here are details of this default command.
126
+
127
+ * `Get-Process -IncludeUserName`
128
+ * `Get-Process` powershell command takes `System.Diagnostics.Process` objects.
129
+ * `IncludeUserName` option is needed to take `UserName`.
130
+ * this needs administrator privilege.
131
+ * this will be omitted if `keys` does not contain `UserName`.
132
+ * ` | ?{$_.StartTime -ne $NULL -and $_.CPU -ne $NULL}`
133
+ * this exlcludes some special processes that don't have some properties, such as the "Idle" process in Windows.
134
+ * ` | Select-Object -Property ...`
135
+ * this takes the necessary parameters from `System.Diagnostics.Process` objects.
136
+ * `...` part will be automatically fixed by `keys`.
137
+ * ` | %{$_.StartTime = $_.StartTime.ToString('o'); return $_;}`
138
+ * this fixes the format of `StartTime` value.
139
+ * note: in Windows, setting the "$env:Lang" environment variable is not effective in changing the format of the output.
140
+ * ` | ConvertTo-Csv -NoTypeInformation`
141
+ * this formats objects to csv strings.
142
+ * currently, it is needed that `command` outputs the results in csv format.
143
+ * this is because white space delimiter is not suitable for Windows, in which empty values are often mixed.
144
+
145
+ **Note:** When using with PowerShell 7 which is previously known as PowerShell Core, you must specify `powershell_command` parameter as `pwsh`. Otherwise, this plugin does not work correctly on PowerShell 7 (pwsh). This is because PowerShell Core and PowerShell 7 use different command name which is `pwsh` not `powershell`.
146
+
93
147
  ## FAQ
94
148
 
95
149
  * I need hostname key in the record.
@@ -3,11 +3,11 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "fluent-plugin-watch-process"
6
- s.version = "0.1.1"
6
+ s.version = "0.2.0"
7
7
  s.authors = ["Kentaro Yoshida"]
8
8
  s.email = ["y.ken.studio@gmail.com"]
9
9
  s.homepage = "https://github.com/y-ken/fluent-plugin-watch-process"
10
- s.summary = %q{Fluentd Input plugin to collect continual process information via ps command. It is useful for cron/barch process monitoring.}
10
+ s.summary = %q{Fluentd Input plugin to collect continual process information via ps command or PowerShell pwsh command for Linux/osx/Windows. It is useful for cron/barch process monitoring.}
11
11
 
12
12
  s.files = `git ls-files`.split("\n")
13
13
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.add_development_dependency "rake"
19
19
  s.add_development_dependency "test-unit", ">= 3.1.0"
20
20
  s.add_development_dependency "appraisal"
21
- s.add_runtime_dependency "fluentd", ">= 0.10.58"
21
+ s.add_runtime_dependency "fluentd", [">= 0.14.0", "< 2"]
22
22
  s.add_runtime_dependency "fluent-mixin-rewrite-tag-name"
23
23
  s.add_runtime_dependency "fluent-mixin-type-converter", ">= 0.1.0"
24
24
  end
@@ -1,99 +1,220 @@
1
- require "fluent/input"
1
+ require 'time'
2
+ require 'csv' if Fluent.windows?
3
+ require "fluent/plugin/input"
2
4
  require 'fluent/mixin/rewrite_tag_name'
3
5
  require 'fluent/mixin/type_converter'
4
6
 
5
- module Fluent
6
- class WatchProcessInput < Fluent::Input
7
- Plugin.register_input('watch_process', self)
7
+ module Fluent::Plugin
8
+ class WatchProcessInput < Fluent::Plugin::Input
9
+ Fluent::Plugin.register_input('watch_process', self)
10
+
11
+ helpers :timer
12
+
13
+ DEFAULT_KEYS = %w(start_time user pid parent_pid cpu_time cpu_percent memory_percent mem_rss mem_size state proc_name command)
14
+ DEFAULT_TYPES = %w(
15
+ pid:integer
16
+ parent_pid:integer
17
+ cpu_percent:float
18
+ memory_percent:float
19
+ mem_rss:integer
20
+ mem_size:integer
21
+ ).join(",")
8
22
 
9
23
  config_param :tag, :string
10
24
  config_param :command, :string, :default => nil
11
- config_param :keys, :string, :default => nil
12
- config_param :interval, :string, :default => '5s'
13
- config_param :lookup_user, :string, :default => nil
25
+ config_param :keys, :array, :default => nil
26
+ config_param :interval, :time, :default => '5s'
27
+ config_param :lookup_user, :array, :default => nil
14
28
  config_param :hostname_command, :string, :default => 'hostname'
15
-
16
- DEFAULT_KEYS = %w(start_time user pid parent_pid cpu_time cpu_percent memory_percent mem_rss mem_size state proc_name command)
17
- DEFAULT_TYPES = "pid:integer,parent_pid:integer,cpu_percent:float,memory_percent:float,mem_rss:integer,mem_size:integer"
29
+ config_param :powershell_command, :enum, list: [:powershell, :pwsh], :default => :powershell
18
30
 
19
31
  include Fluent::HandleTagNameMixin
20
32
  include Fluent::Mixin::RewriteTagName
21
33
  include Fluent::Mixin::TypeConverter
22
- config_set_default :types, DEFAULT_TYPES
23
34
 
24
35
  def initialize
25
36
  super
26
- require 'time'
27
37
  end
28
38
 
29
39
  def configure(conf)
30
40
  super
31
41
 
32
- @command = @command || get_ps_command
33
- @keys = @keys.nil? ? DEFAULT_KEYS : @keys.to_s.gsub(' ', '').split(',')
34
- @lookup_user = @lookup_user.gsub(' ', '').split(',') unless @lookup_user.nil?
35
- @interval = Config.time_value(@interval)
42
+ @windows_watcher = WindowsWatcher.new(@keys, @command, @lookup_user, @powershell_command) if Fluent.windows?
43
+ @keys ||= Fluent.windows? ? @windows_watcher.keys : DEFAULT_KEYS
44
+ @command ||= get_ps_command
45
+ apply_default_types
36
46
  log.info "watch_process: polling start. :tag=>#{@tag} :lookup_user=>#{@lookup_user} :interval=>#{@interval} :command=>#{@command}"
37
47
  end
38
48
 
39
49
  def start
40
- @thread = Thread.new(&method(:run))
50
+ super
51
+ timer_execute(:in_watch_process, @interval, &method(:on_timer))
41
52
  end
42
53
 
43
54
  def shutdown
44
- Thread.kill(@thread)
55
+ super
56
+ end
57
+
58
+ def apply_default_types
59
+ return unless @types.nil?
60
+ @types = Fluent.windows? ? @windows_watcher.default_types : DEFAULT_TYPES
61
+ @type_converters = parse_types_parameter unless @types.nil?
45
62
  end
46
63
 
47
- def run
48
- loop do
49
- io = IO.popen(@command, 'r')
64
+ def on_timer
65
+ io = IO.popen(@command, 'r')
66
+ begin
50
67
  io.gets
51
68
  while result = io.gets
52
- keys_size = @keys.size
53
- if result =~ /(?<lstart>(^\w+\s+\w+\s+\d+\s+\d\d:\d\d:\d\d \d+))/
54
- lstart = Time.parse($~[:lstart])
55
- result = result.sub($~[:lstart], '')
56
- keys_size -= 1
69
+ if Fluent.windows?
70
+ data = @windows_watcher.parse_line(result)
71
+ next unless @windows_watcher.match_look_up_user?(data)
72
+ else
73
+ data = parse_line(result)
74
+ next unless match_look_up_user?(data)
57
75
  end
58
- values = [lstart.to_s, result.chomp.strip.split(/\s+/, keys_size)]
59
- data = Hash[@keys.zip(values.reject(&:empty?).flatten)]
60
- data['elapsed_time'] = (Time.now - Time.parse(data['start_time'])).to_i if data['start_time']
61
- next unless @lookup_user.nil? || @lookup_user.include?(data['user'])
62
76
  emit_tag = tag.dup
63
77
  filter_record(emit_tag, Fluent::Engine.now, data)
64
78
  router.emit(emit_tag, Fluent::Engine.now, data)
65
79
  end
80
+ ensure
66
81
  io.close
67
- sleep @interval
68
82
  end
69
- rescue StandardError => e
70
- log.error "watch_process: error has occured. #{e.message}"
83
+ rescue StandardError => e
84
+ log.error "watch_process: error has occured. #{e.message}"
85
+ end
86
+
87
+ def parse_line(line)
88
+ keys_size = @keys.size
89
+ if line =~ /(?<lstart>(^\w+\s+\w+\s+\d+\s+\d\d:\d\d:\d\d \d+))/
90
+ lstart = Time.parse($~[:lstart])
91
+ line = line.sub($~[:lstart], '')
92
+ keys_size -= 1
93
+ end
94
+ values = [lstart.to_s, line.chomp.strip.split(/\s+/, keys_size)]
95
+ data = Hash[@keys.zip(values.reject(&:empty?).flatten)]
96
+ data['elapsed_time'] = (Time.now - Time.parse(data['start_time'])).to_i if data['start_time']
97
+ data
98
+ end
99
+
100
+ def match_look_up_user?(data)
101
+ return true if @lookup_user.nil?
102
+
103
+ @lookup_user.include?(data['user'])
71
104
  end
72
105
 
73
106
  def get_ps_command
74
- if OS.linux?
75
- "LANG=en_US.UTF-8 && ps -ewwo lstart,user:20,pid,ppid,time,%cpu,%mem,rss,sz,s,comm,cmd"
76
- elsif OS.mac?
107
+ if mac?
77
108
  "LANG=en_US.UTF-8 && ps -ewwo lstart,user,pid,ppid,time,%cpu,%mem,rss,vsz,state,comm,command"
109
+ elsif Fluent.windows?
110
+ @windows_watcher.command
111
+ else
112
+ "LANG=en_US.UTF-8 && ps -ewwo lstart,user:20,pid,ppid,time,%cpu,%mem,rss,sz,s,comm,cmd"
78
113
  end
79
114
  end
80
115
 
81
- module OS
82
- # ref. http://stackoverflow.com/questions/170956/how-can-i-find-which-operating-system-my-ruby-program-is-running-on
83
- def OS.windows?
84
- (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
116
+ def mac?
117
+ (/darwin/ =~ RUBY_PLATFORM) != nil
118
+ end
119
+
120
+ class WindowsWatcher
121
+ # Keys are from the "System.Diagnostics.Process" object properties that can be taken by the "Get-Process" command.
122
+ # You can check the all properties by the "(Get-Process)[0] | Get-Member" command.
123
+ DEFAULT_KEYS = %w(StartTime UserName SessionId Id CPU WorkingSet VirtualMemorySize HandleCount ProcessName)
124
+
125
+ DEFAULT_TYPES = %w(
126
+ SessionId:integer
127
+ Id:integer
128
+ CPU:float
129
+ WorkingSet:integer
130
+ VirtualMemorySize:integer
131
+ HandleCount:integer
132
+ ).join(",")
133
+
134
+ attr_reader :keys
135
+ attr_reader :command
136
+
137
+ def initialize(keys, command, lookup_user, powershell_command)
138
+ @keys = keys || DEFAULT_KEYS
139
+ @powershell_command = powershell_command
140
+ @command = command || default_command
141
+ @lookup_user = lookup_user
85
142
  end
86
143
 
87
- def OS.mac?
88
- (/darwin/ =~ RUBY_PLATFORM) != nil
144
+ def default_types
145
+ DEFAULT_TYPES
89
146
  end
90
147
 
91
- def OS.unix?
92
- !OS.windows?
148
+ def parse_line(line)
149
+ values = line.chomp.strip.parse_csv.map { |e| e ? e : "" }
150
+ data = Hash[@keys.zip(values)]
151
+
152
+ unless data["StartTime"].nil?
153
+ start_time = Time.parse(data['StartTime'])
154
+ data['ElapsedTime'] = (Time.now - start_time).to_i
155
+ data["StartTime"] = start_time.to_s
156
+ end
157
+
158
+ data
159
+ end
160
+
161
+ def match_look_up_user?(data)
162
+ return true if @lookup_user.nil?
163
+
164
+ @lookup_user.include?(data["UserName"])
165
+ end
166
+
167
+ def default_command
168
+ command = [
169
+ command_ps,
170
+ pipe_filtering_normal_ps,
171
+ pipe_select_columns,
172
+ pipe_fixing_locale,
173
+ pipe_formatting_output,
174
+ ].join
175
+ "#{@powershell_command} -command \"#{command}\""
176
+ end
177
+
178
+ def command_ps
179
+ if @keys.include?("UserName")
180
+ # The "IncludeUserName" option is needed to get the username, but this option requires Administrator privilege.
181
+ "Get-Process -IncludeUserName"
182
+ else
183
+ "Get-Process"
184
+ end
185
+ end
186
+
187
+ private
188
+
189
+ def pipe_filtering_normal_ps
190
+ # There are some special processes that don't have some properties, such as the "Idle" process.
191
+ # Normally, these are specific to the system and are not important, so exclude them.
192
+ # Note: The same situation can occur in some processes if there are no Administrator privilege.
193
+ " | ?{$_.StartTime -ne $NULL -and $_.CPU -ne $NULL}"
194
+ end
195
+
196
+ def pipe_select_columns
197
+ if @keys.nil? || @keys.empty?
198
+ raise "The 'keys' parameter is not specified correctly. [keys: #{@keys}]"
199
+ end
200
+
201
+ " | Select-Object -Property #{@keys.join(',')}"
202
+ end
203
+
204
+ def pipe_fixing_locale()
205
+ # In Windows, setting the "$env:Lang" environment variable is not effective in changing the format of the output.
206
+ # You can use "Datetime.ToString" method to change format of datetime values in for-each pipe.
207
+ # Note: About "DateTime.ToString" method: https://docs.microsoft.com/en-us/dotnet/api/system.datetime.tostring
208
+ return "" unless @keys.include?("StartTime")
209
+
210
+ " | %{$_.StartTime = $_.StartTime.ToString('o'); return $_;}"
93
211
  end
94
212
 
95
- def OS.linux?
96
- OS.unix? and not OS.mac?
213
+ def pipe_formatting_output
214
+ # In the "ConvertTo-Csv" command, there are 2 lines of type info and header info at the beginning in the outputs.
215
+ # By the "NoTypeInformation" option, the line of type info is excluded.
216
+ # This enables you to skip the just first line for parsing, like linux or mac.
217
+ " | ConvertTo-Csv -NoTypeInformation"
97
218
  end
98
219
  end
99
220
  end
data/test/helper.rb CHANGED
@@ -12,15 +12,7 @@ require 'test/unit'
12
12
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
13
13
  $LOAD_PATH.unshift(File.dirname(__FILE__))
14
14
  require 'fluent/test'
15
- unless ENV.has_key?('VERBOSE')
16
- nulllogger = Object.new
17
- nulllogger.instance_eval {|obj|
18
- def method_missing(method, *args)
19
- # pass
20
- end
21
- }
22
- $log = nulllogger
23
- end
15
+ require 'fluent/test/driver/input'
24
16
 
25
17
  require 'fluent/plugin/in_watch_process'
26
18
 
@@ -10,7 +10,7 @@ class WatchProcessInputTest < Test::Unit::TestCase
10
10
  ]
11
11
 
12
12
  def create_driver(conf = CONFIG)
13
- Fluent::Test::InputTestDriver.new(Fluent::WatchProcessInput).configure(conf)
13
+ Fluent::Test::Driver::Input.new(Fluent::Plugin::WatchProcessInput).configure(conf)
14
14
  end
15
15
 
16
16
  def test_configure
@@ -23,5 +23,103 @@ class WatchProcessInputTest < Test::Unit::TestCase
23
23
  ]
24
24
  assert_equal 'input.watch_process', d.instance.tag
25
25
  assert_equal ['apache', 'mycron'], d.instance.lookup_user
26
+ assert_equal :powershell, d.instance.powershell_command
27
+ end
28
+
29
+ def test_windows_configure
30
+ omit "Only for UNIX like." unless Fluent.windows?
31
+ d = create_driver %[
32
+ tag input.watch_process
33
+ lookup_user apache, mycron
34
+ powershell_command pwsh
35
+ ]
36
+ assert_equal 'input.watch_process', d.instance.tag
37
+ assert_equal ['apache', 'mycron'], d.instance.lookup_user
38
+ assert_equal :pwsh, d.instance.powershell_command
39
+ end
40
+
41
+ def test_unixlike
42
+ omit "Only for UNIX like." if Fluent.windows?
43
+ whoami = `whoami`
44
+ d = create_driver %[
45
+ tag input.watch_process
46
+ lookup_user #{whoami}
47
+ interval 1s
48
+ ]
49
+ d.run(expect_emits: 1, timeout: 3)
50
+ assert(d.events.size > 1)
51
+ end
52
+
53
+ sub_test_case "Windows" do
54
+ def test_windows_default
55
+ omit "Only for Windows." unless Fluent.windows?
56
+ d = create_driver %[
57
+ tag input.watch_process
58
+ interval 1s
59
+ ]
60
+ default_keys = Fluent::Plugin::WatchProcessInput::WindowsWatcher::DEFAULT_KEYS + ["ElapsedTime"]
61
+
62
+ d.run(expect_records: 1, timeout: 10);
63
+
64
+ assert d.events.size > 0
65
+
66
+ tag, time, record = d.events[0]
67
+
68
+ assert_equal "input.watch_process", tag
69
+ assert time.is_a?(Fluent::EventTime)
70
+ assert_equal default_keys, record.keys
71
+ end
72
+
73
+ def test_windows_customized
74
+ omit "Only for Windows." unless Fluent.windows?
75
+ custom_keys = ["PM", "Id", "UserProcessorTime", "Path"]
76
+ d = create_driver %[
77
+ tag input.watch_process
78
+ interval 1s
79
+ keys #{custom_keys.join(",")}
80
+ types Id:integer
81
+ ]
82
+
83
+ d.run(expect_records: 1, timeout: 10);
84
+
85
+ assert d.events.size > 0
86
+
87
+ tag, time, record = d.events[0]
88
+
89
+ assert_equal "input.watch_process", tag
90
+ assert time.is_a?(Fluent::EventTime)
91
+ assert_equal custom_keys, record.keys
92
+ assert record["PM"].is_a?(String)
93
+ assert record["Id"].is_a?(Integer)
94
+ end
95
+
96
+ def test_windows_lookup
97
+ omit "Only for Windows." unless Fluent.windows?
98
+ d = create_driver %[
99
+ tag input.watch_process
100
+ interval 1s
101
+ ]
102
+ d.run(expect_records: 1, timeout: 10);
103
+
104
+ assert d.events.size > 0
105
+
106
+ tag, time, record = d.events[0]
107
+ lookup_user = record["UserName"]
108
+
109
+ d = create_driver %[
110
+ tag input.watch_process
111
+ interval 1s
112
+ lookup_user #{lookup_user}
113
+ ]
114
+ d.run(expect_records: 1, timeout: 10);
115
+
116
+ assert d.events.size > 0
117
+
118
+ other_user_records = d.events.reject do |tag, time, record|
119
+ lookup_user.include?(record["UserName"])
120
+ end
121
+
122
+ assert other_user_records.size == 0
123
+ end
26
124
  end
27
125
  end
metadata CHANGED
@@ -1,110 +1,103 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-watch-process
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Kentaro Yoshida
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2017-03-30 00:00:00.000000000 Z
11
+ date: 2021-05-30 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: test-unit
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: 3.1.0
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: 3.1.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: appraisal
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: fluentd
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
- version: 0.10.58
61
+ version: 0.14.0
62
+ - - "<"
63
+ - !ruby/object:Gem::Version
64
+ version: '2'
70
65
  type: :runtime
71
66
  prerelease: false
72
67
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
68
  requirements:
75
- - - ! '>='
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: 0.14.0
72
+ - - "<"
76
73
  - !ruby/object:Gem::Version
77
- version: 0.10.58
74
+ version: '2'
78
75
  - !ruby/object:Gem::Dependency
79
76
  name: fluent-mixin-rewrite-tag-name
80
77
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
78
  requirements:
83
- - - ! '>='
79
+ - - ">="
84
80
  - !ruby/object:Gem::Version
85
81
  version: '0'
86
82
  type: :runtime
87
83
  prerelease: false
88
84
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
85
  requirements:
91
- - - ! '>='
86
+ - - ">="
92
87
  - !ruby/object:Gem::Version
93
88
  version: '0'
94
89
  - !ruby/object:Gem::Dependency
95
90
  name: fluent-mixin-type-converter
96
91
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
92
  requirements:
99
- - - ! '>='
93
+ - - ">="
100
94
  - !ruby/object:Gem::Version
101
95
  version: 0.1.0
102
96
  type: :runtime
103
97
  prerelease: false
104
98
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
99
  requirements:
107
- - - ! '>='
100
+ - - ">="
108
101
  - !ruby/object:Gem::Version
109
102
  version: 0.1.0
110
103
  description:
@@ -114,8 +107,8 @@ executables: []
114
107
  extensions: []
115
108
  extra_rdoc_files: []
116
109
  files:
117
- - .gitignore
118
- - .travis.yml
110
+ - ".gitignore"
111
+ - ".travis.yml"
119
112
  - Appraisals
120
113
  - Gemfile
121
114
  - LICENSE.txt
@@ -124,36 +117,34 @@ files:
124
117
  - example1.conf
125
118
  - example2.conf
126
119
  - fluent-plugin-watch-process.gemspec
127
- - gemfiles/fluentd_v0.12.gemfile
128
120
  - gemfiles/fluentd_v0.14.gemfile
129
121
  - lib/fluent/plugin/in_watch_process.rb
130
122
  - test/helper.rb
131
123
  - test/plugin/test_in_watch_process.rb
132
124
  homepage: https://github.com/y-ken/fluent-plugin-watch-process
133
125
  licenses: []
126
+ metadata: {}
134
127
  post_install_message:
135
128
  rdoc_options: []
136
129
  require_paths:
137
130
  - lib
138
131
  required_ruby_version: !ruby/object:Gem::Requirement
139
- none: false
140
132
  requirements:
141
- - - ! '>='
133
+ - - ">="
142
134
  - !ruby/object:Gem::Version
143
135
  version: '0'
144
136
  required_rubygems_version: !ruby/object:Gem::Requirement
145
- none: false
146
137
  requirements:
147
- - - ! '>='
138
+ - - ">="
148
139
  - !ruby/object:Gem::Version
149
140
  version: '0'
150
141
  requirements: []
151
- rubyforge_project:
152
- rubygems_version: 1.8.23
142
+ rubygems_version: 3.1.6
153
143
  signing_key:
154
- specification_version: 3
155
- summary: Fluentd Input plugin to collect continual process information via ps command.
156
- It is useful for cron/barch process monitoring.
144
+ specification_version: 4
145
+ summary: Fluentd Input plugin to collect continual process information via ps command
146
+ or PowerShell pwsh command for Linux/osx/Windows. It is useful for cron/barch process
147
+ monitoring.
157
148
  test_files:
158
149
  - test/helper.rb
159
150
  - test/plugin/test_in_watch_process.rb
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "fluentd", "~> 0.12.0"
6
-
7
- gemspec :path => "../"