RubyRRDtool 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +9 -0
- data/README +64 -0
- data/Rakefile +38 -0
- data/examples/function_test.rb +134 -0
- data/examples/minmax.rb +60 -0
- data/extconf.rb +29 -0
- data/rrd_addition.h +47 -0
- data/rubyrrdtool.c +1093 -0
- data/test/test_rrdtool.rb +172 -0
- metadata +62 -0
@@ -0,0 +1,172 @@
|
|
1
|
+
# Code Generated by ZenTest v. 3.2.0
|
2
|
+
# classname: asrt / meth = ratio%
|
3
|
+
|
4
|
+
$:.unshift '..'
|
5
|
+
|
6
|
+
require 'test/unit' unless defined? $ZENTEST and $ZENTEST
|
7
|
+
require 'RRDtool'
|
8
|
+
|
9
|
+
class TestRRDtool < Test::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
@f = 'test.rrd'
|
12
|
+
@g = (File.basename @f, '.rrd') + '.png'
|
13
|
+
File.delete @f if File.exists? @f
|
14
|
+
File.delete @g if File.exists? @g
|
15
|
+
@r = RRDtool.new @f
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
File.delete @f if File.exists? @f
|
20
|
+
# note: leave the graph file around to check it by hand
|
21
|
+
@r = nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_file
|
25
|
+
@start = Time.now.to_i - 1
|
26
|
+
@step = 300
|
27
|
+
@r.create @step, @start, [ "DS:a:GAUGE:#{2*@step}:0:1",
|
28
|
+
"DS:b:GAUGE:#{2*@step}:-10:10",
|
29
|
+
"RRA:AVERAGE:0.5:1:300",
|
30
|
+
"RRA:LAST:0.5:1:10" ]
|
31
|
+
end
|
32
|
+
|
33
|
+
def create_data
|
34
|
+
scale = 10
|
35
|
+
ts = Time.now.to_i + 1
|
36
|
+
while (ts < (@start.to_i + @step*300)) do
|
37
|
+
@r.update "a:b", ["#{ts}:#{rand()}:#{Math.sin(ts / @step / 10)}"]
|
38
|
+
ts += @step
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_create
|
43
|
+
create_file
|
44
|
+
assert File.readable?(@f)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_dump
|
48
|
+
# RRDtool.dump is not defined for older versions of RRDtool
|
49
|
+
dump_file = "#{@f}.out"
|
50
|
+
create_file
|
51
|
+
create_data
|
52
|
+
if RRDtool.version < 1.2015 then
|
53
|
+
assert_raise NoMethodError do
|
54
|
+
@r.dump dump_file
|
55
|
+
end
|
56
|
+
else
|
57
|
+
@r.dump dump_file
|
58
|
+
assert File.readable? dump_file
|
59
|
+
end
|
60
|
+
# cleanup
|
61
|
+
File.delete dump_file if File.exists? dump_file
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_fetch
|
65
|
+
assert_raise RRDtoolError do
|
66
|
+
@r.fetch ["AVERAGE"]
|
67
|
+
end
|
68
|
+
create_file
|
69
|
+
create_data
|
70
|
+
fary = @r.fetch ["AVERAGE"]
|
71
|
+
assert_not_nil fary
|
72
|
+
assert !fary.empty?
|
73
|
+
#assert_equals expected_data_points, fary[3]
|
74
|
+
# LATER: test rrd.fetch ["AVERAGE", "LAST"]
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_first
|
78
|
+
# first and last should raise an exception without an RRD file
|
79
|
+
assert_raise RRDtoolError do
|
80
|
+
@r.first 0
|
81
|
+
end
|
82
|
+
create_file
|
83
|
+
(0..1).each do |i|
|
84
|
+
f = @r.first i
|
85
|
+
assert_not_nil f
|
86
|
+
assert f > 0
|
87
|
+
end
|
88
|
+
assert_raise RRDtoolError do
|
89
|
+
f2 = @r.first 2
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_graph
|
94
|
+
create_file
|
95
|
+
create_data
|
96
|
+
RRDtool.graph(
|
97
|
+
[@g, "--title", " RubyRRD Demo",
|
98
|
+
"--start", "#{@start} + 1 h",
|
99
|
+
"--end", "#{@start} + 1000 min",
|
100
|
+
"--interlace",
|
101
|
+
"--imgformat", "PNG",
|
102
|
+
"--width=450",
|
103
|
+
"DEF:a=#{@f}:a:AVERAGE",
|
104
|
+
"DEF:b=#{@f}:b:AVERAGE",
|
105
|
+
"CDEF:line=TIME,2400,%,300,LT,a,UNKN,IF",
|
106
|
+
"AREA:b#00b6e4:beta",
|
107
|
+
"AREA:line#0022e9:alpha",
|
108
|
+
"LINE3:line#ff0000"])
|
109
|
+
assert File.exists?(@g)
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_info
|
113
|
+
create_file
|
114
|
+
info = @r.info
|
115
|
+
assert_not_nil info
|
116
|
+
assert_equal info['filename'], @f
|
117
|
+
assert_equal info['step'], @step
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_last
|
121
|
+
# first and last should raise an exception without an RRD file
|
122
|
+
assert_raise RRDtoolError do
|
123
|
+
@r.last
|
124
|
+
end
|
125
|
+
create_file
|
126
|
+
l = @r.last
|
127
|
+
assert l > 0
|
128
|
+
assert_equal @start, l
|
129
|
+
create_data
|
130
|
+
l = @r.last
|
131
|
+
assert l > @start
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_resize
|
135
|
+
raise NotImplementedError, 'Need to write test_resize'
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_restore
|
139
|
+
raise NotImplementedError, 'Need to write test_restore'
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_rrdname
|
143
|
+
r = RRDtool.new 'foo'
|
144
|
+
assert_equal r.rrdname, 'foo'
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_tune
|
148
|
+
raise NotImplementedError, 'Need to write test_tune'
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_update
|
152
|
+
create_file
|
153
|
+
# first, test the simple update case (now)
|
154
|
+
@r.update "a:b", ["N:0:0"]
|
155
|
+
assert_in_delta Time.now.to_i, @r.last, 1
|
156
|
+
# next, create a bunch of data entries
|
157
|
+
create_data
|
158
|
+
l = @r.last
|
159
|
+
@r.update "a:b", ["#{l+1}:0:0", "#{l+2}:1:1"]
|
160
|
+
assert_equal @r.last, l+2
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_version
|
164
|
+
v = RRDtool.version
|
165
|
+
assert_instance_of Float, v
|
166
|
+
assert_not_nil v
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_xport
|
170
|
+
raise NotImplementedError, 'Need to write test_xport'
|
171
|
+
end
|
172
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.11
|
3
|
+
specification_version: 1
|
4
|
+
name: RubyRRDtool
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.6.0
|
7
|
+
date: 2006-10-18 00:00:00 -07:00
|
8
|
+
summary: Ruby language binding for RRD tool version 1.2+
|
9
|
+
require_paths:
|
10
|
+
- test
|
11
|
+
email: drbacher @nospam@ alum dot mit dot edu
|
12
|
+
homepage: http://rubyforge.org/projects/rubyrrdtool/
|
13
|
+
rubyforge_project: rubyrrdtool
|
14
|
+
description: == Introduction rubyrrdtool provides ruby bindings for RRD functions (via librrd), with functionality comparable to the native perl bindings. See examples/minmax.rb or the unit tests in the test directory for scripts that exercise the rrdtool functions.
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
authors:
|
29
|
+
- David Bacher
|
30
|
+
- Mark Probert
|
31
|
+
files:
|
32
|
+
- README
|
33
|
+
- Manifest.txt
|
34
|
+
- Rakefile
|
35
|
+
- extconf.rb
|
36
|
+
- rrd_addition.h
|
37
|
+
- rubyrrdtool.c
|
38
|
+
- test/test_rrdtool.rb
|
39
|
+
- examples/function_test.rb
|
40
|
+
- examples/minmax.rb
|
41
|
+
test_files: []
|
42
|
+
|
43
|
+
rdoc_options: []
|
44
|
+
|
45
|
+
extra_rdoc_files: []
|
46
|
+
|
47
|
+
executables: []
|
48
|
+
|
49
|
+
extensions:
|
50
|
+
- extconf.rb
|
51
|
+
requirements: []
|
52
|
+
|
53
|
+
dependencies:
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: hoe
|
56
|
+
version_requirement:
|
57
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.1.1
|
62
|
+
version:
|