fluent-plugin-ceph 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cd6ce55261293eafa8442198ec20477fc9ff3067
4
+ data.tar.gz: 6b1c9d64dc90b9d6b75ac5724df799bd69ab47c5
5
+ SHA512:
6
+ metadata.gz: ec11e13321befb24d98ff1f27d8beadbabd5552c67b99eba6a7a52cccf4969a93037c5c9656ed5a9b9d2ec8f56945f101ece4c99abbca151e4aa44e2776e93c3
7
+ data.tar.gz: f7c9c153d2c481748ce2a42c40e9a9534eda415d2e8685d22fcb991c878ab2a95eee051c374c3b4183ab3f655ebe22bf58716a4a332c174cb5b2b9dc305ed56c
data/AUTHORS ADDED
@@ -0,0 +1 @@
1
+ Avinash Jha <avinash.jha2493@gmail.com>
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2016 Avinash Jha
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.
@@ -0,0 +1,36 @@
1
+ Ceph plugin for [Fluentd](http://fluentd.org)
2
+
3
+ ## What's Ceph?
4
+ Ceph is a distributed object store and file system designed to provide excellent performance, reliability and scalability.
5
+
6
+ ## Installation
7
+ (1) gem build fluent-plugin-ceph.gemspec
8
+ (2) sudo /usr/sbin/td-agent-gem install fluent-plugin-ceph-0.1.0.gem
9
+ (3) Restart td-agent service.
10
+
11
+ ## Configuration
12
+
13
+ <source>
14
+ @type ceph
15
+ tag ceph
16
+ arguments health, osd tree, osd stat
17
+ granularity 5
18
+ </source>
19
+
20
+ ## Output Format
21
+ For health argument, output will look like this:
22
+
23
+ {"health":{"health_services":[{"mons":[{"name":"ceph-02","kb_total":37024320,"kb_used":12097884,"kb_avail":23022668,"avail_percent":62,"last_updated":"2016-07-26 12:32:08.862700","store_stats":{"bytes_total":20814955,"bytes_sst":0,"bytes_log":2285109,"bytes_misc":18529846,"last_updated":"0.000000"},"health":"HEALTH_OK"}]}]},"timechecks":{"epoch":5,"round":0,"round_status":"finished"},"summary":[{"severity":"HEALTH_ERR","summary":"308 pgs are stuck inactive for more than 300 seconds"},{"severity":"HEALTH_WARN","summary":"308 pgs stale"},{"severity":"HEALTH_WARN","summary":"308 pgs stuck stale"}],"overall_status":"HEALTH_ERR","detail":[]}
24
+
25
+ With multiple arguments, every argument will have a response in the above JSON with key as the argument name.
26
+ ## Supported options
27
+
28
+ ```
29
+ All options supported in ceph commands
30
+ ```
31
+
32
+ ## Copyright
33
+
34
+ Copyright (c) 2016 Avinash Jha. See LICENSE.txt for
35
+ further details.
36
+
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,28 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "fluent-plugin-ceph"
3
+ s.version = "0.1.0"
4
+ s.licenses = ['Apache-2.0']
5
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
+ s.require_paths = ["lib"]
7
+ s.authors = ["Avinash Jha"]
8
+ s.date = "2016-07-26"
9
+ s.email = "avinash.jha2493@gmail.com"
10
+ s.extra_rdoc_files = [
11
+ "LICENSE.txt",
12
+ "README.md"
13
+ ]
14
+ s.files = [
15
+ "AUTHORS",
16
+ "Gemfile",
17
+ "LICENSE.txt",
18
+ "README.md",
19
+ "Rakefile",
20
+ "VERSION",
21
+ "fluent-plugin-ceph.gemspec",
22
+ "lib/fluent/plugin/in_ceph.rb"
23
+ ]
24
+ s.homepage = "http://github.com/aavinashjha/fluent-plugin-ceph"
25
+ s.rubygems_version = "2.4.5"
26
+ s.summary = "Ceph Input plugin for Fluent event collector"
27
+ end
28
+
@@ -0,0 +1,101 @@
1
+ require 'fluent/mixin/rewrite_tag_name'
2
+ require 'json'
3
+ require 'date'
4
+
5
+ module Fluent
6
+ class CephInput < Input
7
+
8
+ Plugin.register_input('ceph', self)
9
+
10
+ def initialize
11
+ super
12
+ end
13
+
14
+ config_param :tag, :string
15
+ config_param :ceph_path, :string, :default => "ceph"
16
+ config_param :arguments, :string, :default => "health"
17
+ config_param :granularity, :integer, :default => 1
18
+ config_param :hostname_command, :string, :default => "hostname"
19
+
20
+ include Fluent::Mixin::RewriteTagName
21
+
22
+ def configure(conf)
23
+ super
24
+ @commands = Hash.new
25
+ if @arguments.include? ","
26
+ @arguments.split(",").each do |argument|
27
+ @commands[argument.strip] = "#{@ceph_path} #{argument.strip} --format json"
28
+ end
29
+ else
30
+ @commands[@arguments.strip] = "#{@ceph_path} #{@arguments.strip} --format json"
31
+ end
32
+ @hostname = `#{@hostname_command}`.chomp!
33
+ end
34
+
35
+ def emit_message
36
+ @output = Hash.new
37
+ @pids = Array.new
38
+ @commands.each do |argument, command|
39
+ io = IO.popen(command, "r")
40
+ pid = io.pid
41
+ json = io.read.strip
42
+ @output[argument] = json && json.length >= 2 ? JSON.parse(json) : nil
43
+ Process.detach(pid)
44
+ Process.kill(:TERM, pid)
45
+ @pids.push pid
46
+ end
47
+ @output['eventtime'] = DateTime.parse(Time.now.to_s).strftime("%d/%m/%Y %H:%M:%S")
48
+ router.emit(@tag.dup, Engine.now, @output)
49
+ end
50
+
51
+ def start
52
+ @loop = Coolio::Loop.new
53
+ @tw = TimerWatcher.new(@granularity, true, &method(:emit_message))
54
+ @tw.attach(@loop)
55
+ @thread = Thread.new(&method(:run))
56
+ end
57
+
58
+ def shutdown
59
+ @pids.each { |pid|
60
+ Process.detach(pid)
61
+ Process.kill(:TERM, pid)
62
+ }
63
+ @tw.detach
64
+ @loop.stop
65
+ @thread.join
66
+ end
67
+
68
+ def run
69
+ begin
70
+ @loop.run
71
+ rescue
72
+ $log.error "unexpected error", :error=>$!.to_s
73
+ $log.error_backtrace
74
+ end
75
+ end
76
+
77
+ def restart
78
+ @pids.each { |pid|
79
+ Process.detach(@pid)
80
+ Process.kill(:TERM, @pid)
81
+ }
82
+ @tw.detach
83
+ @tw = TimerWatcher.new(@delay, true, &method(:emit_message))
84
+ @tw.attach(@loop)
85
+ end
86
+
87
+ class TimerWatcher < Coolio::TimerWatcher
88
+ def initialize(interval, repeat, &method)
89
+ @emit_message = method
90
+ super(interval, repeat)
91
+ end
92
+
93
+ def on_timer
94
+ @emit_message.call
95
+ rescue
96
+ $log.error $!.to_s
97
+ $log.error_backtrace
98
+ end
99
+ end
100
+ end
101
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-ceph
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Avinash Jha
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-07-26 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: avinash.jha2493@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files:
18
+ - LICENSE.txt
19
+ - README.md
20
+ files:
21
+ - AUTHORS
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - VERSION
27
+ - fluent-plugin-ceph.gemspec
28
+ - lib/fluent/plugin/in_ceph.rb
29
+ homepage: http://github.com/aavinashjha/fluent-plugin-ceph
30
+ licenses:
31
+ - Apache-2.0
32
+ metadata: {}
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 2.5.1
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: Ceph Input plugin for Fluent event collector
53
+ test_files: []