fluent-plugin-snmp 0.0.6 → 0.0.7
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.
- data/README.md +26 -32
- data/fluent-plugin-snmp.gemspec +3 -3
- data/lib/fluent/plugin/in_snmp.rb +26 -14
- data/sample/snmp.conf.sample +19 -36
- data/test/plugin/test_in_snmp.rb +4 -2
- metadata +4 -4
data/README.md
CHANGED
@@ -14,38 +14,32 @@ Or install it yourself as:
|
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
|
-
<source>
|
18
|
-
type snmp
|
19
|
-
tag snmp.server1
|
20
|
-
nodes name, value
|
21
|
-
host
|
22
|
-
community
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
</source>
|
44
|
-
|
45
|
-
|
46
|
-
2012-11-08 16:07:40 +0900 snmp.server1: {"name":"HOST-RESOURCES-MIB::hrStorageUsed.31","value":"2352425"}
|
47
|
-
2012-11-08 16:07:45 +0900 snmp.server2: {"value":"[name=HOST-RESOURCES-MIB::hrStorageIndex.7, value=7 (INTEGER)]"}
|
48
|
-
|
17
|
+
<source>
|
18
|
+
type snmp
|
19
|
+
tag snmp.server1
|
20
|
+
nodes name, value
|
21
|
+
host localhost
|
22
|
+
community public
|
23
|
+
mib sysContact.0, sysDescr.0, sysName.0
|
24
|
+
method_type get
|
25
|
+
polling_time 5
|
26
|
+
polling_type async_run
|
27
|
+
</source>
|
28
|
+
|
29
|
+
<source>
|
30
|
+
type snmp
|
31
|
+
tag snmp.server2
|
32
|
+
host localhost
|
33
|
+
community public
|
34
|
+
mib hrStorageIndex, hrStorageDescr, hrStorageSize, hrStorageUsed
|
35
|
+
mib_modules HOST-RESOURCES-MIB
|
36
|
+
polling_time 0,10,20,30,40,50
|
37
|
+
out_executor sample/out_exec.rb.sample
|
38
|
+
</source>
|
39
|
+
|
40
|
+
<match snmp.server*>
|
41
|
+
type stdout
|
42
|
+
</match>
|
49
43
|
|
50
44
|
## Copyright
|
51
45
|
Copyright (c) 2012 Internet Initiative Inc.
|
data/fluent-plugin-snmp.gemspec
CHANGED
@@ -3,11 +3,11 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = "fluent-plugin-snmp"
|
6
|
-
gem.version = "0.0.
|
6
|
+
gem.version = "0.0.7"
|
7
7
|
gem.authors = ["hiro-su"]
|
8
8
|
gem.email = ["h-sugimoto@iij.ad.jp"]
|
9
|
-
gem.description = %q{Input plugin to
|
10
|
-
gem.summary = %q{Input plugin to
|
9
|
+
gem.description = %q{Input plugin to snmp}
|
10
|
+
gem.summary = %q{Input plugin to snmp}
|
11
11
|
|
12
12
|
gem.files = `git ls-files`.split($\)
|
13
13
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -11,11 +11,13 @@ module Fluent
|
|
11
11
|
config_param :mib, :string
|
12
12
|
config_param :nodes, :string, :default => nil
|
13
13
|
config_param :polling_time, :string, :default => nil
|
14
|
+
config_param :polling_offset, :time, :default => 0
|
15
|
+
config_param :polling_type, :string, :default => "run" #or async_run
|
14
16
|
config_param :host_name, :string, :default => nil
|
15
17
|
config_param :retry, :integer, :default => 5
|
16
18
|
config_param :retry_interval, :time, :default => 1
|
17
|
-
config_param :method_type, :string, :default => "walk"
|
18
|
-
config_param :
|
19
|
+
config_param :method_type, :string, :default => "walk" #or get
|
20
|
+
config_param :out_executor, :string, :default => nil
|
19
21
|
|
20
22
|
# SNMP Lib Params
|
21
23
|
# require param: host, community
|
@@ -52,7 +54,8 @@ module Fluent
|
|
52
54
|
def configure(conf)
|
53
55
|
super
|
54
56
|
|
55
|
-
raise ConfigError, "tag is required param" if @tag.empty?
|
57
|
+
raise ConfigError, "snmp: 'tag' is required param" if @tag.empty?
|
58
|
+
raise ConfigError, "snmp: 'polling_type' parameter is required on snmp input" if @polling_type.empty?
|
56
59
|
|
57
60
|
# @mib, @mib_modules, @nodesを配列に変換
|
58
61
|
@mib = @mib.split(',').map{|str| str.strip}
|
@@ -87,9 +90,10 @@ module Fluent
|
|
87
90
|
:use_IPv6 => @use_IPv6
|
88
91
|
}
|
89
92
|
|
90
|
-
unless @
|
93
|
+
unless @out_executor.nil?
|
94
|
+
$log.info "load snmp out executor #{out_executor}"
|
91
95
|
@out_exec = lambda do |manager|
|
92
|
-
|
96
|
+
load @out_executor
|
93
97
|
opts = {
|
94
98
|
:tag => @tag,
|
95
99
|
:mib => @mib,
|
@@ -117,7 +121,8 @@ module Fluent
|
|
117
121
|
end
|
118
122
|
|
119
123
|
def run
|
120
|
-
Polling
|
124
|
+
Polling.setting offset: @polling_offset
|
125
|
+
Polling.__send__(@polling_type, @polling_time) do
|
121
126
|
break if @end_flag
|
122
127
|
exec_params = {
|
123
128
|
manager: @manager,
|
@@ -137,16 +142,25 @@ module Fluent
|
|
137
142
|
|
138
143
|
def shutdown
|
139
144
|
@end_flag = true
|
140
|
-
@thread
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
+
if @thread
|
146
|
+
@thread.run
|
147
|
+
@thread.join
|
148
|
+
@thread = nil
|
149
|
+
end
|
150
|
+
if @starter
|
151
|
+
@starter.join
|
152
|
+
@starter = nil
|
153
|
+
end
|
154
|
+
if @manager
|
155
|
+
@manager.close
|
156
|
+
end
|
145
157
|
end
|
146
158
|
|
159
|
+
private
|
160
|
+
|
147
161
|
def exec_snmp opts={}
|
148
162
|
@retry_count ||= 0
|
149
|
-
if @
|
163
|
+
if @out_executor.nil?
|
150
164
|
case opts[:method_type]
|
151
165
|
when /^walk$/
|
152
166
|
snmp_walk(opts[:manager], opts[:mib], opts[:nodes])
|
@@ -174,8 +188,6 @@ module Fluent
|
|
174
188
|
raise ex
|
175
189
|
end
|
176
190
|
|
177
|
-
private
|
178
|
-
|
179
191
|
def snmp_walk(manager, mib, nodes, test=false)
|
180
192
|
manager.walk(mib) do |row|
|
181
193
|
time = Engine.now
|
data/sample/snmp.conf.sample
CHANGED
@@ -1,42 +1,25 @@
|
|
1
1
|
<source>
|
2
|
-
type snmp
|
3
|
-
tag snmp.server1
|
4
|
-
nodes name, value
|
5
|
-
host localhost
|
6
|
-
community public
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
timeout 3s
|
12
|
-
polling_time 0,10,20,30,40,50
|
2
|
+
type snmp
|
3
|
+
tag snmp.server1
|
4
|
+
nodes name, value
|
5
|
+
host localhost
|
6
|
+
community public
|
7
|
+
mib sysContact.0, sysDescr.0, sysName.0
|
8
|
+
method_type get
|
9
|
+
polling_time 5
|
10
|
+
polling_type async_run
|
13
11
|
</source>
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
#polling_time 5,15,25,35,45,55
|
26
|
-
#</source>
|
27
|
-
#
|
28
|
-
#<source>
|
29
|
-
#type snmp
|
30
|
-
#tag snmp.server3
|
31
|
-
#host localhost
|
32
|
-
#community public
|
33
|
-
#version 2c
|
34
|
-
#mib hrStorageIndex, hrStorageDescr, hrStorageSize, hrStorageUsed
|
35
|
-
#mib_modules HOST-RESOURCES-MIB
|
36
|
-
#retries 0
|
37
|
-
#timeout 3s
|
38
|
-
#polling_time 5m
|
39
|
-
#</source>
|
13
|
+
<source>
|
14
|
+
type snmp
|
15
|
+
tag snmp.server2
|
16
|
+
host localhost
|
17
|
+
community public
|
18
|
+
mib hrStorageIndex, hrStorageDescr, hrStorageSize, hrStorageUsed
|
19
|
+
mib_modules HOST-RESOURCES-MIB
|
20
|
+
polling_time 0,10,20,30,40,50
|
21
|
+
out_executor sample/out_exec.rb.sample
|
22
|
+
</source>
|
40
23
|
|
41
24
|
<match snmp.server*>
|
42
25
|
type stdout
|
data/test/plugin/test_in_snmp.rb
CHANGED
@@ -14,6 +14,7 @@ class SnmpInputTest < Test::Unit::TestCase
|
|
14
14
|
mib hrStorageIndex, hrStorageDescr, hrStorageSize, hrStorageUsed
|
15
15
|
nodes name, value
|
16
16
|
polling_time 0,10,20,30,40,50
|
17
|
+
polling_offset 0
|
17
18
|
host localhost
|
18
19
|
host_name test_host
|
19
20
|
community public
|
@@ -22,7 +23,7 @@ class SnmpInputTest < Test::Unit::TestCase
|
|
22
23
|
retry_interval 2
|
23
24
|
timeout 3s
|
24
25
|
method_type walk
|
25
|
-
|
26
|
+
out_executor sample/out_exec.rb.sample
|
26
27
|
]
|
27
28
|
|
28
29
|
def create_driver(conf=CONFIG)
|
@@ -37,9 +38,10 @@ class SnmpInputTest < Test::Unit::TestCase
|
|
37
38
|
assert_equal ["hrStorageIndex","hrStorageDescr","hrStorageSize","hrStorageUsed"], d.instance.mib
|
38
39
|
assert_equal ["name","value"], d.instance.nodes
|
39
40
|
assert_equal ["0","10","20","30","40","50"], d.instance.polling_time
|
41
|
+
assert_equal 0, d.instance.polling_offset
|
40
42
|
assert_equal "walk", d.instance.method_type
|
41
43
|
assert_equal 2, d.instance.retry_interval
|
42
|
-
assert_equal "sample/out_exec.rb", d.instance.
|
44
|
+
assert_equal "sample/out_exec.rb.sample", d.instance.out_executor
|
43
45
|
|
44
46
|
# SNMP Lib Params
|
45
47
|
assert_equal "localhost", d.instance.host
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-snmp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
@@ -107,7 +107,7 @@ dependencies:
|
|
107
107
|
- - ! '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
|
-
description: Input plugin to
|
110
|
+
description: Input plugin to snmp
|
111
111
|
email:
|
112
112
|
- h-sugimoto@iij.ad.jp
|
113
113
|
executables: []
|
@@ -148,7 +148,7 @@ rubyforge_project:
|
|
148
148
|
rubygems_version: 1.8.24
|
149
149
|
signing_key:
|
150
150
|
specification_version: 3
|
151
|
-
summary: Input plugin to
|
151
|
+
summary: Input plugin to snmp
|
152
152
|
test_files:
|
153
153
|
- test/helper.rb
|
154
154
|
- test/plugin/test_in_snmp.rb
|