errand 0.8.0 → 0.8.1
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.
- data/CHANGELOG.md +4 -1
- data/Gemfile.lock +4 -4
- data/LICENCE +20 -0
- data/README.md +93 -64
- data/lib/errand.rb +4 -0
- data/lib/errand/version.rb +1 -1
- data/spec/errand_spec.rb +26 -2
- metadata +7 -3
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
0.8.1 - 2014/02/21
|
2
|
+
- Feature: Add support for retrieving the first available metric in an RRD - @jessereynolds
|
3
|
+
|
1
4
|
0.8.0 - 2013/02/23
|
2
|
-
- Chore: switched from using librrd-ruby to rrd-ffi, to be more portable
|
5
|
+
- Chore: switched from using librrd-ruby to rrd-ffi, to be more portable - @auxesis
|
3
6
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
errand (0.8.
|
4
|
+
errand (0.8.1)
|
5
5
|
rrd-ffi (= 0.2.13)
|
6
6
|
|
7
7
|
GEM
|
@@ -12,9 +12,9 @@ GEM
|
|
12
12
|
multi_json (~> 1.0)
|
13
13
|
colorize (0.5.8)
|
14
14
|
diff-lcs (1.1.3)
|
15
|
-
ffi (1.
|
16
|
-
i18n (0.6.
|
17
|
-
multi_json (1.
|
15
|
+
ffi (1.9.3)
|
16
|
+
i18n (0.6.4)
|
17
|
+
multi_json (1.8.2)
|
18
18
|
rake (0.8.7)
|
19
19
|
rrd-ffi (0.2.13)
|
20
20
|
activesupport
|
data/LICENCE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011-2014 Lindsay Holmwood
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,100 +1,129 @@
|
|
1
|
-
Errand
|
2
|
-
======
|
1
|
+
# Errand
|
3
2
|
|
4
|
-
Errand provides Ruby bindings for RRD functions (via librrd), and a clear
|
5
|
-
API for interacting with RRDs.
|
3
|
+
Errand provides Ruby bindings for RRD functions (via librrd), and a clear API for interacting with RRDs.
|
6
4
|
|
7
|
-
|
5
|
+
## Installing
|
8
6
|
|
9
|
-
|
10
|
-
=====
|
7
|
+
Install Errand via RubyGems:
|
11
8
|
|
12
|
-
|
9
|
+
```
|
10
|
+
gem install errand
|
11
|
+
```
|
13
12
|
|
14
|
-
|
13
|
+
Or adding do your Gemfile:
|
14
|
+
|
15
|
+
```
|
16
|
+
gem 'errand'
|
17
|
+
```
|
18
|
+
|
19
|
+
## Using
|
20
|
+
|
21
|
+
To start working with an RRD:
|
22
|
+
|
23
|
+
``` ruby
|
24
|
+
@rrd = Errand.new(:filename => "data.rrd")
|
25
|
+
```
|
26
|
+
|
27
|
+
This will either read an existing RRD, or stub out the bits to create a new one.
|
15
28
|
|
16
29
|
To create an RRD:
|
17
30
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
31
|
+
``` ruby
|
32
|
+
options = {
|
33
|
+
:sources => [
|
34
|
+
{
|
35
|
+
:name => "Counter",
|
36
|
+
:type => :counter,
|
37
|
+
:heartbeat => 1800,
|
38
|
+
:min => 0,
|
39
|
+
:max => 4294967295
|
40
|
+
}
|
41
|
+
],
|
42
|
+
:archives => [
|
43
|
+
{
|
44
|
+
:function => :average,
|
45
|
+
:xff => 0.5,
|
46
|
+
:steps => 1,
|
47
|
+
:rows => 2400
|
48
|
+
}
|
49
|
+
]
|
50
|
+
}
|
22
51
|
|
23
|
-
|
52
|
+
@rrd.create(options)
|
53
|
+
```
|
24
54
|
|
25
|
-
|
55
|
+
To update said RRD:
|
26
56
|
|
27
|
-
|
57
|
+
``` ruby
|
58
|
+
@rrd.update(:sources => [{:name => "Counter", :value => 1}]
|
59
|
+
```
|
28
60
|
|
29
|
-
|
30
|
-
:data => {"Counter" => [nil, nil, nil, 1]}
|
61
|
+
To fetch that data:
|
31
62
|
|
32
|
-
|
33
|
-
|
63
|
+
``` ruby
|
64
|
+
@rrd.fetch # <= {:start => Time, :end => Time,
|
65
|
+
:data => {"Counter" => [nil, nil, nil, 1]}
|
66
|
+
```
|
34
67
|
|
35
|
-
|
36
|
-
as rrddump are only available with the latest RRDtool.
|
68
|
+
Check under `spec/` for more usage examples.
|
37
69
|
|
38
|
-
|
39
|
-
to go.
|
70
|
+
## Developing
|
40
71
|
|
41
|
-
|
72
|
+
Clone the repository:
|
42
73
|
|
43
|
-
|
44
|
-
|
45
|
-
|
74
|
+
```
|
75
|
+
git clone git@github.com:auxesis/errand.git
|
76
|
+
```
|
46
77
|
|
47
|
-
|
48
|
-
doesn't, please report bugs at [http://github.com/eric/rubyrrdtool/issues](http://github.com/eric/rubyrrdtool/issues)!
|
78
|
+
Suck down all the dependencies:
|
49
79
|
|
50
|
-
|
51
|
-
|
80
|
+
``` bash
|
81
|
+
cd errand
|
82
|
+
bundle
|
83
|
+
```
|
52
84
|
|
53
|
-
|
85
|
+
### Dependencies
|
54
86
|
|
55
|
-
|
87
|
+
Errand requires RRDtool version 1.2 or later. Some RRD functions such
|
88
|
+
as rrddump are only available with the latest RRDtool.
|
56
89
|
|
57
|
-
|
90
|
+
Installation is standard. If you've installed the gem, you should be ready
|
91
|
+
to go.
|
58
92
|
|
59
|
-
|
93
|
+
Otherwise, simply run:
|
94
|
+
|
95
|
+
``` bash
|
96
|
+
ruby extconf.rb
|
97
|
+
make
|
98
|
+
make install
|
99
|
+
```
|
60
100
|
|
61
|
-
|
62
|
-
|
101
|
+
This should build a library named `rrd.so` in the current directory. If it
|
102
|
+
doesn't, please report bugs at [http://github.com/eric/rubyrrdtool/issues](http://github.com/eric/rubyrrdtool/issues)!
|
63
103
|
|
64
|
-
Testing is done with RSpec.
|
65
104
|
|
66
|
-
|
105
|
+
### Testing
|
67
106
|
|
68
|
-
|
107
|
+
Testing is done with RSpec.
|
69
108
|
|
70
|
-
|
71
|
-
====
|
109
|
+
To run tests:
|
72
110
|
|
73
|
-
|
111
|
+
``` bash
|
112
|
+
rake spec
|
113
|
+
```
|
74
114
|
|
115
|
+
### Building the gem
|
75
116
|
|
76
|
-
|
77
|
-
=======
|
117
|
+
Build the gem:
|
78
118
|
|
79
|
-
|
119
|
+
``` bash
|
120
|
+
rake build
|
121
|
+
```
|
80
122
|
|
81
|
-
|
123
|
+
## TODO
|
82
124
|
|
83
|
-
|
84
|
-
a copy of this software and associated documentation files (the
|
85
|
-
"Software"), to deal in the Software without restriction, including
|
86
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
87
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
88
|
-
permit persons to whom the Software is furnished to do so, subject to
|
89
|
-
the following conditions:
|
125
|
+
* Extend documentation with more examples
|
90
126
|
|
91
|
-
|
92
|
-
included in all copies or substantial portions of the Software.
|
127
|
+
## License
|
93
128
|
|
94
|
-
|
95
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
96
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
97
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
98
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
99
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
100
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
129
|
+
Errand is distributed under the MIT license.
|
data/lib/errand.rb
CHANGED
data/lib/errand/version.rb
CHANGED
data/spec/errand_spec.rb
CHANGED
@@ -14,6 +14,19 @@ describe Errand do
|
|
14
14
|
@rrd = Errand.new(:filename => File.join(@tmpdir, 'test.rrd'))
|
15
15
|
end
|
16
16
|
|
17
|
+
def create_simple_test_rrd(time)
|
18
|
+
@rrd.create(:start => time - 1, :step => 1,
|
19
|
+
:sources => [
|
20
|
+
{:name => "Sum", :type => :gauge, :heartbeat => 1800, :min => 0, :max => 4294967295},
|
21
|
+
{:name => "Total", :type => :gauge, :heartbeat => 1800, :min => 0, :max => 'U'} ],
|
22
|
+
:archives => [
|
23
|
+
{:function => :average, :xff => 0.5, :steps => 1, :rows => 2400}]).should be_true
|
24
|
+
|
25
|
+
@rrd.update(:sources => [
|
26
|
+
{:name => "Sum", :time => time, :value => 1},
|
27
|
+
{:name => "Total", :time => time, :value => 30}]).should be_true
|
28
|
+
end
|
29
|
+
|
17
30
|
it "should create data" do
|
18
31
|
|
19
32
|
@rrd.create(:start => Time.now.to_i - 1, :step => 300,
|
@@ -125,7 +138,18 @@ describe Errand do
|
|
125
138
|
end
|
126
139
|
end
|
127
140
|
|
128
|
-
it "should return timestamp of first value"
|
129
|
-
|
141
|
+
it "should return timestamp of first value" do
|
142
|
+
time = Time.now.to_i
|
143
|
+
create_simple_test_rrd(time)
|
144
|
+
# FIXME: the first update time is coming back as T minus 40 minutes, don't know why
|
145
|
+
#@rrd.first.should eq(time - 1)
|
146
|
+
@rrd.first.should be_a(Integer)
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should return timestamp of last value" do
|
150
|
+
time = Time.now.to_i
|
151
|
+
create_simple_test_rrd(time)
|
152
|
+
@rrd.last.should eq(time)
|
153
|
+
end
|
130
154
|
|
131
155
|
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.8.
|
4
|
+
version: 0.8.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-02-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rrd-ffi
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- CHANGELOG.md
|
91
91
|
- Gemfile
|
92
92
|
- Gemfile.lock
|
93
|
+
- LICENCE
|
93
94
|
- README.md
|
94
95
|
- Rakefile
|
95
96
|
- VERSION
|
@@ -123,4 +124,7 @@ rubygems_version: 1.8.23
|
|
123
124
|
signing_key:
|
124
125
|
specification_version: 3
|
125
126
|
summary: Ruby language binding for RRD tool version 1.2+
|
126
|
-
test_files:
|
127
|
+
test_files:
|
128
|
+
- spec/errand_spec.rb
|
129
|
+
- spec/spec.opts
|
130
|
+
- test/test_rrdtool.rb
|