fluent-plugin-diskusage 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +69 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/fluent-plugin-diskusage.gemspec +23 -0
- data/lib/fluent/plugin/in_diskusage.rb +48 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 121d4248acae8b738328c4ca979b23bc55c495e8
|
4
|
+
data.tar.gz: bc0548e506c224349f67f6244d52999c762d64d3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 50fa08565e35ae1157b492e3ece4061a81287b52d8e6d84ceb9ecd9c83aa63dd26df7160fd0af5cdc38c62230ebafc3d44e0ec07d4c714e20059cd5ffe99838f
|
7
|
+
data.tar.gz: b8cfe0b4b497a4a8ed8e32cc54e7ec6af3e1d079e69edab2aac2ed1121febc44d9daeb5b9e4ba788f9d0f627c2a52125a3e8fef464a71109aa1ca1ce08bb585f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 TODO: Write your name
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Fluent::Plugin::Diskusage
|
2
|
+
|
3
|
+
Send disk usage per mountpoint as events to FluentD.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
fluent-gem install fluent-plugin-diskusage
|
9
|
+
```
|
10
|
+
or
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
/usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-diskusage
|
14
|
+
```
|
15
|
+
|
16
|
+
### Dependencies
|
17
|
+
This plugin depends on the [sys-filesystem](https://github.com/djberg96/sys-filesystem) ruby gem
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
`refresh_interval` is an optional parameter, by default the plugin will poll every 2 minutes (120 seconds)
|
22
|
+
|
23
|
+
`label` is a custom label that will be included in the event record
|
24
|
+
|
25
|
+
```
|
26
|
+
<source>
|
27
|
+
type diskusage
|
28
|
+
tag <YOUR TAG>
|
29
|
+
mountpoint /
|
30
|
+
label rootfs
|
31
|
+
</source>
|
32
|
+
|
33
|
+
<source>
|
34
|
+
type diskusage
|
35
|
+
tag <YOUR TAG>
|
36
|
+
mountpoint /data
|
37
|
+
label DataFiles
|
38
|
+
refresh_interval 1800
|
39
|
+
</source>
|
40
|
+
```
|
41
|
+
|
42
|
+
### Record Format
|
43
|
+
```
|
44
|
+
"label" => 'rootfs',
|
45
|
+
"total_bytes" => 10737418240
|
46
|
+
"free_bytes" => 6442450944
|
47
|
+
"used_bytes" => 4294967296
|
48
|
+
"used_percent" => 0.4
|
49
|
+
"free_percent" => 0.6
|
50
|
+
```
|
51
|
+
```
|
52
|
+
"label" => 'DataFiles',
|
53
|
+
"total_bytes" => 1099511627775
|
54
|
+
"free_bytes" => 536870912000
|
55
|
+
"used_bytes" => 536870912000
|
56
|
+
"used_percent" => 0.5
|
57
|
+
"free_percent" => 0.5
|
58
|
+
```
|
59
|
+
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jwestbrook/fluent-plugin-diskusage.
|
64
|
+
|
65
|
+
|
66
|
+
## License
|
67
|
+
|
68
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
69
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "fluent/plugin/diskusage"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -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-diskusage"
|
7
|
+
spec.version = '0.0.1'
|
8
|
+
spec.authors = ["Jason Westbrook"]
|
9
|
+
spec.email = ["jwestbrook@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{Disk Usage plugin for FluentD}
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
15
|
+
spec.bindir = "exe"
|
16
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_dependency "fluentd", [">= 0.10.30", "< 2"]
|
20
|
+
spec.add_dependency "sys-filesystem", "~> 1.1.4"
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class Fluent::DiskUsage < Fluent::Input
|
2
|
+
Fluent::Plugin.register_input('diskusage',self)
|
3
|
+
|
4
|
+
config_param :tag, :string
|
5
|
+
config_param :mountpoint, :string
|
6
|
+
config_param :label, :string
|
7
|
+
config_param :refresh_interval, :integer, :default => 120
|
8
|
+
|
9
|
+
def configure(conf)
|
10
|
+
super
|
11
|
+
require 'sys/filesystem'
|
12
|
+
end
|
13
|
+
|
14
|
+
def start
|
15
|
+
super
|
16
|
+
@watcher = Thread.new(&method(:run))
|
17
|
+
end
|
18
|
+
|
19
|
+
def run
|
20
|
+
while true
|
21
|
+
output
|
22
|
+
sleep @refresh_interval
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def output
|
27
|
+
filestats = Sys::Filesystem.stat(@mountpoint)
|
28
|
+
total_bytes = filestats.block_size * filestats.blocks
|
29
|
+
free_bytes = filestats.block_size * filestats.blocks_available
|
30
|
+
used_bytes = total_bytes - free_bytes
|
31
|
+
used_percent = 0
|
32
|
+
free_percent = 0
|
33
|
+
if total_bytes.nonzero?
|
34
|
+
used_percent = used_bytes / total_bytes.to_f
|
35
|
+
free_percent = free_bytes / total_bytes.to_f
|
36
|
+
end
|
37
|
+
record = {"label"=>@label,"total_bytes"=>total_bytes,"free_bytes"=>free_bytes,"used_bytes"=>used_bytes,"used_percent"=>used_percent,"free_percent"=>free_percent}
|
38
|
+
|
39
|
+
time = Fluent::Engine.now
|
40
|
+
router.emit(tag,time,record)
|
41
|
+
end
|
42
|
+
|
43
|
+
def shutdown
|
44
|
+
@watcher.terminate
|
45
|
+
@watcher.join
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-diskusage
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jason Westbrook
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-10 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.30
|
20
|
+
- - <
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.10.30
|
30
|
+
- - <
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: sys-filesystem
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ~>
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 1.1.4
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.1.4
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.10'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ~>
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '1.10'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rake
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '10.0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '10.0'
|
75
|
+
description:
|
76
|
+
email:
|
77
|
+
- jwestbrook@gmail.com
|
78
|
+
executables: []
|
79
|
+
extensions: []
|
80
|
+
extra_rdoc_files: []
|
81
|
+
files:
|
82
|
+
- .gitignore
|
83
|
+
- Gemfile
|
84
|
+
- LICENSE.txt
|
85
|
+
- README.md
|
86
|
+
- Rakefile
|
87
|
+
- bin/console
|
88
|
+
- bin/setup
|
89
|
+
- fluent-plugin-diskusage.gemspec
|
90
|
+
- lib/fluent/plugin/in_diskusage.rb
|
91
|
+
homepage:
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.0.14
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Disk Usage plugin for FluentD
|
115
|
+
test_files: []
|