munin2graphite 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +19 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +123 -0
- data/Rakefile +38 -0
- data/VERSION +1 -0
- data/bin/munin2graphite +16 -0
- data/bin/munin2graphite-daemon +20 -0
- data/conf/munin2graphite.conf.example +35 -0
- data/etc/munin2graphite/munin2graphite.conf.example +35 -0
- data/lib/ast_node.rb +344 -0
- data/lib/carbon.rb +36 -0
- data/lib/graphite/base.rb +30 -0
- data/lib/graphite/graph.rb +40 -0
- data/lib/graphite/metric.rb +19 -0
- data/lib/graphite/my_graph.rb +23 -0
- data/lib/graphite/user_graph.rb +4 -0
- data/lib/graphite.rb +8 -0
- data/lib/munin2graphite/config.rb +117 -0
- data/lib/munin2graphite/scheduler.rb +169 -0
- data/lib/munin2graphite.rb +8 -0
- data/lib/munin_graph.rb +136 -0
- data/munin2graphite.gemspec +96 -0
- data/test/munin2graphite/config_test.rb +53 -0
- data/test/test_config.rb +27 -0
- data/test/test_init.rb +13 -0
- data/test/test_munin.rb +43 -0
- data/test/test_munin_graph.rb +286 -0
- data/test/test_my_graph.rb +28 -0
- data/test/test_scheduler.rb +19 -0
- metadata +167 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.join(File.expand_path(File.dirname(__FILE__)),"../test_init")
|
2
|
+
require 'tempfile'
|
3
|
+
|
4
|
+
class TestMyGraph < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
Munin2Graphite::Config.deconfigure!
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_config_init_without_config_file
|
14
|
+
Munin2Graphite::Config.config_file = "/TMP/it does exist, C'mon!"
|
15
|
+
assert_raise(Munin2Graphite::Config::ConfigFileNotFoundException) {
|
16
|
+
Munin2Graphite::Config.carbon
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_config_raises_exception_when_malformed
|
21
|
+
file = Tempfile.new('foo')
|
22
|
+
file.write("test_:::: : ::: [] of_a_malformed thing, \nthat does not confo")
|
23
|
+
file.close
|
24
|
+
Munin2Graphite::Config.config_file = file.path
|
25
|
+
assert_raise(Munin2Graphite::Config::MalformedConfigFileException) {
|
26
|
+
Munin2Graphite::Config.carbon
|
27
|
+
}
|
28
|
+
file.unlink
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_config_raises_exception_when_not_configured
|
32
|
+
assert_raise(Munin2Graphite::Config::NotConfiguredException) {
|
33
|
+
Munin2Graphite::Config.carbon
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_config_initialization_raises_exception_when_mandatory_fields_are_not_present
|
38
|
+
Munin2Graphite::Config.config_file = TEST_CONFIG_FILE
|
39
|
+
file = Tempfile.new('foo')
|
40
|
+
file.write(":thing:\n :other_thing:")
|
41
|
+
file.close
|
42
|
+
Munin2Graphite::Config.config_file = file.path
|
43
|
+
assert_raise(Munin2Graphite::Config::RequiredFieldMissingException){
|
44
|
+
Munin2Graphite::Config.carbon
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_correct_initalization
|
49
|
+
Munin2Graphite::Config.config_file = TEST_CONFIG_FILE
|
50
|
+
assert_not_equal Munin2Graphite::Config[:carbon][:hostname],"","should be filled"
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
data/test/test_config.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),"/test_init"))
|
2
|
+
|
3
|
+
class TestMunin < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
Munin2Graphite::Config.config_file = TEST_CONFIG_FILE
|
7
|
+
@munin = Munin::Node.new(Munin2Graphite::Config["munin_hostname"],Munin2Graphite::Config["munin_port"])
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_config
|
11
|
+
Munin2Graphite::Config.config_file = TEST_CONFIG_FILE
|
12
|
+
assert Munin2Graphite::Config.configured?
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_config_workers
|
16
|
+
Munin2Graphite::Config.config_file = TEST_CONFIG_FILE
|
17
|
+
assert_not_empty Munin2Graphite::Config.workers
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_worker_config
|
21
|
+
Munin2Graphite::Config.config_file = TEST_CONFIG_FILE
|
22
|
+
worker_config = Munin2Graphite::Config.config_for_worker("test_worker1")
|
23
|
+
assert_not_equal Munin2Graphite::Config["munin_hostname"], worker_config["munin_hostname"]
|
24
|
+
assert_not_nil worker_config.log
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/test/test_init.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__) + "/../lib/"))
|
2
|
+
require 'rubygems'
|
3
|
+
require 'test/unit'
|
4
|
+
require '../munin-ruby/lib/munin-ruby'
|
5
|
+
require 'graphite'
|
6
|
+
require 'munin2graphite'
|
7
|
+
require 'munin_graph'
|
8
|
+
require 'carbon'
|
9
|
+
|
10
|
+
TEST_CONFIG_FILE = File.join(File.dirname(__FILE__),"config.conf")
|
11
|
+
Munin2Graphite::Config.config_file = TEST_CONFIG_FILE
|
12
|
+
Graphite::Base.set_connection(Munin2Graphite::Config["carbon_hostname"])
|
13
|
+
Graphite::Base.authenticate(Munin2Graphite::Config["graphite_user"],Munin2Graphite::Config["graphite_password"])
|
data/test/test_munin.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),"/test_init"))
|
2
|
+
|
3
|
+
class TestMunin < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Munin2Graphite::Config.config_file = TEST_CONFIG_FILE
|
6
|
+
@munin = Munin::Node.new(Munin2Graphite::Config["munin_hostname"],Munin2Graphite::Config["munin_port"])
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_metric_lists
|
10
|
+
metrics = @munin.list
|
11
|
+
assert_not_nil metrics
|
12
|
+
assert_not_empty metrics
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_nodes
|
16
|
+
nodes = @munin.nodes
|
17
|
+
assert_not_nil nodes
|
18
|
+
assert_not_empty nodes
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_value_for
|
22
|
+
first_metric = @munin.list.first
|
23
|
+
values = @munin.fetch first_metric
|
24
|
+
assert_not_nil values
|
25
|
+
assert_not_empty values.keys
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_graph_for
|
29
|
+
munin_graph = MuninGraph.graph_for @munin.raw_config(@munin.list.first)
|
30
|
+
assert_equal munin_graph.class, MuninGraph
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_graph_for
|
34
|
+
@munin.list.each do |metric|
|
35
|
+
munin_graph = MuninGraph.graph_for @munin.config(metric,true)[metric]
|
36
|
+
|
37
|
+
munin_graph.config = Munin2Graphite::Config.merge("metric" => metric,"hostname" => @munin.nodes.first.split(".").first)
|
38
|
+
munin_graph.to_graphite.save!
|
39
|
+
assert_equal munin_graph.class, MuninGraph
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,286 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),"/test_init"))
|
2
|
+
|
3
|
+
class TestMuninGraph < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
Munin2Graphite::Config.config_file = TEST_CONFIG_FILE
|
7
|
+
@munin = Munin::Node.new(Munin2Graphite::Config["munin_hostname"],Munin2Graphite::Config["munin_port"])
|
8
|
+
@simple_graph = MuninGraph.new(<<END
|
9
|
+
graph_title ACPI Thermal zone temperatures
|
10
|
+
graph_vlabel Celcius
|
11
|
+
graph_category sensors
|
12
|
+
graph_info This graph shows the temperature in different ACPI Thermal zones. If there is only one it will usually be the case temperature.
|
13
|
+
THM0.label THM0
|
14
|
+
THM0.colour black
|
15
|
+
THM1.label THM1
|
16
|
+
END
|
17
|
+
)
|
18
|
+
@apache_graph = MuninGraph.new(<<END
|
19
|
+
graph_title Apache accesses
|
20
|
+
graph_args --base 1000
|
21
|
+
graph_vlabel accesses / ${graph_period}
|
22
|
+
graph_category apache
|
23
|
+
accesses80.label port 80
|
24
|
+
accesses80.type DERIVE
|
25
|
+
accesses80.max 1000000
|
26
|
+
accesses80.min 0
|
27
|
+
accesses80.info The number of accesses (pages and other items served) globaly on the Apache server
|
28
|
+
END
|
29
|
+
)
|
30
|
+
|
31
|
+
@processes_graph = MuninGraph.new(<<END
|
32
|
+
graph_title Apache processes
|
33
|
+
graph_args --base 1000 -l 0
|
34
|
+
graph_category apache
|
35
|
+
graph_order busy80 idle80
|
36
|
+
graph_vlabel processes
|
37
|
+
graph_total total
|
38
|
+
busy80.label busy servers 80
|
39
|
+
busy80.draw AREA
|
40
|
+
busy80.colour 33cc00
|
41
|
+
idle80.label idle servers 80
|
42
|
+
idle80.draw STACK
|
43
|
+
idle80.colour 0033ff
|
44
|
+
free80.label free slots 80
|
45
|
+
free80.draw STACK
|
46
|
+
free80.colour ccff00
|
47
|
+
END
|
48
|
+
)
|
49
|
+
|
50
|
+
@log_graph = MuninGraph.new(<<END
|
51
|
+
config iostat_ios
|
52
|
+
graph_title IO Service time
|
53
|
+
graph_args --base 1000 --logarithmic
|
54
|
+
graph_category disk
|
55
|
+
graph_vlabel seconds
|
56
|
+
graph_info For each applicable disk device this plugin shows the latency (or delay) for I/O operations on that disk device. The delay is in part made up of waiting for the disk to flush the data, and if data arrives at the disk faster than it can read or write it then the delay time will include the time needed for waiting in the queue.
|
57
|
+
dev104_0_rtime.label cciss/c0d0 read
|
58
|
+
dev104_0_rtime.type GAUGE
|
59
|
+
dev104_0_rtime.draw LINE2
|
60
|
+
dev104_0_rtime.cdef dev104_0_rtime,1000,/
|
61
|
+
dev104_0_wtime.label cciss/c0d0 write
|
62
|
+
dev104_0_wtime.type GAUGE
|
63
|
+
dev104_0_wtime.draw LINE2
|
64
|
+
dev104_0_wtime.cdef dev104_0_wtime,1000,/
|
65
|
+
dev104_16_rtime.label cciss/c0d1 read
|
66
|
+
dev104_16_rtime.type GAUGE
|
67
|
+
dev104_16_rtime.draw LINE2
|
68
|
+
dev104_16_rtime.cdef dev104_16_rtime,1000,/
|
69
|
+
dev104_16_wtime.label cciss/c0d1 write
|
70
|
+
dev104_16_wtime.type GAUGE
|
71
|
+
dev104_16_wtime.draw LINE2
|
72
|
+
dev104_16_wtime.cdef dev104_16_wtime,1000,/
|
73
|
+
END
|
74
|
+
)
|
75
|
+
@simple_graph.config = Munin2Graphite::Config.merge({
|
76
|
+
"metric_prefix" => "test.frontends.linux",
|
77
|
+
"category" => "sensors",
|
78
|
+
"hostname" => "myhost",
|
79
|
+
"metric" => "acpi"}
|
80
|
+
)
|
81
|
+
@apache_graph.config = Munin2Graphite::Config.merge({ "metric_prefix" => "test.frontends.linux",
|
82
|
+
"category" => "apache",
|
83
|
+
"hostname" => "myhost",
|
84
|
+
"metric" => "apache_accesses"
|
85
|
+
})
|
86
|
+
|
87
|
+
@processes_graph.config = Munin2Graphite::Config.merge({
|
88
|
+
"metric_prefix" => "test.frontends.linux",
|
89
|
+
"category" => "apache",
|
90
|
+
"hostname" => "myhost",
|
91
|
+
"metric" => "apache_processes"
|
92
|
+
})
|
93
|
+
@log_graph.config = Munin2Graphite::Config.merge({
|
94
|
+
"metric_prefix" => "test.frontends.linux",
|
95
|
+
"category" => "apache",
|
96
|
+
"hostname" => "myhost",
|
97
|
+
"metric" => "iostat_ios"
|
98
|
+
})
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_get_title
|
102
|
+
root = @simple_graph.root
|
103
|
+
assert_equal root.children.length, 6
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_compilation_on_simple_graph
|
107
|
+
root = @simple_graph.root
|
108
|
+
root.compile
|
109
|
+
field_declarations = root.children_of_class(FieldDeclarationNode)
|
110
|
+
assert_equal field_declarations.first.compile,"alias(test.frontends.linux.myhost.sensors.acpi.THM0,'THM0')"
|
111
|
+
assert_equal root.graph_properties[:vtitle], "Celcius"
|
112
|
+
assert_equal root.graph_properties[:title], "ACPI Thermal zone temperatures"
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_compilation_on_derivative_graph
|
116
|
+
root = @apache_graph.root
|
117
|
+
field_declarations = root.children_of_class(FieldDeclarationNode)
|
118
|
+
root.compile
|
119
|
+
assert_equal field_declarations.first.compile,"alias(scale(nonNegativeDerivative(test.frontends.linux.myhost.apache.apache_accesses.accesses80),0.0166666666666667),'port 80')"
|
120
|
+
assert_equal root.graph_properties[:yMax], 1000000
|
121
|
+
assert_equal root.graph_properties[:yMin], 0
|
122
|
+
assert_equal root.properties[:base] , 1000
|
123
|
+
assert_equal root.graph_properties[:title], "Apache accesses"
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_children_of_class
|
127
|
+
root = @simple_graph.root
|
128
|
+
assert_equal root.children_of_class(GlobalDeclarationNode).length, 4
|
129
|
+
field_declarations = root.children_of_class(FieldDeclarationNode)
|
130
|
+
# puts field_declarations.map(&:properties).inspect
|
131
|
+
assert_equal field_declarations.length,2
|
132
|
+
assert_equal field_declarations.first.children.length,2
|
133
|
+
assert_equal field_declarations[1].children.length,1
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_stacked_graph
|
137
|
+
root = @processes_graph.root
|
138
|
+
@processes_graph.root.compile
|
139
|
+
stacked = false
|
140
|
+
root.targets.each do |target|
|
141
|
+
if target.compile =~ /stacked/
|
142
|
+
stacked = true
|
143
|
+
end
|
144
|
+
end
|
145
|
+
assert_equal stacked,true
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_variable_substitution
|
150
|
+
@apache_graph.root.compile
|
151
|
+
assert_nil @apache_graph.root.url =~ /graph_period/
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_random_colors
|
155
|
+
root = @processes_graph.root
|
156
|
+
@processes_graph.root.compile
|
157
|
+
assert_equal @processes_graph.root.graph_properties[:colorList].first , "#33cc00"
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_logarithmic_graph
|
161
|
+
root = @log_graph.root
|
162
|
+
root.compile
|
163
|
+
root.targets.each do |target|
|
164
|
+
# assert_not_nil target.compile =~ /log/
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_global_attributes_can_appear_wherever
|
169
|
+
graph = MuninGraph.new(<<END
|
170
|
+
graph_title Load average
|
171
|
+
graph_args --base 1000 -l 0
|
172
|
+
graph_vlabel load
|
173
|
+
graph_scale no
|
174
|
+
graph_category system
|
175
|
+
load.label load
|
176
|
+
graph_info The load average of the machine describes how many processes are in the run-queue (scheduled to run "immediately").
|
177
|
+
load.info 5 minute load average
|
178
|
+
END
|
179
|
+
)
|
180
|
+
graph.config = Munin2Graphite::Config.merge({ 'metric' => "load",'hostname' => "localhost"})
|
181
|
+
graph.root.url
|
182
|
+
end
|
183
|
+
|
184
|
+
def test_host_name_changed
|
185
|
+
graph = MuninGraph.new(<<END
|
186
|
+
host_name Firewalls
|
187
|
+
graph_title Load average
|
188
|
+
graph_args --base 1000 -l 0
|
189
|
+
graph_vlabel load
|
190
|
+
graph_scale no
|
191
|
+
graph_category system
|
192
|
+
load.label load
|
193
|
+
graph_info The load average of the machine describes how many processes are in the run-queue (scheduled to run "immediately").
|
194
|
+
load.info 5 minute load average
|
195
|
+
END
|
196
|
+
)
|
197
|
+
graph.config = Munin2Graphite::Config.merge({ 'metric' => "load",'hostname' => "localhost"})
|
198
|
+
graph.root.url
|
199
|
+
assert_equal graph.root.properties['hostname'] , "Firewalls"
|
200
|
+
end
|
201
|
+
|
202
|
+
|
203
|
+
def test_multi_line
|
204
|
+
graph = MuninGraph.new(<<END
|
205
|
+
graph_order down up
|
206
|
+
graph_title eth2 traffic
|
207
|
+
graph_args --base 1000
|
208
|
+
graph_vlabel bits in (-) / out (+) per ${graph_period}
|
209
|
+
graph_category network
|
210
|
+
graph_info This graph shows the traffic of the eth2 network interface. Please note that the traffic is shown in bits per second, not bytes. IMPORTANT: On 32 bit systems the data source for this plugin uses 32bit counters, which makes the plugin unreliable and unsuitable for most 100Mb (or faster) interfaces, where traffic is expected to exceed 50Mbps over a 5 minute period. This means that this plugin is unsuitable for most 32 bit production environments. To avoid this problem, use the ip_ plugin instead. There should be no problems on 64 bit systems running 64 bit kernels.
|
211
|
+
down.label received
|
212
|
+
down.type COUNTER
|
213
|
+
down.graph no
|
214
|
+
down.cdef down,8,*
|
215
|
+
up.label bps
|
216
|
+
up.type COUNTER
|
217
|
+
up.negative down
|
218
|
+
up.cdef up,8,*
|
219
|
+
up.max 1000000000
|
220
|
+
up.info Traffic of the eth2 interface. Maximum speed is 1000 Mbps.
|
221
|
+
down.max 1000000000
|
222
|
+
END
|
223
|
+
)
|
224
|
+
graph.config = Munin2Graphite::Config.merge({ 'metric' => "load",'hostname' => "localhost"})
|
225
|
+
graph.root.compile
|
226
|
+
color_list = graph.root.graph_properties[:colorList]
|
227
|
+
assert_equal color_list.first , color_list[1] # Thew should be drawn with the same color
|
228
|
+
assert_match graph.root.url , /alias\(scale\(scale\(scale\(nonNegativeDerivative\(test.frontends.linux.localhost.network.load.down\),0.0166666666666667\),8\),-1/
|
229
|
+
assert_equal graph.root.children_of_class(FieldDeclarationNode).length , 2
|
230
|
+
graph.root.url
|
231
|
+
end
|
232
|
+
|
233
|
+
def test_network_graph
|
234
|
+
graph = MuninGraph.new(<<END
|
235
|
+
host_name Switxos
|
236
|
+
graph_category switch
|
237
|
+
graph_title One switck
|
238
|
+
graph_args --base 1000
|
239
|
+
graph_vlabel Errors in (G) / out (B) per ${graph_period}
|
240
|
+
fe_0_1_errors_in.label Errors IN
|
241
|
+
fe_0_1_errors_in.draw LINE1
|
242
|
+
fe_0_1_errors_in.type DERIVE
|
243
|
+
fe_0_1_errors_in.cdef fe_0_1_errors_in,8,*
|
244
|
+
fe_0_1_errors_in.max 2000000000
|
245
|
+
fe_0_1_errors_in.min 0
|
246
|
+
fe_0_1_errors_out.label Errors OUT
|
247
|
+
fe_0_1_errors_out.draw LINE1
|
248
|
+
fe_0_1_errors_out.type DERIVE
|
249
|
+
fe_0_1_errors_out.cdef fe_0_1_errors_out,8,*
|
250
|
+
fe_0_1_errors_out.max 2000000000
|
251
|
+
fe_0_1_errors_out.min 0
|
252
|
+
fe_0_2_errors_in.label Errors IN
|
253
|
+
fe_0_2_errors_in.draw LINE1
|
254
|
+
fe_0_2_errors_in.type DERIVE
|
255
|
+
fe_0_2_errors_in.cdef fe_0_2_errors_in,8,*
|
256
|
+
fe_0_2_errors_in.max 2000000000
|
257
|
+
fe_0_2_errors_in.min 0
|
258
|
+
fe_0_2_errors_out.label Errors OUT
|
259
|
+
fe_0_2_errors_out.draw LINE1
|
260
|
+
fe_0_2_errors_out.type DERIVE
|
261
|
+
fe_0_2_errors_out.cdef fe_0_2_errors_out,8,*
|
262
|
+
fe_0_2_errors_out.max 2000000000
|
263
|
+
fe_0_2_errors_out.min 0
|
264
|
+
fe_0_4_errors_in.label Errors IN
|
265
|
+
fe_0_4_errors_in.draw LINE1
|
266
|
+
fe_0_4_errors_in.type DERIVE
|
267
|
+
fe_0_4_errors_in.cdef fe_0_4_errors_in,8,*
|
268
|
+
fe_0_4_errors_in.max 2000000000
|
269
|
+
fe_0_4_errors_in.min 0
|
270
|
+
fe_0_4_errors_out.label Errors OUT
|
271
|
+
fe_0_4_errors_out.draw LINE1
|
272
|
+
fe_0_4_errors_out.type DERIVE
|
273
|
+
fe_0_4_errors_out.cdef fe_0_4_errors_out,8,*
|
274
|
+
fe_0_4_errors_out.max 2000000000
|
275
|
+
fe_0_4_errors_out.min 0
|
276
|
+
END
|
277
|
+
)
|
278
|
+
graph.config = Munin2Graphite::Config.merge({ 'metric' => "load",'hostname' => "localhost"})
|
279
|
+
graph.root.compile
|
280
|
+
assert_equal graph.root.targets.length, 6
|
281
|
+
|
282
|
+
end
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),"/test_init"))
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class TestMyGraph < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
Munin2Graphite::Config.config_file = TEST_CONFIG_FILE
|
8
|
+
@graphic = Graphite::MyGraph.new
|
9
|
+
@graphic.url = "http://graphite.uoc.es/composer/../render/?width=1371&height=707&_salt=1312965749.741&target=alias(scale(derivative(campus.frontends.linux.aleia.apache.apache_volume.volume80)%2C0.016666666666666666)%2C%22Bytes%20por%20segundo%22)&title=Bytes%20transmitidos"
|
10
|
+
@graphic.name = "Apache.Transferencia"
|
11
|
+
@graphic.save!
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
Graphite::MyGraph.find_all_by_query("*").each do |graph|
|
16
|
+
graph.delete!
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_find_by_query_and_path_before_authenticate
|
21
|
+
assert_equal Graphite::MyGraph.find_by_query_and_path("*","Apache").count, 1
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_find_by_name
|
25
|
+
assert_equal Graphite::MyGraph.find_by_name("Apache.Transferencia").name , "Apache.Transferencia"
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__),"/test_init"))
|
2
|
+
|
3
|
+
class TestMuninGraph < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
Munin2Graphite::Config.config_file = TEST_CONFIG_FILE
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_obtain_metrics
|
10
|
+
@scheduler = Munin2Graphite::Scheduler.new(Munin2Graphite::Config)
|
11
|
+
@scheduler.obtain_metrics
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_obtain_graphs
|
15
|
+
@scheduler = Munin2Graphite::Scheduler.new(Munin2Graphite::Config)
|
16
|
+
@scheduler.obtain_graphs
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: munin2graphite
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jose Fernandez (magec)
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-09 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rufus-scheduler
|
16
|
+
requirement: &14306040 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - =
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.0.10
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *14306040
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: daemons
|
27
|
+
requirement: &14305560 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - =
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.1.4
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *14305560
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: parseconfig
|
38
|
+
requirement: &14305080 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *14305080
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: munin-ruby
|
49
|
+
requirement: &14304600 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.2.1
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *14304600
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: bundler
|
60
|
+
requirement: &14304120 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.0.0
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *14304120
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: jeweler
|
71
|
+
requirement: &14303640 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.5.2
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *14303640
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: yard
|
82
|
+
requirement: &14303160 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ~>
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 0.6.0
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *14303160
|
91
|
+
description: This gem will install as a daemon and can be used to connect to a graphite
|
92
|
+
and a carbon backend. It will not only post the data for the metrics but also create
|
93
|
+
graphs into graphite, by means of a translation from munin-node.
|
94
|
+
email: jfernandezperez@gmail.com
|
95
|
+
executables:
|
96
|
+
- munin2graphite
|
97
|
+
- munin2graphite-daemon
|
98
|
+
extensions: []
|
99
|
+
extra_rdoc_files:
|
100
|
+
- LICENSE.txt
|
101
|
+
- README.markdown
|
102
|
+
files:
|
103
|
+
- Gemfile
|
104
|
+
- LICENSE.txt
|
105
|
+
- README.markdown
|
106
|
+
- Rakefile
|
107
|
+
- VERSION
|
108
|
+
- bin/munin2graphite
|
109
|
+
- bin/munin2graphite-daemon
|
110
|
+
- conf/munin2graphite.conf.example
|
111
|
+
- etc/munin2graphite/munin2graphite.conf.example
|
112
|
+
- lib/ast_node.rb
|
113
|
+
- lib/carbon.rb
|
114
|
+
- lib/graphite.rb
|
115
|
+
- lib/graphite/base.rb
|
116
|
+
- lib/graphite/graph.rb
|
117
|
+
- lib/graphite/metric.rb
|
118
|
+
- lib/graphite/my_graph.rb
|
119
|
+
- lib/graphite/user_graph.rb
|
120
|
+
- lib/munin2graphite.rb
|
121
|
+
- lib/munin2graphite/config.rb
|
122
|
+
- lib/munin2graphite/scheduler.rb
|
123
|
+
- lib/munin_graph.rb
|
124
|
+
- munin2graphite.gemspec
|
125
|
+
- test/munin2graphite/config_test.rb
|
126
|
+
- test/test_config.rb
|
127
|
+
- test/test_init.rb
|
128
|
+
- test/test_munin.rb
|
129
|
+
- test/test_munin_graph.rb
|
130
|
+
- test/test_my_graph.rb
|
131
|
+
- test/test_scheduler.rb
|
132
|
+
homepage: http://github.com/magec/munin2graphite
|
133
|
+
licenses:
|
134
|
+
- MIT
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ! '>='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
segments:
|
146
|
+
- 0
|
147
|
+
hash: -924376751011725776
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
none: false
|
150
|
+
requirements:
|
151
|
+
- - ! '>='
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
requirements: []
|
155
|
+
rubyforge_project:
|
156
|
+
rubygems_version: 1.8.10
|
157
|
+
signing_key:
|
158
|
+
specification_version: 3
|
159
|
+
summary: Allows to post both data and graphic info from munin to graphite (https://launchpad.net/graphite)
|
160
|
+
test_files:
|
161
|
+
- test/munin2graphite/config_test.rb
|
162
|
+
- test/test_config.rb
|
163
|
+
- test/test_init.rb
|
164
|
+
- test/test_munin.rb
|
165
|
+
- test/test_munin_graph.rb
|
166
|
+
- test/test_my_graph.rb
|
167
|
+
- test/test_scheduler.rb
|