gri 10.0.8 → 10.0.9
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 +4 -4
- data/lib/fluent/plugin/out_gri.rb +36 -0
- data/lib/gri/builtindefs.rb +14 -4
- data/lib/gri/collector.rb +27 -9
- data/lib/gri/main.rb +2 -0
- data/lib/gri/page.rb +31 -9
- data/lib/gri/pcollector.rb +1 -1
- data/lib/gri/scheduler.rb +2 -0
- data/lib/gri/version.rb +1 -1
- data/test/test_collector.rb +1 -1
- data/test/test_docker_collector.rb +2 -1
- data/test/test_format_helper.rb +6 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0085633d9b1b963f804f959a9c2a17cc2b7d76f
|
4
|
+
data.tar.gz: cee9da876f1ab710bc5554230fa0c58e742d0979
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b16f01fbde9f66c4f144b7dd1e0ad4437393d3db9657c882166b83ed3de47549a62094b34b1dbd5ae0307571c614b354441aeea072c21d40028935ddcf4be0c
|
7
|
+
data.tar.gz: d0134819ae4af120a405b8e6f2a930977fc13d3d77ed760c436c3a5800d415ed7e1a3fe1df819f3918527f15514275d5f7f25ff347407fbd40a27c007d03d92f
|
@@ -58,4 +58,40 @@ class GriOutput < BufferedOutput
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
class TraOutput < BufferedOutput
|
62
|
+
Plugin.register_output('tra', self)
|
63
|
+
|
64
|
+
config_param :config_path, :string, :default=>'/usr/local/gri/gri.conf'
|
65
|
+
config_param :tra_dir, :string, :default=>nil
|
66
|
+
config_param :log_level, :string, :default=>nil
|
67
|
+
config_param :interval, :integer, :default=>nil
|
68
|
+
|
69
|
+
def start
|
70
|
+
super
|
71
|
+
if @log_level
|
72
|
+
::Log.init '/tmp/out_tra.log', :log_level=>@log_level
|
73
|
+
end
|
74
|
+
GRI::Config.init @config_path
|
75
|
+
root_dir = GRI::Config['root-dir'] ||= GRI::Config::ROOT_PATH
|
76
|
+
plugin_dirs = GRI::Config.getvar('plugin-dir') || [root_dir + '/plugin']
|
77
|
+
GRI::Plugin.load_plugins plugin_dirs
|
78
|
+
@tra_dir ||= GRI::Config['tra-dir'] || root_dir + '/tra'
|
79
|
+
@interval ||= (GRI::Config['interval'] || 300).to_i
|
80
|
+
end
|
81
|
+
|
82
|
+
def format tag, time, record
|
83
|
+
[tag, time, record].to_msgpack
|
84
|
+
end
|
85
|
+
|
86
|
+
def write chunk
|
87
|
+
records = []
|
88
|
+
chunk.msgpack_each {|tag, time, record|
|
89
|
+
records.push record
|
90
|
+
}
|
91
|
+
writer = GRI::Writer.create 'ldb', :tra_dir=>@tra_dir, :interval=>@interval
|
92
|
+
writer.write records
|
93
|
+
writer.finalize
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
61
97
|
end
|
data/lib/gri/builtindefs.rb
CHANGED
@@ -171,11 +171,16 @@ module GRI
|
|
171
171
|
:tdb=>['hrStorage', 'hrStorageDescr', 'hrStorageSize', 'hrStorageUsed'],
|
172
172
|
:fix_workhash=>lambda {|wh|
|
173
173
|
if (th = wh[:hrStorageTotalHack])
|
174
|
-
|
174
|
+
ht = Hash[*(th.map {|k, v|
|
175
175
|
[v['dskPath'],
|
176
176
|
(v['dskTotalHigh'].to_i * 4294967296 +
|
177
177
|
v['dskTotalLow'].to_i) * 1024]
|
178
178
|
}).flatten]
|
179
|
+
hu = Hash[*(th.map {|k, v|
|
180
|
+
[v['dskPath'],
|
181
|
+
(v['dskUsedHigh'].to_i * 4294967296 +
|
182
|
+
v['dskUsedLow'].to_i) * 1024]
|
183
|
+
}).flatten]
|
179
184
|
end
|
180
185
|
if (h = wh[:hrStorage])
|
181
186
|
h.reject! {|k, v|
|
@@ -183,12 +188,16 @@ module GRI
|
|
183
188
|
h.each {|k, v|
|
184
189
|
u = v['hrStorageAllocationUnits'].to_i
|
185
190
|
v.delete 'hrStorageType'
|
186
|
-
if
|
191
|
+
if ht and (t = ht[v['hrStorageDescr']])
|
187
192
|
v['hrStorageSize'] = t
|
188
193
|
else
|
189
194
|
v['hrStorageSize'] = v['hrStorageSize'].to_i * u
|
190
195
|
end
|
191
|
-
|
196
|
+
if hu and (t = hu[v['hrStorageDescr']])
|
197
|
+
v['hrStorageUsed'] = t
|
198
|
+
else
|
199
|
+
v['hrStorageUsed'] = v['hrStorageUsed'].to_i * u
|
200
|
+
end
|
192
201
|
}
|
193
202
|
end
|
194
203
|
},
|
@@ -201,7 +210,8 @@ module GRI
|
|
201
210
|
},
|
202
211
|
|
203
212
|
'hrStorageTotalHack'=>{
|
204
|
-
:oid=>['dskPath', 'dskTotalLow', 'dskTotalHigh'
|
213
|
+
:oid=>['dskPath', 'dskTotalLow', 'dskTotalHigh',
|
214
|
+
'dskUsedLow', 'dskUsedHigh'],
|
205
215
|
},
|
206
216
|
|
207
217
|
'hrSWRunPerf'=>{
|
data/lib/gri/collector.rb
CHANGED
@@ -99,6 +99,7 @@ module GRI
|
|
99
99
|
if $debug
|
100
100
|
puts "snmp: #{host} (#{vendor.name}): #{sysinfo['sysDescr']}"
|
101
101
|
puts vendor.options.inspect
|
102
|
+
printf " elapsed %f sec\n", Time.now - @attached_at
|
102
103
|
end
|
103
104
|
|
104
105
|
@snmp.version = vendor.options['ver'] if vendor.options['ver']
|
@@ -106,6 +107,7 @@ module GRI
|
|
106
107
|
punits_d = punits.dup
|
107
108
|
@workhash = punits.inject({}) {|h, pu| h[pu.cat] = {}; h}
|
108
109
|
poll1(punits) {
|
110
|
+
printf " elapsed %f sec\n", Time.now - @attached_at if $debug
|
109
111
|
if !options.has_key?('SYS') or options['SYS']
|
110
112
|
sysinfo.delete 'sysObjectID'
|
111
113
|
records = [sysinfo]
|
@@ -168,8 +170,10 @@ module GRI
|
|
168
170
|
records.push h
|
169
171
|
end
|
170
172
|
end
|
173
|
+
printf " elapsed %f sec\n", Time.now - @attached_at if $debug
|
171
174
|
@cb.call records
|
172
175
|
@loop.detach self
|
176
|
+
printf " elapsed %f sec\n", Time.now - @attached_at if $debug
|
173
177
|
}
|
174
178
|
}
|
175
179
|
end
|
@@ -190,8 +194,16 @@ module GRI
|
|
190
194
|
pu = punits.shift
|
191
195
|
@get_oid_buf = []
|
192
196
|
oids = pu.oids.dup
|
193
|
-
|
194
|
-
|
197
|
+
if $debug
|
198
|
+
t = Time.now
|
199
|
+
puts " poll #{host} #{pu.name}" if $debug['walk']
|
200
|
+
end
|
201
|
+
walk1(pu, oids) {
|
202
|
+
if $debug and !$debug['walk']
|
203
|
+
printf " poll #{host} #{pu.name} (%f sec)\n", Time.now - t
|
204
|
+
end
|
205
|
+
poll1 punits, &cb
|
206
|
+
}
|
195
207
|
end
|
196
208
|
end
|
197
209
|
|
@@ -250,10 +262,10 @@ module GRI
|
|
250
262
|
@snmp.connect unless @snmp.sock
|
251
263
|
@snmp.walk_start(enoid) {|*res| @results.push res}
|
252
264
|
send_req enoid
|
253
|
-
rescue SocketError
|
265
|
+
rescue SocketError => e
|
254
266
|
@loop.detach self
|
255
267
|
@on_error.call if @on_error
|
256
|
-
Log.error "#{host}: error"
|
268
|
+
Log.error "#{host}: error: #{e.to_s}"
|
257
269
|
end
|
258
270
|
|
259
271
|
def get varbind, &cb
|
@@ -263,10 +275,10 @@ module GRI
|
|
263
275
|
@snmp.connect unless @snmp.sock
|
264
276
|
@snmp.get_start(varbind) {|*res| @results.push res}
|
265
277
|
send_req varbind
|
266
|
-
rescue SocketError
|
278
|
+
rescue SocketError => e
|
267
279
|
@loop.detach self
|
268
280
|
@on_error.call if @on_error
|
269
|
-
Log.error "#{host}: error"
|
281
|
+
Log.error "#{host}: error: #{e.to_s}"
|
270
282
|
end
|
271
283
|
|
272
284
|
def send_req arg
|
@@ -290,8 +302,14 @@ module GRI
|
|
290
302
|
elsif @preq
|
291
303
|
Log.warn "#{host}: retry #{@retry_count}"
|
292
304
|
@on_retry.call if @on_retry
|
293
|
-
@
|
294
|
-
|
305
|
+
if (s = @snmp.make_req(@snmp.state, @preq.last))
|
306
|
+
@buffers.push s
|
307
|
+
loop.watch @snmp.sock, :w, @tout, self
|
308
|
+
else
|
309
|
+
@loop.detach self
|
310
|
+
@on_error.call if @on_error
|
311
|
+
Log.error "#{host}: cannot retry: #{@retry_count}"
|
312
|
+
end
|
295
313
|
else
|
296
314
|
@loop.detach self
|
297
315
|
@on_error.call if @on_error
|
@@ -314,8 +332,8 @@ module GRI
|
|
314
332
|
@snmp.state = :SUCCESS if @snmp.state == :GET_REQ
|
315
333
|
end
|
316
334
|
if @snmp.state == :SUCCESS
|
317
|
-
@poll_cb.call @results
|
318
335
|
@preq = nil
|
336
|
+
@poll_cb.call @results
|
319
337
|
elsif @snmp.state != :IDLE
|
320
338
|
send_req arg if arg
|
321
339
|
end
|
data/lib/gri/main.rb
CHANGED
@@ -59,6 +59,7 @@ module GRI
|
|
59
59
|
writer = Writer.create 'rrd', wopts
|
60
60
|
app.writers.push writer
|
61
61
|
end
|
62
|
+
app.writers.clear if @options['reset-writers']
|
62
63
|
if @options['writers']
|
63
64
|
for w in @options['writers']
|
64
65
|
writer = Writer.create w, @config.to_h
|
@@ -103,6 +104,7 @@ module GRI
|
|
103
104
|
op.on('--rrdupdater', '--updater') {opts['updater'] = true}
|
104
105
|
op.on('--single') {opts['para'] = false}
|
105
106
|
op.on('--tra=URL') {|arg| opts['tra'] = arg}
|
107
|
+
op.on('--reset-writers') {opts['reset-writers'] = true}
|
106
108
|
|
107
109
|
op.on('-c COMMUNITY') {|arg| opts['community'] = arg}
|
108
110
|
op.on('-v VER') {|arg| opts['version'] = arg}
|
data/lib/gri/page.rb
CHANGED
@@ -3,6 +3,7 @@ require 'gri/builtindefs'
|
|
3
3
|
require 'gri/utils'
|
4
4
|
require 'gri/request'
|
5
5
|
require 'gri/format_helper'
|
6
|
+
require 'gri/blank'
|
6
7
|
|
7
8
|
module GRI
|
8
9
|
class Page
|
@@ -15,10 +16,15 @@ module GRI
|
|
15
16
|
|
16
17
|
def mk_page_title dirs, rs, params
|
17
18
|
jstr = (params['p'] == 't' or params['p'] == 'v') ? ', ' : ' + '
|
18
|
-
hosthash = {}
|
19
19
|
descrs = []
|
20
20
|
headlegend = nil
|
21
21
|
|
22
|
+
if (tags = params.getvar('tag'))
|
23
|
+
title = tags.compact.join jstr
|
24
|
+
return title, title, headlegend
|
25
|
+
end
|
26
|
+
|
27
|
+
hosthash = {}
|
22
28
|
for rname in rs
|
23
29
|
host, key = rname.split('_', 2)
|
24
30
|
hosthash[host] = true
|
@@ -52,7 +58,7 @@ module GRI
|
|
52
58
|
descr
|
53
59
|
end
|
54
60
|
}.join(jstr)
|
55
|
-
body_title = descrs.
|
61
|
+
body_title = descrs.map {|url, xhost, descr|
|
56
62
|
if xhost and hosthash.size > 1
|
57
63
|
"<a href=\"#{h url}\">#{h xhost}:#{h descr}</a>"
|
58
64
|
else
|
@@ -66,6 +72,7 @@ module GRI
|
|
66
72
|
def mk_param_str stime, etime, rs, ds, params
|
67
73
|
res = rs.map {|r| "r=#{u r}"}
|
68
74
|
res << "grp=#{u params['grp']}" if params['grp']
|
75
|
+
(tags = params.getvar('tag')) && tags.each {|tag| res << "tag=#{u tag}"}
|
69
76
|
res << "stime=#{stime.to_i}"
|
70
77
|
res << "etime=#{etime.to_i}" if etime.to_i.nonzero?
|
71
78
|
res << "z=#{u params['z']}"
|
@@ -78,9 +85,15 @@ module GRI
|
|
78
85
|
|
79
86
|
def mk_graph_tag stime, etime, rs, params
|
80
87
|
if params['p'] == 't'
|
81
|
-
|
82
|
-
|
83
|
-
|
88
|
+
if (tags = params.getvar 'tag')
|
89
|
+
tags.map {|tag|
|
90
|
+
mk_graph_tag_r stime, etime, [], params
|
91
|
+
}.join("\n")
|
92
|
+
else
|
93
|
+
rs.map {|rname|
|
94
|
+
mk_graph_tag_r stime, etime, [rname], params
|
95
|
+
}.join("\n")
|
96
|
+
end
|
84
97
|
else
|
85
98
|
mk_graph_tag_r stime, etime, rs, params
|
86
99
|
end
|
@@ -160,10 +173,18 @@ module GRI
|
|
160
173
|
cs = stime.strftime '%Y-%m-%d %H:%M:%S'
|
161
174
|
ce = etime.strftime '%Y-%m-%d %H:%M:%S'
|
162
175
|
|
163
|
-
|
164
|
-
|
165
|
-
|
176
|
+
if (tags = params.getvar('tag')) and (grp = params['grp'])
|
177
|
+
gra_dir, = @options[:dirs]
|
178
|
+
rrdpaths = tags.inject([]) {|a, tag|
|
179
|
+
a += Dir.glob("#{gra_dir}/#{grp}/#{tag}/*.rrd")
|
180
|
+
}
|
181
|
+
r = File.basename rrdpaths.first
|
182
|
+
else
|
183
|
+
r = params['r'] || ''
|
184
|
+
end
|
185
|
+
host, @data_name, = parse_host_key r
|
166
186
|
|
187
|
+
rs = params.getvar('r') || []
|
167
188
|
@title, body_title, headlegend =
|
168
189
|
mk_page_title @options[:dirs], rs, params
|
169
190
|
|
@@ -190,6 +211,7 @@ module GRI
|
|
190
211
|
<form enctype="application/x-www-form-urlencoded" method="get"
|
191
212
|
action="<%= url_to '?' %>">
|
192
213
|
<% rs.each {|r| -%><%= hidden 'r', r %><% } -%>
|
214
|
+
<% tags and tags.each {|tag| -%><%= hidden 'tag', tag %><% } -%>
|
193
215
|
<% if params['grp'] then %><%= hidden 'grp', params['grp'] %><% end %>
|
194
216
|
<% tzs = TZS -%>
|
195
217
|
<% (tzs.assoc(params['tz']) || tzs[0])[2] = true -%>
|
@@ -210,7 +232,7 @@ Graph size: <%= popup_menu('z', nil, *zs) %>
|
|
210
232
|
<% (tms.assoc(params['tm']) || tms[1])[2] = true -%>
|
211
233
|
term: <%= popup_menu('tm', nil, *tms) %>
|
212
234
|
<br/>
|
213
|
-
<% if rs.size > 1 -%>
|
235
|
+
<% if rs.size > 1 or grp -%>
|
214
236
|
<% c_ary = [['', 'sum'], ['s', 'stack'], ['v', 'overlay'], ['t', 'tile']] -%>
|
215
237
|
<% (c_ary.assoc(params['p']) || c_ary[0])[2] = true -%>
|
216
238
|
Composite type: <%= popup_menu('p', nil, *c_ary) %><br/>
|
data/lib/gri/pcollector.rb
CHANGED
@@ -66,7 +66,7 @@ module GRI
|
|
66
66
|
pkeys.shift
|
67
67
|
pts += ptargets[t]
|
68
68
|
while (n = pts.shift)
|
69
|
-
timeout(waittime) {sock = server_sock.accept}
|
69
|
+
Timeout.timeout(waittime) {sock = server_sock.accept}
|
70
70
|
if (res = IO.select(nil, [sock], nil, 20))
|
71
71
|
thost = targets[n].first
|
72
72
|
sock.puts "#{n} #{thost}"
|
data/lib/gri/scheduler.rb
CHANGED
@@ -25,9 +25,11 @@ module GRI
|
|
25
25
|
|
26
26
|
def process1 col_type, host, options
|
27
27
|
return if Config['nop']
|
28
|
+
return if col_type == 'fluentd'
|
28
29
|
collector = Collector.create(col_type, host, options,
|
29
30
|
@fake_descr_hash) {|records|
|
30
31
|
for writer in @writers
|
32
|
+
puts " writer #{writer.class}" if $debug
|
31
33
|
writer.write records
|
32
34
|
end
|
33
35
|
@metrics[:record_count] += records.size
|
data/lib/gri/version.rb
CHANGED
data/test/test_collector.rb
CHANGED
@@ -18,7 +18,7 @@ end
|
|
18
18
|
|
19
19
|
class TestCollector < Test::Unit::TestCase
|
20
20
|
TEST_SYS = "0\x81\xF2\x02\x01\x01\x04\bpublic00\xA2\x81\xE2\x02" +
|
21
|
-
"\x02\x03\
|
21
|
+
"\x02\x03\xEA\x02\x01\x00\x02\x01\x000\x81\xD50d\x06\b+\x06\x01" +
|
22
22
|
"\x02\x01\x01\x01\x00\x04XLinux xxxxx.yyyyy.zzz.com " +
|
23
23
|
"X.X.XX-XXX.XX.X.XXX #1 SMP Thu Oct 31 12:00:00 EDT 2013 x86_64" +
|
24
24
|
"0\x1F\x06\b+\x06\x01\x02\x01\x01\x05\x00\x04\x13xxxxx.yyyyy.zzz.com" +
|
data/test/test_format_helper.rb
CHANGED
@@ -30,7 +30,8 @@ class TestFormatHelper < Test::Unit::TestCase
|
|
30
30
|
def test_format_helper_mk_query
|
31
31
|
ae '?a=1', mk_query(:a=>1)
|
32
32
|
assert_match /\bb=a\+%26\b/, mk_query(:a=>1, :b=>'a &')
|
33
|
-
assert_not_match /\bc=/, mk_query(:c=>nil)
|
33
|
+
#assert_not_match /\bc=/, mk_query(:c=>nil)
|
34
|
+
assert(/\bc=/ !~ mk_query(:c=>nil))
|
34
35
|
end
|
35
36
|
|
36
37
|
def test_format_helper_td
|
@@ -44,8 +45,10 @@ class TestFormatHelper < Test::Unit::TestCase
|
|
44
45
|
end
|
45
46
|
|
46
47
|
def test_format_helper_text_field
|
47
|
-
|
48
|
-
|
48
|
+
t = text_field('text', 'aaa', 40, nil, nil)
|
49
|
+
s = t.scan(/\b(\w+="[^\"]+")/).flatten.sort
|
50
|
+
assert_equal ['name="text"', 'size="40"', 'type="text"', 'value="aaa"'], s
|
51
|
+
assert_match /<input\s+.*\/>/, t #/
|
49
52
|
end
|
50
53
|
|
51
54
|
def test_format_helper_popup_menu
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 10.0.
|
4
|
+
version: 10.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- maebashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
184
|
version: '0'
|
185
185
|
requirements: []
|
186
186
|
rubyforge_project:
|
187
|
-
rubygems_version: 2.
|
187
|
+
rubygems_version: 2.5.1
|
188
188
|
signing_key:
|
189
189
|
specification_version: 4
|
190
190
|
summary: GRI
|