gri 10.0.0
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 +7 -0
- data/.gitignore +7 -0
- data/MIT-LICENSE.txt +20 -0
- data/README.md +132 -0
- data/Rakefile +5 -0
- data/bin/grapher +17 -0
- data/bin/gri +5 -0
- data/bin/gricast +17 -0
- data/bin/grispark +5 -0
- data/bin/griwalk +9 -0
- data/bin/trad +19 -0
- data/bin/trad-http +17 -0
- data/gri.gemspec +21 -0
- data/lib/fluent/plugin/out_gri.rb +56 -0
- data/lib/gri/api.rb +28 -0
- data/lib/gri/app_collector.rb +154 -0
- data/lib/gri/app_walker.rb +23 -0
- data/lib/gri/blank.rb +49 -0
- data/lib/gri/builtindefs.rb +211 -0
- data/lib/gri/cast.rb +84 -0
- data/lib/gri/cgraph.rb +37 -0
- data/lib/gri/clist.rb +163 -0
- data/lib/gri/collector.rb +284 -0
- data/lib/gri/config.rb +134 -0
- data/lib/gri/ds_list.rb +166 -0
- data/lib/gri/format_helper.rb +112 -0
- data/lib/gri/gparams.rb +43 -0
- data/lib/gri/graph.rb +239 -0
- data/lib/gri/grapher.rb +70 -0
- data/lib/gri/ldb.rb +160 -0
- data/lib/gri/list.rb +242 -0
- data/lib/gri/log.rb +140 -0
- data/lib/gri/loop.rb +109 -0
- data/lib/gri/ltsv.rb +58 -0
- data/lib/gri/main.rb +107 -0
- data/lib/gri/mlog.rb +22 -0
- data/lib/gri/mmsgpack.rb +57 -0
- data/lib/gri/msnmp.rb +601 -0
- data/lib/gri/page.rb +235 -0
- data/lib/gri/pcollector.rb +209 -0
- data/lib/gri/plugin.rb +75 -0
- data/lib/gri/plugin/bootstrap.rb +65 -0
- data/lib/gri/plugin/cisco.rb +98 -0
- data/lib/gri/plugin/exec_collector.rb +89 -0
- data/lib/gri/plugin/juniper.rb +5 -0
- data/lib/gri/plugin/netsnmp.rb +8 -0
- data/lib/gri/plugin/ucdavis.rb +176 -0
- data/lib/gri/plugin/writer_fluentd.rb +26 -0
- data/lib/gri/polling_unit.rb +88 -0
- data/lib/gri/q.rb +5 -0
- data/lib/gri/request.rb +29 -0
- data/lib/gri/rrd.rb +438 -0
- data/lib/gri/scheduler.rb +68 -0
- data/lib/gri/sgraph.rb +147 -0
- data/lib/gri/spark.rb +94 -0
- data/lib/gri/tra_collector.rb +80 -0
- data/lib/gri/trad.rb +170 -0
- data/lib/gri/updater.rb +201 -0
- data/lib/gri/util_daemon.rb +19 -0
- data/lib/gri/util_marshal.rb +13 -0
- data/lib/gri/utils.rb +63 -0
- data/lib/gri/vendor.rb +76 -0
- data/lib/gri/version.rb +3 -0
- data/lib/gri/wmain.rb +67 -0
- data/lib/gri/writer.rb +184 -0
- data/mcollector +47 -0
- data/test/mock.rb +60 -0
- data/test/root/gra/.sysdb/sysdb.txt +3 -0
- data/test/root/gra/testhost/.records.txt +2 -0
- data/test/root/if.def +2 -0
- data/test/root/test.conf +4 -0
- data/test/root/testtab +9 -0
- data/test/root/testtab2 +2 -0
- data/test/root/tra/testhost/_/20130614 +20 -0
- data/test/test_app.rb +58 -0
- data/test/test_builtindefs.rb +24 -0
- data/test/test_collector.rb +58 -0
- data/test/test_config.rb +62 -0
- data/test/test_ds_list.rb +48 -0
- data/test/test_exec_collector.rb +33 -0
- data/test/test_format_helper.rb +68 -0
- data/test/test_graph.rb +69 -0
- data/test/test_ldb.rb +29 -0
- data/test/test_list.rb +65 -0
- data/test/test_log.rb +16 -0
- data/test/test_loop.rb +35 -0
- data/test/test_ltsv.rb +38 -0
- data/test/test_main.rb +19 -0
- data/test/test_mmsgpack.rb +27 -0
- data/test/test_msnmp.rb +147 -0
- data/test/test_page.rb +51 -0
- data/test/test_pcollector.rb +71 -0
- data/test/test_plugin.rb +62 -0
- data/test/test_plugin_cisco.rb +23 -0
- data/test/test_polling_unit.rb +58 -0
- data/test/test_request.rb +26 -0
- data/test/test_rrd.rb +53 -0
- data/test/test_rrd_updater.rb +139 -0
- data/test/test_scheduler.rb +31 -0
- data/test/test_tra_collector.rb +40 -0
- data/test/test_trad.rb +33 -0
- data/test/test_util_marshal.rb +17 -0
- data/test/test_utils.rb +15 -0
- data/test/test_vendor.rb +40 -0
- data/test/test_writer.rb +33 -0
- data/test/unittest_helper.rb +27 -0
- metadata +208 -0
data/test/test_main.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/unittest_helper')
|
2
|
+
|
3
|
+
require 'gri/main'
|
4
|
+
|
5
|
+
module GRI
|
6
|
+
|
7
|
+
class TestMain < Test::Unit::TestCase
|
8
|
+
def test_main_optparse
|
9
|
+
main = Main.new
|
10
|
+
opts = {}
|
11
|
+
|
12
|
+
optparser = main.instance_eval {optparse opts}
|
13
|
+
argv = ['--config-path', '/tmp/gri.conf']
|
14
|
+
optparser.parse argv
|
15
|
+
ae '/tmp/gri.conf', opts[:config_path]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/unittest_helper')
|
2
|
+
|
3
|
+
require 'msgpack'
|
4
|
+
require 'gri/mmsgpack'
|
5
|
+
|
6
|
+
class TestMMsgpack < Test::Unit::TestCase
|
7
|
+
def eq obj
|
8
|
+
ae obj, MessagePack.unpack(obj.to_msgpack)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_mmsgpack
|
12
|
+
eq 1
|
13
|
+
eq -1
|
14
|
+
eq 0x7fffffff
|
15
|
+
eq 1000
|
16
|
+
eq 2000000000
|
17
|
+
eq 1000000000000
|
18
|
+
|
19
|
+
eq 'abc'
|
20
|
+
|
21
|
+
assert_nil MessagePack.unpack(nil.to_msgpack)
|
22
|
+
|
23
|
+
eq [1,2,'a']
|
24
|
+
|
25
|
+
eq 1=>'abc'
|
26
|
+
end
|
27
|
+
end
|
data/test/test_msnmp.rb
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
# coding: us-ascii
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/unittest_helper')
|
3
|
+
|
4
|
+
require 'gri/msnmp'
|
5
|
+
|
6
|
+
class TestMSNMP < Test::Unit::TestCase
|
7
|
+
def test_ber_enc
|
8
|
+
# tag 0x02 == INT
|
9
|
+
ae "\x02\x01\x00", BER.enc(0x02, 0)
|
10
|
+
ae "\x02\x01\xFF", BER.enc(0x02, 255)
|
11
|
+
ae "\x02\x02\x01\x00", BER.enc(0x02, 256)
|
12
|
+
ae "\x02\x01\xff", BER.enc(0x02, -1)
|
13
|
+
ae "\x02\x01\x80", BER.enc(0x02, -128)
|
14
|
+
ae "\x02\x02\xff\x7f", BER.enc(0x02, -129)
|
15
|
+
|
16
|
+
# tag 0x04 == STR
|
17
|
+
ae "\x04\x01a", BER.enc(0x04, 'a')
|
18
|
+
ae "\x04\x08abcdefgh", BER.enc(0x04, 'abcdefgh')
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_ber_enc_len
|
22
|
+
ae "\x1", BER.enc_len(1)
|
23
|
+
ae "\x7f", BER.enc_len(127)
|
24
|
+
ae "\x81\x80", BER.enc_len(128)
|
25
|
+
ae "\x81\xff", BER.enc_len(255)
|
26
|
+
ae "\x82\x01\x00", BER.enc_len(256)
|
27
|
+
ae "\x82\xff\xff", BER.enc_len(65535)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_ber_enc_oid
|
31
|
+
ae "+\x06\x01\x02\x01\x02", BER.enc_v_oid('1.3.6.1.2.1.2')
|
32
|
+
ae "\x06\x06+\x06\x01\x02\x01\x02", BER.enc_oid('1.3.6.1.2.1.2')
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_ber_enc_oid_list
|
36
|
+
list = ['sysDescr', 'sysName'].map {|n| SNMP::OIDS[n] + '.0'}
|
37
|
+
s = BER.enc_oid_list list
|
38
|
+
t, val, remain = BER.tlv(s)
|
39
|
+
ae 0x30, t
|
40
|
+
assert remain.empty?
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_ber_cat_enoid
|
44
|
+
oids = [BER.enc_v_oid('1.3.6.1.2.1.1'), BER.enc_v_oid('1.3.6.1.2.1.2')]
|
45
|
+
varbind = BER.cat_enoid oids
|
46
|
+
t, val, remain = BER.tlv(varbind)
|
47
|
+
ae 0x30, t
|
48
|
+
assert remain.empty?
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_dec_oid
|
52
|
+
ae [1,3,6,1,2,1,2], BER.dec_oid(BER.enc_v_oid('1.3.6.1.2.1.2'))
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_ber_dec_int
|
56
|
+
ae 1, BER.dec_int("\x01")
|
57
|
+
ae 127, BER.dec_int("\x7f")
|
58
|
+
ae -128, BER.dec_int("\x80")
|
59
|
+
ae -129, BER.dec_int("\xff\x7f")
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_ber_dec_cnt
|
63
|
+
ae 1, BER.dec_cnt("\x00\x00\x00\x01")
|
64
|
+
ae(2**31+1, BER.dec_cnt("\x80\x00\x00\x01"))
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_ber_tlv
|
68
|
+
tag, val, remain = BER.tlv "\x04\x06public\x04\x08abcdefgh"
|
69
|
+
ae 4, tag
|
70
|
+
ae 'public', val
|
71
|
+
ae "\x04\x08abcdefgh", remain
|
72
|
+
|
73
|
+
s = 'a' * 200
|
74
|
+
tag, val, remain = BER.tlv(BER.enc_str(s))
|
75
|
+
ae 4, tag
|
76
|
+
ae s, val
|
77
|
+
assert remain.empty?
|
78
|
+
|
79
|
+
s = 'a' * 300
|
80
|
+
tag, val, remain = BER.tlv(BER.enc_str(s))
|
81
|
+
ae 4, tag
|
82
|
+
ae s, val
|
83
|
+
assert remain.empty?
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_ber_dec_msg
|
87
|
+
varbind = "\0" * 160
|
88
|
+
s = BER.enc_int(1234) + BER.enc_int(0) + BER.enc_int(0) + varbind
|
89
|
+
s = "\xA2" + BER.enc_len(s.size) + s
|
90
|
+
s = BER.enc_int(1) + BER.enc_str('public') + s
|
91
|
+
msg = "\x30" + BER.enc_len(s.size) + s
|
92
|
+
|
93
|
+
enc_request_id, error_status, error_index, varbind = BER.dec_msg msg
|
94
|
+
ae BER.enc_int(1234), enc_request_id
|
95
|
+
ae 0, error_status
|
96
|
+
ae 0, error_index
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_ber_dec_varbind_block
|
100
|
+
oid = '1.3.6.1.2.1.6.9.0'
|
101
|
+
s = BER.enc_oid(oid) + "B\x01\x10" # GAUGE 1 16
|
102
|
+
msg = "\x30" + BER.enc_len(s.size) + s
|
103
|
+
res, = BER.dec_varbind(msg)
|
104
|
+
ae oid, BER.dec_oid(res[0]).join('.')
|
105
|
+
ae 0x42, res[1] # GAUGE
|
106
|
+
ae 16, res[2]
|
107
|
+
|
108
|
+
oid = SNMP::OIDS['sysDescr']+'.0'
|
109
|
+
s = BER.enc_oid(oid) + BER.enc_str("test")
|
110
|
+
s = "\x30" + BER.enc_len(s.size) + s
|
111
|
+
res, = BER.dec_varbind(s)
|
112
|
+
ae oid, BER.dec_oid(res[0]).join('.')
|
113
|
+
ae 0x04, res[1]
|
114
|
+
ae 'test', res[2]
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_snmp_enoid2name
|
118
|
+
snmp = SNMP.new '127.0.0.1'
|
119
|
+
enoid = BER.enc_v_oid SNMP::OIDS['system']
|
120
|
+
ae 'system', snmp.enoid2name(enoid)
|
121
|
+
enoid = BER.enc_v_oid '1.3.6.1.2.1.1.1.0'
|
122
|
+
ae 'sysDescr.0', snmp.enoid2name(enoid)
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_c64
|
126
|
+
c = BER::C64.new "\0"
|
127
|
+
ae "0x0000000000000000", c.to_s
|
128
|
+
|
129
|
+
c = BER::C64.new "\x01\x00\x00"
|
130
|
+
ae "0x0000000000010000", c.to_s
|
131
|
+
ae 65536, c.to_i
|
132
|
+
|
133
|
+
n = 0xffffffffffffffff
|
134
|
+
c = BER::C64.new [n].pack('Q')
|
135
|
+
ae "0xffffffffffffffff", c.to_s
|
136
|
+
|
137
|
+
c = BER::C64.new "\x12\x34\x56\x78\xfe\xdc\xba\x98"
|
138
|
+
ae "0x12345678fedcba98", c.to_s
|
139
|
+
ae "\x124Vx\xFE\xDC\xBA\x98", c.to_binary
|
140
|
+
ae "\xcf\x124Vx\xfe\xdc\xba\x98", c.to_msgpack
|
141
|
+
|
142
|
+
c = BER::C64.new "\x01\x23\x45\x67\x89"
|
143
|
+
ae "\xcf\x00\x00\x00\x01#Eg\x89", c.to_msgpack
|
144
|
+
|
145
|
+
c = BER::C64.new "\x00\x03\x00\x00\x00\x00\x00\x00"
|
146
|
+
end
|
147
|
+
end
|
data/test/test_page.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/unittest_helper')
|
2
|
+
|
3
|
+
require 'rack'
|
4
|
+
require 'gri/page'
|
5
|
+
|
6
|
+
module GRI
|
7
|
+
|
8
|
+
class TestPage < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
@root_dir = File.dirname(__FILE__) + '/root'
|
11
|
+
@page = Page.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_page_mk_page_title
|
15
|
+
rs = ['testhost__eth0']
|
16
|
+
res = @page.mk_page_title([@root_dir + '/gra'], rs, {})
|
17
|
+
ae 3, res.size
|
18
|
+
ae 'testdescr', res[0]
|
19
|
+
assert_match(/__eth0/, res[1])
|
20
|
+
assert_match(/ eth0/, res[2])
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_page_mk_param_str
|
24
|
+
rs = ['r0.example.com', 'r 1?']
|
25
|
+
params = {}
|
26
|
+
assert_match /\br=r\+1%3F/, @page.mk_param_str(0, 0, rs, nil, params)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_page_mk_graph_tag
|
30
|
+
stime = Time.local(2013,10,1)
|
31
|
+
etime = stime + 24*3600
|
32
|
+
rs = ['testhost__eth0']
|
33
|
+
params = {'p'=>'s'}
|
34
|
+
res = @page.mk_graph_tag stime, etime, rs, params
|
35
|
+
ae 2, res.scan(/inoctet/).size
|
36
|
+
ae 2, res.scan(/indiscard/).size
|
37
|
+
ae 2, res.scan(/inerror/).size
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_page_parse_request
|
41
|
+
s = '/?r=testhost__eth0&cs=2013-10-01&ce=2013-10-02'
|
42
|
+
env = Rack::MockRequest.env_for s
|
43
|
+
req = GRI::Request.new env
|
44
|
+
stime, etime, params = @page.parse_request req
|
45
|
+
ae 1380553200, stime.to_i
|
46
|
+
ae 1380639600, etime.to_i
|
47
|
+
ae 'testhost__eth0', params['r']
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/unittest_helper')
|
2
|
+
|
3
|
+
require 'gri/config'
|
4
|
+
require 'gri/pcollector'
|
5
|
+
require 'mock'
|
6
|
+
|
7
|
+
module GRI
|
8
|
+
|
9
|
+
class TestPCollector < Test::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
path = File.expand_path(File.dirname(__FILE__) + '/root/testtab')
|
12
|
+
config = Config.new
|
13
|
+
config['gritab-path'] = path
|
14
|
+
@app = AppCollector.new config
|
15
|
+
lines = @app.load_target_lines config
|
16
|
+
@targets = @app.get_targets_from_lines lines, config
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_pcollector_get_ptargets
|
20
|
+
targets = @targets
|
21
|
+
|
22
|
+
basetime = Time.local(2013,4,1,10,5).to_i
|
23
|
+
ptargets = @app.get_ptargets targets, basetime, 0
|
24
|
+
ae 1, ptargets.size
|
25
|
+
ae basetime.to_i, ptargets.keys.first
|
26
|
+
|
27
|
+
ptargets = @app.get_ptargets targets, basetime, 1
|
28
|
+
t = Time.local(2013,4,1,10,5).to_i
|
29
|
+
hosts = ptargets[t].map {|n| targets[n].first}.sort
|
30
|
+
ae ["host01", "host02", "host03", "host04", "host05", "localhost"], hosts
|
31
|
+
|
32
|
+
basetime = Time.local(2013,4,1,10,0).to_i
|
33
|
+
ptargets = @app.get_ptargets targets, basetime, 300
|
34
|
+
t = Time.local(2013,4,1,10,0).to_i
|
35
|
+
hosts = ptargets[t].map {|n| targets[n].first}.sort
|
36
|
+
ae ["host00", "host01", "host02", "host03", "host04", "host05", "host06",
|
37
|
+
"localhost"], hosts
|
38
|
+
|
39
|
+
basetime = Time.local(2013,4,1,10,7).to_i
|
40
|
+
ptargets = @app.get_ptargets targets, basetime, 300
|
41
|
+
t = Time.local(2013,4,1,10,10).to_i
|
42
|
+
hosts = ptargets[t].map {|n| targets[n].first}.sort
|
43
|
+
ae ["host01", "host02", "host03", "host04", "host05", "localhost"], hosts
|
44
|
+
|
45
|
+
basetime = Time.local(2013,4,1,10,7).to_i
|
46
|
+
ptargets = @app.get_ptargets targets, basetime, 300, 120
|
47
|
+
|
48
|
+
#for t, inds in ptargets.sort_by {|t,| t}
|
49
|
+
# p [Time.at(t), inds.map {|ind|targets[ind].first}]
|
50
|
+
#end
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_pcollector_server_loop
|
54
|
+
@app.server_loop([], {}, nil, nil)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_pcollector_get_max_queue_size
|
58
|
+
config = Config.new
|
59
|
+
app = AppCollector.new config
|
60
|
+
assert_kind_of Integer, @app.get_max_queue_size
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_pcollector_fork_child
|
64
|
+
@app.extend MockFork
|
65
|
+
nproc = 2
|
66
|
+
pids = @app.fork_child nil, nil, nproc, nil, nil, nil, nil
|
67
|
+
ae nproc, pids.size
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
data/test/test_plugin.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# coding: us-ascii
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/unittest_helper')
|
3
|
+
|
4
|
+
require 'gri/config'
|
5
|
+
require 'gri/plugin'
|
6
|
+
|
7
|
+
module GRI
|
8
|
+
|
9
|
+
class TestPlugin < Test::Unit::TestCase
|
10
|
+
def test_plugin_load_plugin_dir
|
11
|
+
lib_dir = File.dirname(__FILE__) + '/../lib/gri/plugin'
|
12
|
+
files = GRI::Plugin.get_plugin_files lib_dir
|
13
|
+
assert(files.size > 5)
|
14
|
+
|
15
|
+
config = Config.new
|
16
|
+
config['enable-plugin'] = 'ucdavis'
|
17
|
+
files = GRI::Plugin.get_plugin_files lib_dir, config
|
18
|
+
ae 1, files.size
|
19
|
+
|
20
|
+
config['enable-plugin'] = 'netsnmp'
|
21
|
+
files = GRI::Plugin.get_plugin_files lib_dir, config
|
22
|
+
ae 2, files.size
|
23
|
+
|
24
|
+
config['disable-plugin'] = 'ucdavis'
|
25
|
+
files = GRI::Plugin.get_plugin_files lib_dir, config
|
26
|
+
ae 1, files.size
|
27
|
+
end
|
28
|
+
|
29
|
+
require 'gri/msnmp'
|
30
|
+
require 'gri/builtindefs'
|
31
|
+
require 'gri/vendor'
|
32
|
+
require 'gri/polling_unit'
|
33
|
+
require 'gri/plugin/ucdavis'
|
34
|
+
|
35
|
+
DATA = [
|
36
|
+
["+\x06\x01\x04\x01\x8Fe\t\x01\x01\x01", 2, 1],
|
37
|
+
["+\x06\x01\x04\x01\x8Fe\t\x01\x02\x01", 4, "/"],
|
38
|
+
["+\x06\x01\x04\x01\x8Fe\t\x01\x06\x01", 2, 40_000_000],
|
39
|
+
["+\x06\x01\x04\x01\x8Fe\t\x01\a\x01", 2, 25_000_000],
|
40
|
+
["+\x06\x01\x04\x01\x8Fe\t\x01\b\x01", 2, 9_000_000],
|
41
|
+
]
|
42
|
+
|
43
|
+
def test_plugin_ucdavis_feed
|
44
|
+
SNMP.new 'host'
|
45
|
+
vendor = Vendor.check({}, {'ucd-dsk'=>true})
|
46
|
+
pu = vendor.get_punits.detect {|pu| pu.name == 'ucd-dsk'}
|
47
|
+
|
48
|
+
wh = {}
|
49
|
+
DATA.each {|enoid, tag, val|
|
50
|
+
pu.feed wh, enoid, tag, val}
|
51
|
+
h = wh[1]
|
52
|
+
ae '/', h['dskPath']
|
53
|
+
ae 40000000, h['dskTotal']
|
54
|
+
ae 9000000, h['dskUsed']
|
55
|
+
|
56
|
+
pu.fix_workhash :disk=>wh
|
57
|
+
ae 40000000*1024, h['dskTotal']
|
58
|
+
ae 9000000*1024, h['dskUsed']
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/unittest_helper')
|
2
|
+
|
3
|
+
require 'gri/msnmp'
|
4
|
+
require 'gri/builtindefs'
|
5
|
+
require 'gri/vendor'
|
6
|
+
require 'gri/plugin/cisco'
|
7
|
+
|
8
|
+
module GRI
|
9
|
+
|
10
|
+
class TestPluginCisco < Test::Unit::TestCase
|
11
|
+
def test_plugin_cisco
|
12
|
+
sysinfo = {'sysObjectID'=>"+\x06\x01\x04\x01\t\x01",
|
13
|
+
'sysDescr'=>"Cisco IOS Software, c9999x00000_rp Software (c9999x00000_xx), Version 12.3(45)X678, RELEASE SOFTWARE ()",
|
14
|
+
}
|
15
|
+
vendor = Vendor.check sysinfo
|
16
|
+
assert vendor.options['interfaces']
|
17
|
+
assert vendor.options['lcpu']
|
18
|
+
ae '2c', vendor.options['ver']
|
19
|
+
ae 'c9999x00000_xx', sysinfo['_firm']
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# coding: us-ascii
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/unittest_helper')
|
3
|
+
|
4
|
+
require 'gri/msnmp'
|
5
|
+
require 'gri/builtindefs'
|
6
|
+
require 'gri/polling_unit'
|
7
|
+
|
8
|
+
module GRI
|
9
|
+
class TestPollingUnit < Test::Unit::TestCase
|
10
|
+
def test_polling_unit_all_units
|
11
|
+
units = PollingUnit.all_units
|
12
|
+
assert_kind_of PollingUnit, units['interfaces']
|
13
|
+
assert_kind_of PollingUnit, units['ifMIB']
|
14
|
+
assert_kind_of PollingUnit, units['ipaddr']
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_polling_unit
|
18
|
+
pu = PollingUnit.new 'test', :test
|
19
|
+
ae 'test', pu.name
|
20
|
+
pu.dhash = {}
|
21
|
+
oids = ['ifDescr', 'ifSpeed', 'ifAdminStatus', 'ifOperStatus']
|
22
|
+
pu.set_oids oids
|
23
|
+
ae 4, pu.oids.size
|
24
|
+
ae "+\x06\x01\x02\x01\x02\x02\x01\x02", pu.oids.first
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_polling_unit_feed
|
28
|
+
snmp = SNMP.new 'host'
|
29
|
+
|
30
|
+
workhash = {''=>{}}
|
31
|
+
|
32
|
+
units = PollingUnit.all_units
|
33
|
+
pu = units['interfaces']
|
34
|
+
wh = workhash[pu.cat]
|
35
|
+
enoid = BER.enc_v_oid(SNMP::OIDS['ifDescr'] + '.1')
|
36
|
+
pu.feed wh, enoid, 4, 'lo'
|
37
|
+
ae 'lo', wh[1]['ifDescr']
|
38
|
+
enoid = BER.enc_v_oid(SNMP::OIDS['ifDescr'] + '.2')
|
39
|
+
pu.feed wh, enoid, 4, 'eth0'
|
40
|
+
ae 'eth0', wh[2]['ifDescr']
|
41
|
+
|
42
|
+
pu = units['ifMIB']
|
43
|
+
wh = workhash[pu.cat]
|
44
|
+
enoid = BER.enc_v_oid(SNMP::OIDS['ifHighSpeed'] + '.2')
|
45
|
+
pu.feed wh, enoid, 2, 10000
|
46
|
+
ae 10000, wh[2]['ifHighSpeed']
|
47
|
+
pu.fix_workhash workhash
|
48
|
+
ae 10000000000, wh[2]['ifSpeed']
|
49
|
+
|
50
|
+
workhash[:ipaddr] = {
|
51
|
+
'192.168.0.1'=>{'ifIndex'=>2, 'mask'=>'255.255.255.0'}
|
52
|
+
}
|
53
|
+
pu = units['ipaddr']
|
54
|
+
pu.fix_workhash workhash
|
55
|
+
ae '192.168.0.1/255.255.255.0', wh[2]['ipaddr']
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|