fluent-plugin-sadf 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: 21809ec9dde43b541c62ab1027b13c13f267852e
4
+ data.tar.gz: 90c017dced717ca77c9f35c74c03fae4eee8918b
5
+ SHA512:
6
+ metadata.gz: 47b5a768bb9706524a0c4451e05bbfc89c7b0e511cabf30d0e144197951c3fce4fd9bc2c1eef1dc5f0fd4cfefea1c585752420191ffdbe5fd0b83a6993ee06be
7
+ data.tar.gz: 4ec9d9cd2ef03df54400f9bf55637282123de9fabbf974feb18e0b90a46b8765e5e2207791b3f5187cf6a03bb2a499f5f4445b9121bf5cbd5973b9fb021bacd1
data/.gitignore ADDED
@@ -0,0 +1,19 @@
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
+ *.swp
19
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 hirotaka tajiri
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Fluent::Plugin::Sadf, a plugin for [Fluentd](http://fluentd.org)
2
+
3
+ fluentd plugin for collecting sysstat using sadf.
4
+
5
+ This plugin needs "sysstat".
6
+
7
+ ## Installation
8
+
9
+ $ gem install fluent-plugin-sadf
10
+
11
+ ## Configuration
12
+ ### Parameters:
13
+
14
+ TBD
15
+
16
+ ### Example:
17
+
18
+ <source>
19
+ type sadf
20
+ sar_option -A
21
+ tag sadf.tag
22
+ interval 10
23
+ hostname_output true
24
+ hostname check_host01
25
+ </source>
26
+
27
+ output
28
+
29
+ sadf.tag: {"hostname":"note","args":"-A","all":{"%usr":"26.14","%nice":"0.00","%sys":"7.95","%iowait":"1.96","%steal":"0.00","%irq":"0.00","%soft":"0.00","%guest":"0.00","%gnice":"0.00","%idle":"63.94"},"cpu0":{"%usr":"21.40","%nice":"0.00","%sys":"8.73","%iowait":"3.93","%steal":"0.00","%irq":"0.00","%soft":"0.00","%guest":"0.00","%gnice":"0.00","%idle":"65.94"},"cpu1":{"%usr":"35.81","%nice":"0.00","%sys":"9.61","%iowait":"2.18","%steal":"0.00","%irq":"0.00","%soft":"0.00","%guest":"0.00","%gnice":"0.00","%idle":"52.40"},"cpu2":{"%usr":"21.40","%nice":"0.00","%sys":"6.55","%iowait":"1.75","%steal":"0.00","%irq":"0.00","%soft":"0.00","%guest":"0.00","%gnice":"0.00","%idle":"70.31"},"cpu3":{"%usr":"25.97","%nice":"0.00","%sys":"6.93","%iowait":"0.00","%steal":"0.00","%irq":"0.00","%soft":"0.00","%guest":"0.00","%gnice":"0.00","%idle":"67.10"}}
30
+
31
+ ## Copyright
32
+
33
+ Copyright (c) 2016 Yuji Hagiwara. See [LICENSE](LICENSE.txt) for details.
34
+
35
+ This software is based on fluent-plugin-sar (https://github.com/hirotaka-tajiri/fluent-plugin-sar) written by Hirotaka Tajiri, licensed by MIT License.
36
+
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ i# encoding: utf-8
2
+ require "bundler/gem_tasks"
3
+
4
+ require 'rspec/core'
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new(:spec) {| spec |
7
+ spec.pattern = FileList['spec/*_spec.rb']
8
+ }
9
+ task :default => :spec
10
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ #lib = File.expand_path('../lib', __FILE__)
3
+ #$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ $:.push File.expand_path('../lib', __FILE__)
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fluent-plugin-sadf"
8
+ spec.description = %q{fluentd plugin for collecting sysstat using sadf}
9
+ spec.homepage = "https://github.com/yuuzi41/fluent-plugin-sadf"
10
+ spec.summary = spec.description
11
+ spec.version = File.read("VERSION").strip
12
+ spec.authors = ["yuuzi41"]
13
+ spec.email = ""
14
+ spec.license = "MIT"
15
+ spec.has_rdoc = false
16
+
17
+ spec.files = `git ls-files`.split("\n")
18
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{| f | File.basename(f)}
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'fluentd', "~> 0.10"
23
+ spec.add_development_dependency "rake", ">0"
24
+ spec.add_development_dependency "rspec", ">0"
25
+ end
@@ -0,0 +1,54 @@
1
+ class SadfInput < Fluent::Input
2
+ Fluent::Plugin.register_input('sadf', self)
3
+
4
+ config_param :sar_option, :string, default: ''
5
+ config_param :tag, :string, default: 'sadf_result.tag'
6
+ config_param :interval, :integer, default: 5
7
+ config_param :hostname_output, :bool, default: true
8
+ config_param :hostname, :string, default: Socket.gethostname
9
+
10
+ def configure(conf)
11
+ super
12
+ @interval_m = @sar_option.split.size.zero? ? @interval * 60 : @interval * 60 - 1
13
+ begin
14
+ `sar -V`
15
+ rescue
16
+ raise Fluent::ConfigError, "sar(sysstat) is not installed."
17
+ end
18
+ end
19
+
20
+ def start
21
+ super
22
+ @thread = Thread.new(&method(:run))
23
+ end
24
+
25
+ def shutdown
26
+ @thread.kill
27
+ end
28
+
29
+ private
30
+
31
+ def run
32
+ loop do
33
+ @result = Hash.new
34
+ @result["hostname"] = @hostname if @hostname_output
35
+ @result["args"] = @sar_option
36
+ Fluent::Engine.emit(@tag, Fluent::Engine.now, @result.merge(sadf_execute(@sar_option)))
37
+ sleep @interval_m
38
+ end
39
+ end
40
+
41
+ def sadf_execute(opt)
42
+ rec = Hash.new
43
+
44
+ `LANG=C sadf -- #{opt} 1 1`.split("\n").each {| line |
45
+ array = line.split("\t")
46
+ if !rec.has_key?(array[3]) then
47
+ rec[array[3]] = Hash.new
48
+ end
49
+ rec[array[3]][array[4]] = array[5]
50
+ }
51
+
52
+ rec
53
+ end
54
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-sadf
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - yuuzi41
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-19 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.10'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.10'
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: fluentd plugin for collecting sysstat using sadf
56
+ email: ''
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - ".gitignore"
62
+ - Gemfile
63
+ - LICENSE.txt
64
+ - README.md
65
+ - Rakefile
66
+ - VERSION
67
+ - fluent-plugin-sadf.gemspec
68
+ - lib/fluent/plugin/in_sadf.rb
69
+ homepage: https://github.com/yuuzi41/fluent-plugin-sadf
70
+ licenses:
71
+ - MIT
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 2.4.8
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: fluentd plugin for collecting sysstat using sadf
93
+ test_files: []