astro-collectd 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/collectd/em_support.rb +2 -2
- data/lib/collectd/interface.rb +3 -3
- data/lib/collectd/pkt.rb +6 -2
- data/lib/collectd/server.rb +1 -1
- data/spec/interface_spec.rb +4 -4
- metadata +7 -7
- data/README.rst +0 -83
data/VERSION.yml
CHANGED
data/lib/collectd/em_support.rb
CHANGED
@@ -7,10 +7,10 @@ module Collectd
|
|
7
7
|
def track_deferrable(name, deferrable)
|
8
8
|
attach_time = Time.now
|
9
9
|
deferrable.callback do |*a|
|
10
|
-
push_deferrable_values("#{name}
|
10
|
+
push_deferrable_values("#{name}_success", attach_time)
|
11
11
|
end
|
12
12
|
deferrable.errback do |*a|
|
13
|
-
push_deferrable_values("#{name}
|
13
|
+
push_deferrable_values("#{name}_error", attach_time)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
def push_deferrable_values(name, attach_time)
|
data/lib/collectd/interface.rb
CHANGED
@@ -151,7 +151,7 @@ module Collectd
|
|
151
151
|
# Use count & sums for average
|
152
152
|
if @gauges.has_key?(plugin_type)
|
153
153
|
old_values = @gauges[plugin_type]
|
154
|
-
count = old_values.shift
|
154
|
+
count = old_values.shift || 0
|
155
155
|
values.map! { |value| value + (old_values.shift || value) }
|
156
156
|
@gauges[plugin_type] = [count + 1] + values
|
157
157
|
else
|
@@ -174,10 +174,10 @@ module Collectd
|
|
174
174
|
plugin_type_values[plugin] ||= {}
|
175
175
|
plugin_type_values[plugin][plugin_instance] ||= {}
|
176
176
|
plugin_type_values[plugin][plugin_instance][type] ||= {}
|
177
|
-
count = values.shift
|
177
|
+
count = values.shift || next
|
178
178
|
values.map! { |value| value.to_f / count }
|
179
179
|
plugin_type_values[plugin][plugin_instance][type][type_instance] =
|
180
|
-
|
180
|
+
Packet::Values.new(values.map { |value| Packet::Values::Gauge.new(value) })
|
181
181
|
end
|
182
182
|
pkt = [Packet::Host.new(Collectd.hostname),
|
183
183
|
Packet::Time.new(Time.now.to_i),
|
data/lib/collectd/pkt.rb
CHANGED
data/lib/collectd/server.rb
CHANGED
data/spec/interface_spec.rb
CHANGED
@@ -118,12 +118,12 @@ describe Collectd::EmPlugin do
|
|
118
118
|
end
|
119
119
|
it 'should report latency' do
|
120
120
|
@df.succeed
|
121
|
-
g = @server.gauges[[:plugin1, :plugin_instance1, :latency, '
|
121
|
+
g = @server.gauges[[:plugin1, :plugin_instance1, :latency, 'df_success']]
|
122
122
|
g[0].should be_kind_of(Numeric)
|
123
123
|
end
|
124
124
|
it 'should increase a counter' do
|
125
125
|
@df.succeed
|
126
|
-
c = @server.counters[[:plugin1, :plugin_instance1, :counter, '
|
126
|
+
c = @server.counters[[:plugin1, :plugin_instance1, :counter, 'df_success']]
|
127
127
|
c[0].should be_kind_of(Numeric)
|
128
128
|
end
|
129
129
|
end
|
@@ -133,12 +133,12 @@ describe Collectd::EmPlugin do
|
|
133
133
|
end
|
134
134
|
it 'should report latency' do
|
135
135
|
@df.fail
|
136
|
-
g = @server.gauges[[:plugin1, :plugin_instance1, :latency, '
|
136
|
+
g = @server.gauges[[:plugin1, :plugin_instance1, :latency, 'df_error']]
|
137
137
|
g[0].should be_kind_of(Numeric)
|
138
138
|
end
|
139
139
|
it 'should increase a counter' do
|
140
140
|
@df.fail
|
141
|
-
c = @server.counters[[:plugin1, :plugin_instance1, :counter, '
|
141
|
+
c = @server.counters[[:plugin1, :plugin_instance1, :counter, 'df_error']]
|
142
142
|
c[0].should be_kind_of(Numeric)
|
143
143
|
end
|
144
144
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: astro-collectd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephan Maka
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-19 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -19,10 +19,9 @@ executables: []
|
|
19
19
|
|
20
20
|
extensions: []
|
21
21
|
|
22
|
-
extra_rdoc_files:
|
23
|
-
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
24
|
files:
|
25
|
-
- README.rst
|
26
25
|
- Rakefile
|
27
26
|
- VERSION.yml
|
28
27
|
- examples/em_sender.rb
|
@@ -37,6 +36,7 @@ files:
|
|
37
36
|
- spec/interface_spec.rb
|
38
37
|
has_rdoc: false
|
39
38
|
homepage: http://github.com/astro/ruby-collectd
|
39
|
+
licenses:
|
40
40
|
post_install_message:
|
41
41
|
rdoc_options:
|
42
42
|
- --charset=UTF-8
|
@@ -57,11 +57,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements: []
|
58
58
|
|
59
59
|
rubyforge_project:
|
60
|
-
rubygems_version: 1.
|
60
|
+
rubygems_version: 1.3.5
|
61
61
|
signing_key:
|
62
62
|
specification_version: 3
|
63
63
|
summary: Send collectd statistics from Ruby
|
64
64
|
test_files:
|
65
65
|
- spec/interface_spec.rb
|
66
|
-
- examples/sender.rb
|
67
66
|
- examples/em_sender.rb
|
67
|
+
- examples/sender.rb
|
data/README.rst
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
collectd Data Model
|
2
|
-
-------------------
|
3
|
-
|
4
|
-
Collectd groups data by **six categories:**
|
5
|
-
|
6
|
-
* *hostname* is grabbed from `hostname -f`
|
7
|
-
* *plugin* is the application's name
|
8
|
-
* *plugin-instance* is passed from the programs' side with the
|
9
|
-
programs instance identifier, useful if you're running the same
|
10
|
-
script twice (PIDs are quite too random)
|
11
|
-
* *type* is the kind of data you are measuring and must be defined in
|
12
|
-
types.db_ for collectd to understand
|
13
|
-
* *type-instance* provides further distinction and have no relation to
|
14
|
-
other type-instances. Multiple type-instances are only rendered into
|
15
|
-
one graph by collection3 if defined with module GenericStacked.
|
16
|
-
* *values* are one or more field names and types belonging
|
17
|
-
together. The exact amount of fields and their corresponding names
|
18
|
-
(useful to collection3) are specified in collectd's types.db_.
|
19
|
-
|
20
|
-
A value can be either of **two types:**
|
21
|
-
|
22
|
-
* *COUNTER* is for increasing counters where you want to plot the
|
23
|
-
delta. Network interface traffic counters are a good example.
|
24
|
-
* *GAUGE* is values that go up and down to be plotted as-is, like a
|
25
|
-
temperature graph.
|
26
|
-
|
27
|
-
|
28
|
-
Usage
|
29
|
-
-----
|
30
|
-
|
31
|
-
::
|
32
|
-
|
33
|
-
gem 'astro-collectd'
|
34
|
-
require 'collectd'
|
35
|
-
|
36
|
-
First of all, specify a server to send data to:
|
37
|
-
|
38
|
-
::
|
39
|
-
|
40
|
-
Collectd.add_server(interval, addr='ff18::efc0:4a42', port=25826)
|
41
|
-
|
42
|
-
Each server definition you add will receive all the data you push to
|
43
|
-
later. An interval of 10 is quite reasonable. Because of UDP and some
|
44
|
-
buffering in collectd, an interval of 1 seconds shouldn't hurt either.
|
45
|
-
|
46
|
-
All the identifiers from above can be given free form with some
|
47
|
-
method_missing stuff. Like this:
|
48
|
-
|
49
|
-
::
|
50
|
-
|
51
|
-
# Set gauge absolutely
|
52
|
-
Collectd.plugin(:plugin_instance).type(:type_instance).gauge = 23
|
53
|
-
|
54
|
-
# Increase counter relatively (collectd caches counters)
|
55
|
-
Collectd.plugin(:plugin_instance).type(:type_instance).count! 5
|
56
|
-
|
57
|
-
# Set counter absolutely
|
58
|
-
Collectd.plugin(:plugin_instance).type(:type_instance).counter = 42
|
59
|
-
|
60
|
-
For convenience, define yourself a global *shortcut*, like:
|
61
|
-
|
62
|
-
::
|
63
|
-
|
64
|
-
Stats = Collectd.my_zombie(RAILS_ENV)
|
65
|
-
|
66
|
-
To automatically collect *memory and CPU statistics* of your Ruby
|
67
|
-
process, do:
|
68
|
-
|
69
|
-
::
|
70
|
-
|
71
|
-
Stats.with_full_proc_stats
|
72
|
-
|
73
|
-
You can also have the library *poll* for your data, if you feel
|
74
|
-
comfortable with that, eg:
|
75
|
-
|
76
|
-
::
|
77
|
-
|
78
|
-
Stats.counter(:seconds_elapsed).polled_counter do
|
79
|
-
Time.now.to_i
|
80
|
-
end
|
81
|
-
|
82
|
-
|
83
|
-
.. _types.db: http://collectd.org/documentation/manpages/types.db.5.shtml
|