fluent-plugin-loadaverage 0.0.1

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
+ SHA1:
3
+ metadata.gz: 1d04bf5927f4da9411ef5286aa682cc542f95e11
4
+ data.tar.gz: eacbbe0fe0cbc3bca299cfc1252e7126213a64c7
5
+ SHA512:
6
+ metadata.gz: 69bab63c2a81527a4b86ed2e4be71b6b7e866cad1507c1675772320368b94d6657bfd33f50322ce11da0eb2a26bad1bec5de9bd15f66210c7098598aecec67d1
7
+ data.tar.gz: ea682ae16ef5139bb3bd43fa7deb90979538d2d1a0ca39b7f74b97297ec9be408229423604baa040ffe7c15a0df366b3813f76f4e688ed146b162ef94768fd6b
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-loadaverage.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # fluent-plugin-loadaverage
2
+
3
+ ## Overview
4
+ Fluentd input plugin to collect loadaverage via uptime command.
5
+
6
+ ## Installation
7
+ ```
8
+ $ gem install fluent-plugin-loadaverage
9
+ ```
10
+
11
+ ## Configuration
12
+ ```
13
+ <source>
14
+ type loadaverage
15
+ tag loadaverage
16
+ interval 10
17
+ </source>
18
+ ```
19
+
20
+ ### Parameters
21
+ - tag(Required)
22
+ - record output destination
23
+ - interval
24
+ - execute interval time
25
+ - [default] 60s
26
+
27
+ ## OutputFormat
28
+ ```
29
+ {"past_1min":"0.00","past_5min":"0.01","past_15min":"0.05"}
30
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "fluent-plugin-loadaverage"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["mogulla3"]
9
+ spec.email = ["hs.iarn3@gmail.com"]
10
+
11
+ spec.summary = %q{Fluent input plugin to collect load average via uptime command.}
12
+ spec.description = %q{Fluent input plugin to collect load average via uptime command.}
13
+ spec.homepage = "https://github.com/mogulla3/fluent-plugin-loadaverage"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency "fluentd"
21
+ spec.add_development_dependency "rake"
22
+ end
@@ -0,0 +1,49 @@
1
+ module Fluent
2
+ class LoadAverageInput < Input
3
+ Plugin.register_input("loadaverage", self)
4
+
5
+ config_param :tag, :string
6
+ config_param :interval, :integer, :default => 60
7
+
8
+ class TimerWatcher < Coolio::TimerWatcher
9
+ def initialize(interval, repeat, &callback)
10
+ @callback = callback
11
+ super(interval, repeat)
12
+ end
13
+
14
+ def on_timer
15
+ @callback.call
16
+ end
17
+ end
18
+
19
+ def configure(conf)
20
+ super
21
+ end
22
+
23
+ def start
24
+ @loop = Coolio::Loop.new
25
+ @timer = TimerWatcher.new(@interval, true, &method(:uptime))
26
+ @loop.attach(@timer)
27
+ @thread = Thread.new(&method(:run))
28
+ end
29
+
30
+ def shutdown
31
+ @loop.watchers.each {|w| w.detach }
32
+ @loop.stop
33
+ @thread.join
34
+ end
35
+
36
+ def run
37
+ @loop.run
38
+ rescue
39
+ log.error "unexpected error", :error => $!.to_s
40
+ log.error_backtrace
41
+ end
42
+
43
+ def uptime
44
+ past1_min, past5_min, past15_min =
45
+ `uptime`.chomp.match(/load average(?::|s:) (\d+\.\d+)(?:,|) (\d+\.\d+)(?:,|) (\d+\.\d+)$/).to_a.values_at(1,2,3)
46
+ router.emit(@tag, Engine.now, { past_1min: past1_min, past_5min: past5_min, past_15min: past15_min })
47
+ end
48
+ end
49
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-loadaverage
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - mogulla3
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fluentd
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Fluent input plugin to collect load average via uptime command.
42
+ email:
43
+ - hs.iarn3@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".travis.yml"
50
+ - Gemfile
51
+ - README.md
52
+ - Rakefile
53
+ - fluent-plugin-loadaverage.gemspec
54
+ - lib/fluent/plugin/in_loadaverage.rb
55
+ homepage: https://github.com/mogulla3/fluent-plugin-loadaverage
56
+ licenses: []
57
+ metadata: {}
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.4.5
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Fluent input plugin to collect load average via uptime command.
78
+ test_files: []
79
+ has_rdoc: