librrd 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -1
- data/Rakefile +14 -1
- data/VERSION +1 -1
- data/lib/librrd.rb +5 -0
- data/librrd.gemspec +6 -4
- data/test/test_librrd.rb +20 -0
- data/test/test_rrd.rb +79 -0
- metadata +9 -6
- data/test.rb +0 -76
data/README.md
CHANGED
@@ -17,6 +17,8 @@ The following systems, RRDtool versions and Ruby versions have been tested.
|
|
17
17
|
* Ruby 1.9.2p0, 1.8.7p302
|
18
18
|
* Rubinius 1.1.0
|
19
19
|
* ruby-enterpriseedition 1.8.7 2010.02
|
20
|
+
* CentOS 5.5 (RRDtool 1.2.27)
|
21
|
+
* ruby-enterpriseedition 1.8.6 20090610
|
20
22
|
* OpenBSD 4.8 (RRDtool 1.2.30)
|
21
23
|
* Ruby 1.9.2p0, 1.8.7p302
|
22
24
|
|
@@ -25,7 +27,18 @@ The following systems, RRDtool versions and Ruby versions have been tested.
|
|
25
27
|
Make sure you have the development package of `librrd` installed.
|
26
28
|
(like `librrd-dev` on Debian/Ubuntu) Then you can just `gem install`.
|
27
29
|
|
28
|
-
|
30
|
+
gem install librrd
|
31
|
+
|
32
|
+
# Developing
|
33
|
+
|
34
|
+
Build the C extension:
|
35
|
+
|
36
|
+
ruby ext/librrd/extconf.rb
|
37
|
+
make
|
38
|
+
|
39
|
+
Run the tests:
|
40
|
+
|
41
|
+
rake test
|
29
42
|
|
30
43
|
# Contribute
|
31
44
|
|
data/Rakefile
CHANGED
@@ -46,7 +46,20 @@ end
|
|
46
46
|
#
|
47
47
|
#############################################################################
|
48
48
|
|
49
|
-
task :default => :
|
49
|
+
task :default => :test
|
50
|
+
|
51
|
+
require 'rake/testtask'
|
52
|
+
task :test => :build_rrd
|
53
|
+
Rake::TestTask.new(:test) do |test|
|
54
|
+
test.libs << 'lib' << 'test'
|
55
|
+
test.pattern = 'test/**/test_*.rb'
|
56
|
+
test.verbose = false
|
57
|
+
end
|
58
|
+
|
59
|
+
desc "Built the RRD.so"
|
60
|
+
task :build_rrd do
|
61
|
+
sh "ruby ext/librrd/extconf.rb && make"
|
62
|
+
end
|
50
63
|
|
51
64
|
#############################################################################
|
52
65
|
#
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0
|
data/lib/librrd.rb
ADDED
data/librrd.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
|
|
7
7
|
## If your rubyforge_project name is different, then edit it and comment out
|
8
8
|
## the sub! line in the Rakefile
|
9
9
|
s.name = 'librrd'
|
10
|
-
s.version = '0.
|
11
|
-
s.date = '
|
10
|
+
s.version = '1.0.0'
|
11
|
+
s.date = '2011-01-15'
|
12
12
|
|
13
13
|
s.summary = "Ruby bindings for librrd"
|
14
14
|
s.description = "Ruby bindings for librrd. Extracted from the RRDtool source."
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
|
22
22
|
## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
|
23
|
-
s.require_paths = %w[ext]
|
23
|
+
s.require_paths = %w[ext lib]
|
24
24
|
|
25
25
|
s.rdoc_options = ["--charset=UTF-8"]
|
26
26
|
s.extra_rdoc_files = %w[README.md CHANGES.md]
|
@@ -41,8 +41,10 @@ Gem::Specification.new do |s|
|
|
41
41
|
ext/librrd/1.3/main.c
|
42
42
|
ext/librrd/1.4/main.c
|
43
43
|
ext/librrd/extconf.rb
|
44
|
+
lib/librrd.rb
|
44
45
|
librrd.gemspec
|
45
|
-
test.rb
|
46
|
+
test/test_librrd.rb
|
47
|
+
test/test_rrd.rb
|
46
48
|
]
|
47
49
|
# = MANIFEST =
|
48
50
|
|
data/test/test_librrd.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'librrd'
|
3
|
+
|
4
|
+
class TestLibRRD < Test::Unit::TestCase
|
5
|
+
# RubyGems users expect when they install a gem that:
|
6
|
+
#
|
7
|
+
# "gem name" == "name they require" == "name of object in global namespace".
|
8
|
+
#
|
9
|
+
# Alias RRD to LibRRD, so backwards compatibility is retained, but RubyGems
|
10
|
+
# users aren't surprised.
|
11
|
+
#
|
12
|
+
|
13
|
+
def test_constant_defined
|
14
|
+
assert(Object.const_defined?(:"LibRRD"))
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_rrd_methods_defined
|
18
|
+
assert(%w(fetch dump graph update).all? {|m| LibRRD.methods.include?(m) })
|
19
|
+
end
|
20
|
+
end
|
data/test/test_rrd.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'time'
|
3
|
+
require 'RRD'
|
4
|
+
|
5
|
+
class TestRRD < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
@rrd_file = 'test.rrd'
|
8
|
+
@png_file = "#{File.basename(@rrd_file, '.rrd')}.png"
|
9
|
+
@start_time = Time.parse('2011-01-15').to_i
|
10
|
+
@end_time = @start_time + 300 * 300
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
File.unlink(@rrd_file) if File.exist?(@rrd_file)
|
15
|
+
File.unlink(@png_file) if File.exist?(@png_file)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_rrd_manipulation
|
19
|
+
assert_nothing_raised do
|
20
|
+
RRD.create(
|
21
|
+
@rrd_file,
|
22
|
+
"--start", "#{@start_time - 1}",
|
23
|
+
"--step", "300",
|
24
|
+
"DS:a:GAUGE:600:U:U",
|
25
|
+
"DS:b:GAUGE:600:U:U",
|
26
|
+
"RRA:AVERAGE:0.5:1:300"
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
assert_nothing_raised do
|
31
|
+
@start_time.step(@end_time, 300) do |i|
|
32
|
+
RRD.update(@rrd_file, "#{i}:#{rand(100)}:#{Math.sin(i / 800) * 50 + 50}")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
(fstart, fend, data) = RRD.fetch(@rrd_file, "--start", @start_time.to_s, "--end",
|
38
|
+
@end_time.to_s, "AVERAGE")
|
39
|
+
|
40
|
+
assert_equal(1295046000, fstart)
|
41
|
+
assert_equal(1295136300, fend)
|
42
|
+
assert_equal(['a', 'b'], data)
|
43
|
+
|
44
|
+
assert_nothing_raised do
|
45
|
+
RRD.graph(
|
46
|
+
@png_file,
|
47
|
+
"--title", " RubyRRD Demo",
|
48
|
+
"--start", "#{@start_time + 3600}",
|
49
|
+
"--end", "start + 1000 min",
|
50
|
+
"--interlace",
|
51
|
+
"--imgformat", "PNG",
|
52
|
+
"--width=450",
|
53
|
+
"DEF:a=#{@rrd_file}:a:AVERAGE",
|
54
|
+
"DEF:b=#{@rrd_file}:b:AVERAGE",
|
55
|
+
"CDEF:line=TIME,2400,%,300,LT,a,UNKN,IF",
|
56
|
+
"AREA:b#00b6e4:beta",
|
57
|
+
"AREA:line#0022e9:alpha",
|
58
|
+
"LINE3:line#ff0000"
|
59
|
+
)
|
60
|
+
end
|
61
|
+
assert(File.exist?(@png_file))
|
62
|
+
|
63
|
+
assert_equal(@end_time, RRD.last(@rrd_file).to_i)
|
64
|
+
|
65
|
+
if RRD.respond_to?(:xport)
|
66
|
+
assert_nothing_raised do
|
67
|
+
fstart, fend, step, col, legend, data = RRD.xport(
|
68
|
+
"--start", start_time.to_s,
|
69
|
+
"--end", (start_time + 300 * 300).to_s,
|
70
|
+
"--step", 10.to_s,
|
71
|
+
"DEF:A=#{rrd}:a:AVERAGE",
|
72
|
+
"DEF:B=#{rrd}:b:AVERAGE",
|
73
|
+
"XPORT:A:a",
|
74
|
+
"XPORT:B:b"
|
75
|
+
)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
metadata
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
name: librrd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
hash: 23
|
5
|
-
prerelease:
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
|
+
- 1
|
7
8
|
- 0
|
8
|
-
- 2
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 1.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bernd Ahlers
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-15 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -43,8 +43,10 @@ files:
|
|
43
43
|
- ext/librrd/1.3/main.c
|
44
44
|
- ext/librrd/1.4/main.c
|
45
45
|
- ext/librrd/extconf.rb
|
46
|
+
- lib/librrd.rb
|
46
47
|
- librrd.gemspec
|
47
|
-
- test.rb
|
48
|
+
- test/test_librrd.rb
|
49
|
+
- test/test_rrd.rb
|
48
50
|
has_rdoc: true
|
49
51
|
homepage: http://github.com/bernd/librrd-ruby
|
50
52
|
licenses: []
|
@@ -54,6 +56,7 @@ rdoc_options:
|
|
54
56
|
- --charset=UTF-8
|
55
57
|
require_paths:
|
56
58
|
- ext
|
59
|
+
- lib
|
57
60
|
required_ruby_version: !ruby/object:Gem::Requirement
|
58
61
|
none: false
|
59
62
|
requirements:
|
@@ -75,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
78
|
requirements: []
|
76
79
|
|
77
80
|
rubyforge_project:
|
78
|
-
rubygems_version: 1.
|
81
|
+
rubygems_version: 1.4.2
|
79
82
|
signing_key:
|
80
83
|
specification_version: 2
|
81
84
|
summary: Ruby bindings for librrd
|
data/test.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# $Id: test.rb,v 1.2 2002/10/22 17:34:00 miles Exp $
|
3
|
-
# Driver does not carry cash.
|
4
|
-
|
5
|
-
$: << '/scratch/rrd12build/lib/ruby/1.8/i386-linux/'
|
6
|
-
|
7
|
-
require "RRD"
|
8
|
-
|
9
|
-
name = "test"
|
10
|
-
rrd = "#{name}.rrd"
|
11
|
-
start_time = Time.now.to_i
|
12
|
-
end_time = start_time.to_i + 300 * 300
|
13
|
-
|
14
|
-
puts "creating #{rrd}"
|
15
|
-
RRD.create(
|
16
|
-
rrd,
|
17
|
-
"--start", "#{start_time - 1}",
|
18
|
-
"--step", "300",
|
19
|
-
"DS:a:GAUGE:600:U:U",
|
20
|
-
"DS:b:GAUGE:600:U:U",
|
21
|
-
"RRA:AVERAGE:0.5:1:300")
|
22
|
-
puts
|
23
|
-
|
24
|
-
puts "updating #{rrd}"
|
25
|
-
start_time.step(end_time, 300) { |i|
|
26
|
-
RRD.update(rrd, "#{i}:#{rand(100)}:#{Math.sin(i / 800) * 50 + 50}")
|
27
|
-
}
|
28
|
-
puts
|
29
|
-
|
30
|
-
puts "fetching data from #{rrd}"
|
31
|
-
(fstart, fend, data) = RRD.fetch(rrd, "--start", start_time.to_s, "--end", end_time.to_s, "AVERAGE")
|
32
|
-
puts "got #{data.length} data points from #{fstart} to #{fend}"
|
33
|
-
puts
|
34
|
-
|
35
|
-
puts "generating graph #{name}.png"
|
36
|
-
RRD.graph(
|
37
|
-
"#{name}.png",
|
38
|
-
"--title", " RubyRRD Demo",
|
39
|
-
"--start", "#{start_time+3600}",
|
40
|
-
"--end", "start + 1000 min",
|
41
|
-
"--interlace",
|
42
|
-
"--imgformat", "PNG",
|
43
|
-
"--width=450",
|
44
|
-
"DEF:a=#{rrd}:a:AVERAGE",
|
45
|
-
"DEF:b=#{rrd}:b:AVERAGE",
|
46
|
-
"CDEF:line=TIME,2400,%,300,LT,a,UNKN,IF",
|
47
|
-
"AREA:b#00b6e4:beta",
|
48
|
-
"AREA:line#0022e9:alpha",
|
49
|
-
"LINE3:line#ff0000")
|
50
|
-
puts
|
51
|
-
|
52
|
-
# last method test
|
53
|
-
if end_time != RRD.last("#{rrd}").to_i
|
54
|
-
puts "last method expects #{Time.at(end_time)}."
|
55
|
-
puts " But #{RRD.last("#{rrd}")} returns."
|
56
|
-
end
|
57
|
-
puts
|
58
|
-
|
59
|
-
# xport method test
|
60
|
-
if RRD.respond_to?(:xport)
|
61
|
-
puts "xporting data from #{rrd}"
|
62
|
-
(fstart,fend,step,col,legend,data)=RRD.xport(
|
63
|
-
"--start", start_time.to_s,
|
64
|
-
"--end", (start_time + 300 * 300).to_s,
|
65
|
-
"--step", 10.to_s,
|
66
|
-
"DEF:A=#{rrd}:a:AVERAGE",
|
67
|
-
"DEF:B=#{rrd}:b:AVERAGE",
|
68
|
-
"XPORT:A:a",
|
69
|
-
"XPORT:B:b")
|
70
|
-
puts "Xported #{col} columns(#{legend.join(", ")}) with #{data.length} rows from #{fstart} to #{fend} and step #{step}\n"
|
71
|
-
else
|
72
|
-
puts "Skipping xport test, method not available."
|
73
|
-
end
|
74
|
-
|
75
|
-
print "This script has created #{name}.png in the current directory\n";
|
76
|
-
print "This demonstrates the use of the TIME and % RPN operators\n";
|