errand 0.7.4 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -7,4 +7,3 @@ pkg
7
7
  *.gem
8
8
  *.o
9
9
  *.so
10
- errand.gemspec
@@ -1 +1 @@
1
- 1.9.3-p0
1
+ 1.9.3-p125
@@ -1,4 +1,3 @@
1
- 0.7.4 - 2013/02/22
2
- - Chore: switched from using system package manager RRDtool to librrd-ruby
3
- - Chore: remove use of Jeweler
1
+ 0.8.0 - 2013/02/23
2
+ - Chore: switched from using librrd-ruby to rrd-ffi, to be more portable
4
3
 
data/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- source :rubygems
3
+ source 'http://rubygems.org'
4
4
 
5
5
  gemspec
@@ -1,16 +1,24 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- errand (0.7.4)
5
- librrd (= 1.0.3)
4
+ errand (0.8.0)
5
+ rrd-ffi (= 0.2.13)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
+ activesupport (3.2.12)
11
+ i18n (~> 0.6)
12
+ multi_json (~> 1.0)
10
13
  colorize (0.5.8)
11
14
  diff-lcs (1.1.3)
12
- librrd (1.0.3)
15
+ ffi (1.4.0)
16
+ i18n (0.6.1)
17
+ multi_json (1.6.1)
13
18
  rake (0.8.7)
19
+ rrd-ffi (0.2.13)
20
+ activesupport
21
+ ffi
14
22
  rspec (2.9.0)
15
23
  rspec-core (~> 2.9.0)
