fluent-plugin-free 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5b909239529629b4037e118d68946d5839fac63c
4
+ data.tar.gz: 691e97dd9f7334ff94b7864fd6f606641ed9fbd2
5
+ SHA512:
6
+ metadata.gz: e066da14e03f733923cb4b63014c1b02914e12ad8fd542f8b519c3a4a8a0d8a12cd5034fb79b0f6f9f2a160e283f42b6e97c5b8aec00fcc303cbe0d546977b2e
7
+ data.tar.gz: bf2e6dc858e381eeabebcfcca240c58604710f8da3bf79ce27f5fe19036aa0b954e168a0fe6b4a4b3ab836ecbc806b5fd63d970150f5cc485f118c38fdba7885
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-free.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2014 TATEZONO Masaki
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,79 @@
1
+ fluent-plugin-free
2
+ ==================
3
+
4
+ Input plugin for fluentd to collect memory usage from 'free' command.
5
+
6
+ 'free' command shows system memory usage. This plugin collect values from the command , and input is into fluentd.
7
+
8
+
9
+ Installation
10
+ ------------
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'fluent-plugin-free'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install fluent-plugin-free
23
+
24
+
25
+ Sample Configration
26
+ -------------------
27
+
28
+ To get memory usage in MegaByte :
29
+
30
+ <source>
31
+ type free
32
+ unit mega # size unit, 'byte', 'kilo', 'mega', 'giga'
33
+ mode actual # 'actual' mode incldue 'buffers' and 'cache' in 'free' size.
34
+ interval 5 # seconds, you can also use 10s, 20m, 10h
35
+ tag memory.free
36
+ </source>
37
+
38
+ And you will get like this :
39
+
40
+ 2014-06-28T10:46:04+09:00 memory.free {"used":"1553","free":"441"}
41
+ 2014-06-28T10:46:09+09:00 memory.free {"used":"1553","free":"441"}
42
+
43
+
44
+
45
+ Parameters
46
+ ----------
47
+
48
+ * unit
49
+
50
+ The unit of memory usage value. You can choose one of 'byte', 'kilo', 'mega' or 'giga'. Default is 'mega'
51
+
52
+ * mode
53
+
54
+ If you specify 'actual' in the option,the value you get includes 'buffers' and 'cached'.The value in 'mode actual' shows the memory size you can really use.Default is nil.
55
+
56
+ * interval
57
+
58
+ The interval time to collect value. Numerical number means seconds, and you can also use 's':seconds, 'm':minutes or 'h':hours. Default is 10 (seconds).
59
+
60
+ * tag
61
+
62
+ The input tag. Default is 'memory.free'
63
+
64
+
65
+ Contributing
66
+ ------------
67
+
68
+ 1. Fork it ( https://github.com/zonomasa/fluent-plugin-free/fork )
69
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
70
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
71
+ 4. Push to the branch (`git push origin my-new-feature`)
72
+ 5. Create a new Pull Request
73
+
74
+
75
+ Copyright
76
+ ---------
77
+ Author:: TATEZONO Masaki
78
+ Copyright:: Copyright (c) 2014 TATEZONO Masaki
79
+ License:: Apache License, Version 2.0
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new(:test) do |test|
5
+ test.libs << 'lib' << 'test'
6
+ test.pattern = 'test/**/test_*.rb'
7
+ test.verbose = true
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,23 @@
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-free"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["TATEZONO Masaki"]
9
+ spec.email = ["tatezono@gmail.com"]
10
+ spec.summary = %q{Input plugin for fluentd to collect memory usage from free command.}
11
+ spec.description = %q{Input plugin for fluentd to collect memory usage from free command.}
12
+ spec.homepage = "https://github.com/zonomasa/fluent-plugin-free"
13
+ spec.license = "APLv2"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.6"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_runtime_dependency "fluentd"
23
+ end
@@ -0,0 +1,63 @@
1
+ class Fluent::FreeInput < Fluent::Input
2
+ Fluent::Plugin.register_input('free', self)
3
+
4
+ config_param :interval, :time, :default => nil
5
+ config_param :option, :string, :default => nil
6
+ config_param :unit, :string, :default => 'mega'
7
+ config_param :mode, :string, :default => nil
8
+ config_param :tag, :string, :default => 'memory.free'
9
+
10
+ def configure(conf)
11
+ super
12
+ if @interval
13
+ @tick = interval.to_i
14
+ else
15
+ @tick = 10
16
+ end
17
+
18
+ @option = case @unit
19
+ when 'byte' then '-b'
20
+ when 'kilo' then '-k'
21
+ when 'mega' then '-m'
22
+ when 'giga' then '-g'
23
+ else
24
+ raise RuntimeError, "@unit must be one of byte/kilo/mega/giga"
25
+ end
26
+ end
27
+
28
+ def start
29
+ super
30
+ @thread = Thread.new(&method(:run))
31
+ end
32
+
33
+ def shutdown
34
+ @thread.terminate
35
+ @thread.join
36
+ end
37
+
38
+ def run
39
+ loop do
40
+ Fluent::Engine.emit(@tag, Fluent::Engine.now, get_free_info)
41
+ sleep @tick
42
+ end
43
+ end
44
+
45
+ private
46
+ def get_free_info
47
+ ret = `free #{@option}`.split($/)
48
+ ret.shift
49
+ if @mode == 'actual'
50
+ items = ret[1].split(/\s+/)
51
+ else
52
+ items = ret[0].split(/\s+/)
53
+ end
54
+ free_info = {
55
+ 'used' => items[2],
56
+ 'free' => items[3],
57
+ }
58
+ free_info
59
+ end
60
+
61
+
62
+
63
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+
12
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
13
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
14
+ require 'fluent/test'
15
+ require 'fluent/plugin/in_free'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,25 @@
1
+ require 'helper'
2
+
3
+ class FreeInputTest < Test::Unit::TestCase
4
+ def setup
5
+ Fluent::Test.setup
6
+ end
7
+
8
+ CONFIG = %[
9
+ interval 10
10
+ ]
11
+
12
+
13
+ def create_driver(conf = CONFIG)
14
+ Fluent::Test::InputTestDriver.new(Fluent::FreeInput).configure(conf)
15
+ end
16
+
17
+
18
+ def test_configure
19
+ d = create_driver
20
+
21
+
22
+
23
+ end
24
+
25
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-free
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - TATEZONO Masaki
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
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
+ - !ruby/object:Gem::Dependency
42
+ name: fluentd
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Input plugin for fluentd to collect memory usage from free command.
56
+ email:
57
+ - tatezono@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - fluent-plugin-free.gemspec
68
+ - lib/fluent/plugin/in_free.rb
69
+ - test/helper.rb
70
+ - test/pulugin/test_in_free.rb
71
+ homepage: https://github.com/zonomasa/fluent-plugin-free
72
+ licenses:
73
+ - APLv2
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.2.2
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Input plugin for fluentd to collect memory usage from free command.
95
+ test_files:
96
+ - test/helper.rb
97
+ - test/pulugin/test_in_free.rb