16
24
  rspec-expectations (~> 2.9.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.3
1
+ 0.7.4
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "errand/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "errand"
7
+ s.version = Errand::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = [ "Lindsay Holmwood" ]
10
+ s.email = [ "lindsay@holmwood.id.au" ]
11
+ s.homepage = "https://github.com/auxesis/errand"
12
+ s.summary = "Ruby language binding for RRD tool version 1.2+"
13
+ s.description = "Errand provides Ruby bindings for RRD functions (via rrd-ffi), and a concise DSL for interacting with RRDs."
14
+
15
+ s.rubyforge_project = "errand"
16
+
17
+ s.required_ruby_version = ">= 1.8.7"
18
+ s.required_rubygems_version = ">= 1.3.6"
19
+
20
+ s.files = `git ls-files`.split("\n")
21
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
+ s.require_paths = ["lib"]
24
+
25
+ s.add_runtime_dependency "rrd-ffi", "= 0.2.13"
26
+ s.add_development_dependency "rake", ">= 0"
27
+ s.add_development_dependency "rspec", ">= 0"
28
+ s.add_development_dependency "colorize", ">= 0"
29
+ end
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  # Attempt to load the native RRD library provided by the operating system.
4
- require 'RRD'
4
+ require 'rrd'
5
5
 
6
6
  # Errand:
7
7
  # Wraps the RRD Ruby library provided by your distribution's package manager,
@@ -11,7 +11,7 @@ class Errand
11
11
  def initialize(opts={})
12
12
  raise ArgumentError unless opts[:filename]
13
13
  @filename = opts[:filename]
14
- @backend = ::RRD
14
+ @backend = ::RRD::Wrapper
15
15
  end
16
16
 
17
17
  def dump(opts={})
@@ -24,28 +24,26 @@ class Errand
24
24
  end
25
25
 
26
26
  def fetch(opts={})
27
- start = (opts[:start] || Time.now.to_i - 3600).to_s
28
- finish = (opts[:finish] || Time.now.to_i).to_s
27
+ start = (opts[:start] || Time.now.to_i - 3600).to_s
28
+ finish = (opts[:finish] || Time.now.to_i).to_s
29
29
  function = opts[:function] ? opts[:function].to_s.upcase : "AVERAGE"
30
30
 
31
- args = [@filename, "--start", start, "--end", finish, function]
31
+ args = [ @filename, function, "--start", start, "--end", finish ]
32
32
 
33
- data = @backend.fetch(*args)
34
- start = data[0]
35
- finish = data[1]
36
- labels = data[2]
37
- values = data[3]
33
+ data = @backend.fetch(*args)
34
+ labels = data.shift
38
35
  points = {}
39
36
 
40
- # compose a saner representation of the data
41
37
  labels.each_with_index do |label, index|
42
38
  points[label] = []
43
- values.each do |tuple|
44
- value = tuple[index].nan? ? nil : tuple[index]
39
+ data.each do |tuple|
40
+ value = tuple[index]
45
41
  points[label] << value
46
42
  end
47
43
  end
48
44
 
45
+ points.delete('time')
46
+
49
47
  {:start => start, :finish => finish, :data => points}
50
48
  end
51
49
 
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  class Errand
4
- VERSION = "0.7.4"
4
+ VERSION = "0.8.0"
5
5
  end
@@ -1,57 +1,80 @@
1
- #!/usr/bin/env ruby
1
+ #!/usr/bin/env ruby
2
2
 
3
3
  $: << File.expand_path(File.join(File.dirname(__FILE__), '..'))
4
4
  require 'lib/errand'
5
5
  require 'tmpdir'
6
6
 
7
- describe Errand do
7
+ describe Errand do
8
8
 
9
9
  before(:all) do
10
10
  @tmpdir = Dir.mktmpdir
11
11
  end
12
12
 
13
- before(:each) do
13
+ before(:each) do
14
14
  @rrd = Errand.new(:filename => File.join(@tmpdir, 'test.rrd'))
15
15
  end
16
16
 
17
- it "should create data" do
17
+ it "should create data" do
18
18
 
19
- @rrd.create(:start => Time.now.to_i - 1, :step => 300,
20
- :sources => [
19
+ @rrd.create(:start => Time.now.to_i - 1, :step => 300,
20
+ :sources => [
21
21
  {:name => "Counter", :type => :counter, :heartbeat => 1800, :min => 0, :max => 4294967295},
22
22
  {:name => "Total", :type => :derive, :heartbeat => 1800, :min => 0, :max => 'U'} ],
23
23
  :archives => [
24
24
  {:function => :average, :xff => 0.5, :steps => 1, :rows => 2400}]).should be_true
25
-
25
+
26
26
  sources = @rrd.info.keys.grep(/^ds\[/).map { |ds| ds[3..-1].split(']').first}.uniq
27
27
  sources.size.should == 2
28
28
 
29
29
  end
30
30
 
31
31
  it "should dump data" do
32
- @rrd.create(:start => Time.now.to_i - 1, :step => 300,
33
- :sources => [
32
+ @rrd.create(:start => Time.now.to_i - 1, :step => 300,
33
+ :sources => [
34
34
  {:name => "Counter", :type => :counter, :heartbeat => 1800, :min => 0, :max => 4294967295},
35
35
  {:name => "Total", :type => :derive, :heartbeat => 1800, :min => 0, :max => 'U'} ],
36
36
  :archives => [
37
37
  {:function => :average, :xff => 0.5, :steps => 1, :rows => 2400}]).should be_true
38
-
38
+
39
39
  tmpfile = File.join(@tmpdir, 'test.out')
40
40
  lambda {
41
41
  @rrd.dump(:filename => tmpfile)
42
- @rrd.dump # <= no args
42
+ @rrd.dump # <= no args
43
43
  }.should_not raise_error
44
44
  end
45
45
 
46
- it "should update rrds" do
47
- @rrd.create(:start => Time.now.to_i - 1, :step => 1,
48
- :sources => [
49
- {:name => "Sum", :type => :gauge, :heartbeat => 1800, :min => 0, :max => 4294967295},
50
- {:name => "Total", :type => :gauge, :heartbeat => 1800, :min => 0, :max => 'U'} ],
51
- :archives => [
52
- {:function => :average, :xff => 0.5, :steps => 1, :rows => 2400}]).should be_true
53
-
54
- @rrd.update(:sources => [
46
+ it "should update rrds" do
47
+ attrs = {
48
+ :start => Time.now.to_i - 1,
49
+ :step => 1,
50
+ :sources => [
51
+ {
52
+ :name => "Sum",
53
+ :type => :gauge,
54
+ :heartbeat => 1800,
55
+ :min => 0,
56
+ :max => 4294967295
57
+ },
58
+ {
59
+ :name => "Total",
60
+ :type => :gauge,
61
+ :heartbeat => 1800,
62
+ :min => 0,
63
+ :max => 'U'
64
+ }
65
+ ],
66
+ :archives => [
67
+ {
68
+ :function => :average,
69
+ :xff => 0.5,
70
+ :steps => 1,
71
+ :rows => 2400
72
+ }
73
+ ]
74
+ }
75
+ @rrd.create(attrs).should be_true
76
+
77
+ @rrd.update(:sources => [
55
78
  {:name => "Sum", :value => 1},
56
79
  {:name => "Total", :value => 30}]).should be_true
57
80
 
@@ -60,10 +83,10 @@ describe Errand do
60
83
  end
61
84
  end
62
85
 
63
- it "should update with weird data" do
86
+ it "should update with weird data" do
64
87
  time = Time.now.to_i - 300
65
- @rrd.create(:start => time - 1, :step => 1,
66
- :sources => [
88
+ @rrd.create(:start => time - 1, :step => 1,
89
+ :sources => [
67
90
  {:name => "Sum", :type => :gauge, :heartbeat => 1800, :min => 0, :max => 4294967295},
68
91
  {:name => "Total", :type => :gauge, :heartbeat => 1800, :min => 0, :max => 'U'} ],
69
92
  :archives => [
@@ -74,9 +97,9 @@ describe Errand do
74
97
  updates << {:name => "Sum", :time => time + i , :value => 1}
75
98
  updates << {:name => "Total", :time => time + i * 4, :value => 30}
76
99
  end
77
-
100
+
78
101
  @rrd.update(:sources => updates)
79
-
102
+
80
103
  @rrd.fetch[:data].each_pair do |source, values|
81
104
  values.compact.size.should > 0
82
105
  end
@@ -84,15 +107,15 @@ describe Errand do
84
107
 
85
108
  it "should fetch data" do
86
109
  time = Time.now.to_i - 300
87
- @rrd.create(:start => time - 1, :step => 1,
88
- :sources => [
110
+ @rrd.create(:start => time - 1, :step => 1,
111
+ :sources => [
89
112
  {:name => "Sum", :type => :gauge, :heartbeat => 1800, :min => 0, :max => 4294967295},
90
113
  {:name => "Total", :type => :gauge, :heartbeat => 1800, :min => 0, :max => 'U'} ],
91
114
  :archives => [
92
115
  {:function => :average, :xff => 0.5, :steps => 1, :rows => 2400}]).should be_true
93
116
 
94
117
  100.times do |i|
95
- @rrd.update(:sources => [
118
+ @rrd.update(:sources => [
96
119
  {:name => "Sum", :time => time + i, :value => 1},
97
120
  {:name => "Total", :time => time + i, :value => 30}]).should be_true
98
121
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: errand
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.8.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,27 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-22 00:00:00.000000000 Z
12
+ date: 2013-02-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: librrd
16
- requirement: &10134780 !ruby/object:Gem::Requirement
15
+ name: rrd-ffi
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - =
19
+ - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.0.3
21
+ version: 0.2.13
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *10134780
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.2.13
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rake
27
- requirement: &10145700 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *10145700
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rspec
38
- requirement: &10144440 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *10144440
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: colorize
49
- requirement: &10160900 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,9 +69,14 @@ dependencies:
54
69
  version: '0'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *10160900
58
- description: Errand provides Ruby bindings for RRD functions (via librrd), and a concise
59
- DSL for interacting with RRDs.
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Errand provides Ruby bindings for RRD functions (via rrd-ffi), and a
79
+ concise DSL for interacting with RRDs.
60
80
  email:
61
81
  - lindsay@holmwood.id.au
62
82
  executables: []
@@ -73,12 +93,13 @@ files:
73
93
  - README.md
74
94
  - Rakefile
75
95
  - VERSION
96
+ - errand.gemspec
76
97
  - lib/errand.rb
77
98
  - lib/errand/version.rb
78
99
  - spec/errand_spec.rb
79
100
  - spec/spec.opts
80
101
  - test/test_rrdtool.rb
81
- homepage: http://auxesis.github.com/errand
102
+ homepage: https://github.com/auxesis/errand
82
103
  licenses: []
83
104
  post_install_message:
84
105
  rdoc_options: []
@@ -97,8 +118,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
118
  - !ruby/object:Gem::Version
98
119
  version: 1.3.6
99
120
  requirements: []
100
- rubyforge_project:
101
- rubygems_version: 1.8.11
121
+ rubyforge_project: errand
122
+ rubygems_version: 1.8.23
102
123
  signing_key:
103
124
  specification_version: 3
104
125
  summary: Ruby language binding for RRD tool version 1.2+