visage-app 1.0.0 → 2.0.0

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.
Files changed (42) hide show
  1. data/.gitignore +10 -0
  2. data/CHANGELOG.md +12 -0
  3. data/Gemfile +1 -15
  4. data/Gemfile.lock +44 -42
  5. data/README.md +123 -49
  6. data/Rakefile +16 -26
  7. data/bin/visage-app +17 -4
  8. data/features/cli.feature +10 -3
  9. data/features/json.feature +37 -0
  10. data/features/step_definitions/{visage_steps.rb → cli_steps.rb} +1 -1
  11. data/features/step_definitions/json_steps.rb +50 -8
  12. data/features/step_definitions/site_steps.rb +1 -1
  13. data/features/support/config/default/profiles.yaml +335 -0
  14. data/features/{data → support}/config/with_no_profiles/.stub +0 -0
  15. data/features/support/config/with_no_profiles/profiles.yaml +0 -0
  16. data/features/support/config/with_old_profile_yaml/profiles.yaml +116 -0
  17. data/features/support/env.rb +2 -3
  18. data/lib/visage-app.rb +35 -25
  19. data/lib/visage-app/collectd/json.rb +115 -118
  20. data/lib/visage-app/collectd/rrds.rb +25 -19
  21. data/lib/visage-app/helpers.rb +17 -0
  22. data/lib/visage-app/profile.rb +18 -25
  23. data/lib/visage-app/public/images/caution.png +0 -0
  24. data/lib/visage-app/public/images/ok.png +0 -0
  25. data/lib/visage-app/public/images/questions.png +0 -0
  26. data/lib/visage-app/public/javascripts/builder.js +607 -0
  27. data/lib/visage-app/public/javascripts/graph.js +179 -142
  28. data/lib/visage-app/public/javascripts/message.js +520 -0
  29. data/lib/visage-app/public/javascripts/mootools-core-1.4.0-full-compat.js +6285 -0
  30. data/lib/visage-app/public/javascripts/mootools-more-1.4.0.1.js +6399 -0
  31. data/lib/visage-app/public/stylesheets/message.css +61 -0
  32. data/lib/visage-app/public/stylesheets/screen.css +149 -38
  33. data/lib/visage-app/version.rb +5 -0
  34. data/lib/visage-app/views/builder.haml +38 -49
  35. data/lib/visage-app/views/builder_form.haml +14 -0
  36. data/lib/visage-app/views/layout.haml +5 -2
  37. data/lib/visage-app/views/profile.haml +44 -25
  38. data/visage-app.gemspec +29 -132
  39. metadata +93 -150
  40. data/VERSION +0 -1
  41. data/features/builder.feature +0 -16
  42. data/lib/visage-app/collectd/profile.rb +0 -36
@@ -6,13 +6,15 @@ require 'socket'
6
6
  fqdn = Socket.gethostbyname(Socket.gethostname).first
7
7
  port = 9292
8
8
  $stdout.sync = true
9
- @root = Pathname.new(File.dirname(__FILE__)).parent.expand_path
9
+ @root = (Pathname.new(__FILE__).parent.parent + 'lib').expand_path
10
+ $: << @root.to_s
10
11
  action = ARGV[0]
11
12
 
12
13
  case action
13
14
  when "start"
14
15
  require 'rubygems'
15
16
  require 'rack'
17
+ require 'visage-app'
16
18
 
17
19
  puts ' _ ___'
18
20
  puts '| | / (_)________ _____ ____'
@@ -22,18 +24,29 @@ when "start"
22
24
  puts ' /____/'
23
25
  puts
24
26
  puts "will be running at http://#{fqdn}:#{port}/"
27
+
28
+ if Visage::Profile.old_format?
29
+ puts
30
+ puts "The Visage profile format has changed!"
31
+ puts "You need to upgrade your profiles."
32
+ puts "Please run:"
33
+ puts
34
+ puts " #{$0} upgrade"
35
+ puts
36
+ exit 1
37
+ end
38
+
25
39
  puts
26
- require @root.join('lib/visage-app')
27
40
  puts "Looking for RRDs in #{Visage::Config.rrddir}"
28
41
  puts
29
42
 
30
- config = @root.join('lib/visage-app/config.ru').to_s
43
+ config = (@root + 'lib/visage-app/config.ru').to_s
31
44
  server = Rack::Server.new(:config => config, :Port => port, :server => "webrick")
32
45
  server.start
33
46
  when "genapache"
34
47
  require 'socket'
35
48
  fqdn = Socket.gethostbyname(Socket.gethostname).first
36
- public_dir = @root.join('lib/visage-app/public')
49
+ public_dir = (@root + 'lib/visage-app/public').to_s
37
50
 
38
51
  puts <<-CONFIG
39
52
  <VirtualHost *>
@@ -16,9 +16,16 @@ Feature: command line utility
16
16
 
17
17
  Scenario: Specified configuration directory
18
18
  Given the "visage" gem is installed
19
- And there is no file at "features/data/config/with_no_profiles/profiles.yaml"
19
+ And there is no file at "features/support/config/with_no_profiles/profiles.yaml"
20
20
  When I start the visage server helper with "visage-app start" and the following variables:
21
21
  | CONFIG_PATH |
22
- | features/data/config/with_no_profiles |
23
- Then I should see a file at "features/data/config/with_no_profiles/profiles.yaml"
22
+ | features/support/config/with_no_profiles |
23
+ Then I should see a file at "features/support/config/with_no_profiles/profiles.yaml"
24
24
 
25
+ Scenario: Config upgrader
26
+ Given the "visage" gem is installed
27
+ When I start the visage server helper with "visage-app start" and the following variables:
28
+ | CONFIG_PATH |
29
+ | features/support/config/with_old_profile_yaml |
30
+ Then I should see "The Visage profile format has changed" on the terminal
31
+ And I should see "visage-app upgrade" on the terminal
@@ -16,6 +16,18 @@ Feature: Export data
16
16
  Then I should receive valid JSON
17
17
  And the JSON should have a list of plugins
18
18
 
19
+ Scenario: Get a list of available metrics on a host
20
+ When I visit the first available host
21
+ Then the request should succeed
22
+ Then I should receive valid JSON
23
+ And the JSON should have a list of plugins
24
+
25
+ Scenario: Get a list of available metrics across many hosts
26
+ When I visit the first two available hosts
27
+ Then the request should succeed
28
+ Then I should receive valid JSON
29
+ And the JSON should have a list of plugins
30
+
19
31
  Scenario: Retrieve single plugin instance
20
32
  Given a list of hosts exist
21
33
  When I visit "memory/memory-free" on the first available host
@@ -49,3 +61,28 @@ Feature: Export data
49
61
  Then I should receive valid JSON
50
62
  And I should see multiple hosts
51
63
 
64
+ Scenario: Retrieve data with a defined start time
65
+ Given a list of hosts exist
66
+ When I visit "disk*/disk_ops" on the first available host with the following query parameters:
67
+ | parameter | value |
68
+ | start | 1321769692 |
69
+ | finish | 1321773292 |
70
+ Then the request should succeed
71
+ Then I should receive valid JSON
72
+ And I should see the following parameters for each plugin instance:
73
+ | parameter | value |
74
+ | start | 1321769692 |
75
+ | finish | 1321773292 |
76
+
77
+ Scenario: Retrieve data with a defined finish time
78
+ Given a list of hosts exist
79
+ When I visit "disk*/disk_ops" on the first available host with the following query parameters:
80
+ | parameter | value |
81
+ | finish | 1321773292 |
82
+ Then the request should succeed
83
+ Then I should receive valid JSON
84
+ And I should see the following parameters for each plugin instance:
85
+ | parameter | value |
86
+ | start | 1321769692 |
87
+ | finish | 1321773292 |
88
+
@@ -34,7 +34,7 @@ When /^I start the visage server helper with "([^"]*)" and the following variabl
34
34
  ENV[variable] = value
35
35
  end
36
36
  end
37
- When %(I start the visage server helper with "#{cmd}")
37
+ step %(I start the visage server helper with "#{cmd}")
38
38
  end
39
39
 
40
40
  Then /^I should see a file at "([^"]*)"$/ do |filename|
@@ -94,10 +94,10 @@ Then /^the JSON should have a list of hosts$/ do
94
94
  end
95
95
 
96
96
  Given /^a list of hosts exist$/ do
97
- When 'I go to /data'
98
- Then 'the request should succeed'
99
- Then 'I should receive valid JSON'
100
- Then 'the JSON should have a list of hosts'
97
+ step 'I go to /data'
98
+ step 'the request should succeed'
99
+ step 'I should receive valid JSON'
100
+ step 'the JSON should have a list of hosts'
101
101
  end
102
102
 
103
103
  When /^I visit "([^"]*)" on the first available host$/ do |glob|
@@ -108,16 +108,27 @@ end
108
108
 
109
109
 
110
110
  When /^I visit the first available host$/ do
111
- When 'I go to /data'
112
- Then 'the request should succeed'
113
- Then 'I should receive valid JSON'
114
- Then 'the JSON should have a list of hosts'
111
+ step 'I go to /data'
112
+ step 'the request should succeed'
113
+ step 'I should receive valid JSON'
114
+ step 'the JSON should have a list of hosts'
115
115
 
116
116
  host = @response["hosts"].first
117
117
  url = "/data/#{host}"
118
118
  When "I go to #{url}"
119
119
  end
120
120
 
121
+ When /^I visit the first two available hosts$/ do
122
+ step 'I go to /data'
123
+ step 'the request should succeed'
124
+ step 'I should receive valid JSON'
125
+ step 'the JSON should have a list of hosts'
126
+
127
+ host = @response["hosts"][0..1].join(',')
128
+ url = "/data/#{host}"
129
+ When "I go to #{url}"
130
+ end
131
+
121
132
  Then /^the JSON should have a list of plugins$/ do
122
133
  host = @response.keys.first
123
134
  plugins = @response[host]
@@ -133,3 +144,34 @@ Then /^the JSON should have a list of types$/ do
133
144
  end
134
145
  end
135
146
 
147
+
148
+ When /^I visit "([^"]*)" on the first available host with the following query parameters:$/ do |glob, table|
149
+ host = @response["hosts"].first
150
+ url = "/data/#{host}/#{glob}"
151
+
152
+ params = Hash[table.hashes.map { |hash| [hash["parameter"], hash["value"]] }]
153
+ query = params.map{|k,v| "#{CGI.escape(k)}=#{CGI.escape(v)}"}.join("&")
154
+ url += "?#{query}"
155
+
156
+ step "I go to #{url}"
157
+ end
158
+
159
+ Then /^I should see the following parameters for each plugin instance:$/ do |table|
160
+ params = Hash[table.hashes.map { |hash| [hash["parameter"], hash["value"]] }]
161
+
162
+ @response.should_not be_nil
163
+
164
+ @response.each_pair do |host, plugin|
165
+ plugin.each_pair do |instance, metric|
166
+ metric.each_pair do |k, series|
167
+ series.each_pair do |k, data|
168
+ params.each do |key, value|
169
+ data[key].should == value.to_i
170
+ end
171
+ end
172
+ end
173
+ end
174
+ end
175
+
176
+ end
177
+
@@ -33,7 +33,7 @@ end
33
33
 
34
34
  Then /^I should see a profile heading$/ do
35
35
  doc = Nokogiri::HTML(response_body)
36
- doc.search('div#profile h2#profile_name').size.should == 1
36
+ doc.search('div#profile h2#name').size.should == 1
37
37
  end
38
38
 
39
39
  Then /^show me the page source$/ do
@@ -0,0 +1,335 @@
1
+ ---
2
+ cpu+on+bar+flapjack+worker01+:
3
+ :metrics:
4
+ - cpu-0/cpu-wait
5
+ - cpu-0/cpu-interrupt
6
+ - cpu-0/cpu-nice
7
+ - cpu-0/cpu-softirq
8
+ - cpu-0/cpu-steal
9
+ - cpu-0/cpu-system
10
+ - cpu-0/cpu-user
11
+ :hosts:
12
+ - bar
13
+ - flapjack-worker01
14
+ :profile_name: "cpu on bar + flapjack-worker01 "
15
+ :url: cpu+on+bar+flapjack+worker01+
16
+ load+on+ubuntu+localdomain:
17
+ :metrics:
18
+ - load/load
19
+ :hosts:
20
+ - ubuntu.localdomain
21
+ :profile_name: load on ubuntu.localdomain
22
+ :url: load+on+ubuntu+localdomain
23
+ apache+stats+on+all+flapjack+workers:
24
+ :metrics:
25
+ - apache/apache_scoreboard-starting
26
+ - apache/apache_scoreboard-logging
27
+ - apache/apache_scoreboard-sending
28
+ - apache/apache_scoreboard-open
29
+ - apache/apache_scoreboard-closing
30
+ - apache/apache_scoreboard-waiting
31
+ - apache/apache_scoreboard-reading
32
+ - apache/apache_scoreboard-keepalive
33
+ - apache/apache_bytes
34
+ - apache/apache_scoreboard-dnslookup
35
+ - apache/apache_requests
36
+ - apache/apache_scoreboard-finishing
37
+ - apache/apache_scoreboard-idle_cleanup
38
+ :hosts:
39
+ - flapjack-worker01
40
+ - flapjack-worker02
41
+ - flapjack-worker03
42
+ - flapjack-worker04
43
+ - flapjack-worker05
44
+ - flapjack-worker06
45
+ :profile_name: apache stats on all flapjack workers
46
+ :url: apache+stats+on+all+flapjack+workers
47
+ cpu+on+blah+and+foo:
48
+ :metrics:
49
+ - cpu-0/cpu-softirq
50
+ - cpu-0/cpu-user
51
+ - cpu-0/cpu-wait
52
+ - cpu-0/cpu-system
53
+ - cpu-0/cpu-nice
54
+ - cpu-0/cpu-steal
55
+ - cpu-0/cpu-interrupt
56
+ :hosts:
57
+ - blah
58
+ - foo
59
+ :profile_name: cpu on blah and foo
60
+ :url: cpu+on+blah+and+foo
61
+ cpu+load+on+blah+foo:
62
+ :metrics:
63
+ - cpu-0/cpu-softirq
64
+ - cpu-0/cpu-idle
65
+ - load/load
66
+ - cpu-0/cpu-steal
67
+ - cpu-0/cpu-system
68
+ - cpu-0/cpu-user
69
+ - cpu-0/cpu-wait
70
+ - cpu-0/cpu-interrupt
71
+ - cpu-0/cpu-nice
72
+ :hosts:
73
+ - blah
74
+ - foo
75
+ :profile_name: cpu + load on blah + foo
76
+ :url: cpu+load+on+blah+foo
77
+ cpu+memory+on+blah:
78
+ :metrics:
79
+ - cpu-0/cpu-steal
80
+ - memory/memory-used
81
+ - cpu-0/cpu-system
82
+ - memory/memory-buffered
83
+ - memory/memory-cached
84
+ - cpu-0/cpu-user
85
+ - cpu-0/cpu-wait
86
+ - cpu-0/cpu-idle
87
+ - cpu-0/cpu-interrupt
88
+ - cpu-0/cpu-nice
89
+ - memory/memory-free
90
+ - cpu-0/cpu-softirq
91
+ :hosts:
92
+ - blah
93
+ :profile_name: cpu + memory on blah
94
+ :url: cpu+memory+on+blah
95
+ all+on+all:
96
+ :metrics: []
97
+
98
+ :hosts:
99
+ - bar
100
+ - baz
101
+ - blah
102
+ - doom
103
+ - flapjack-worker01
104
+ - flapjack-worker02
105
+ - flapjack-worker03
106
+ - flapjack-worker04
107
+ - flapjack-worker05
108
+ - flapjack-worker06
109
+ - foo
110
+ - spoons
111
+ - ubuntu.localdomain
112
+ :profile_name: all on all
113
+ :url: all+on+all
114
+ cpu+on+bar+worker+:
115
+ :metrics:
116
+ - cpu-0/cpu-idle
117
+ - cpu-0/cpu-steal
118
+ - cpu-0/cpu-softirq
119
+ - cpu-0/cpu-user
120
+ - cpu-0/cpu-system
121
+ - cpu-0/cpu-nice
122
+ - cpu-0/cpu-wait
123
+ - cpu-0/cpu-interrupt
124
+ :hosts:
125
+ - bar
126
+ :profile_name: cpu on bar + worker*
127
+ :url: cpu+on+bar+worker+
128
+ spf+dns+queries+on+ubuntu:
129
+ :metrics:
130
+ - dns/dns_qtype-#99
131
+ :hosts:
132
+ - ubuntu.localdomain
133
+ :profile_name: SPF DNS queries on ubuntu
134
+ :url: spf+dns+queries+on+ubuntu
135
+ foobar:
136
+ :metrics:
137
+ - cpu-0/cpu-nice
138
+ - cpu-0/cpu-softirq
139
+ - cpu-0/cpu-steal
140
+ - cpu-0/cpu-idle
141
+ - cpu-0/cpu-system
142
+ - cpu-0/cpu-user
143
+ - cpu-0/cpu-wait
144
+ - cpu-0/cpu-interrupt
145
+ :hosts:
146
+ - blah
147
+ :profile_name: foobar
148
+ :url: foobar
149
+ foo:
150
+ :metrics:
151
+ - cpu-0/cpu-steal
152
+ - cpu-0/cpu-idle
153
+ - cpu-0/cpu-system
154
+ - cpu-0/cpu-user
155
+ - cpu-0/cpu-wait
156
+ - cpu-0/cpu-interrupt
157
+ - cpu-0/cpu-nice
158
+ - cpu-0/cpu-softirq
159
+ :hosts:
160
+ - blah
161
+ :profile_name: foo
162
+ :url: foo
163
+ processes+on+blah:
164
+ :metrics:
165
+ - processes/ps_state-zombies
166
+ - processes/ps_state-running
167
+ - processes/ps_state-blocked
168
+ - processes/ps_state-stopped
169
+ - processes/ps_state-paging
170
+ - processes/ps_state-sleeping
171
+ :hosts:
172
+ - ubuntu.localdomain
173
+ :profile_name: processes on blah
174
+ :url: processes+on+blah
175
+ wide+variance+in+values:
176
+ :metrics:
177
+ - vmem/vmpage_number-dirty
178
+ :hosts:
179
+ - ubuntu.localdomain
180
+ :profile_name: wide variance in values
181
+ :url: wide+variance+in+values
182
+ sda+on+ubuntu:
183
+ :metrics:
184
+ - disk-sda/disk_ops
185
+ - disk-sda/disk_time
186
+ - disk-sda/disk_merged
187
+ - disk-sda/disk_octets
188
+ :hosts:
189
+ - ubuntu.localdomain
190
+ :profile_name: sda on ubuntu
191
+ :url: sda+on+ubuntu
192
+ ruby+gc+on+ubuntu+localdomain:
193
+ :metrics:
194
+ - curl_json-gc/counter--growth
195
+ - curl_json-gc/counter--collections
196
+ - curl_json-gc/counter--num_allocations
197
+ - curl_json-gc/counter--allocated_size
198
+ :hosts:
199
+ - ubuntu.localdomain
200
+ :profile_name: Ruby GC on ubuntu.localdomain
201
+ :url: ruby+gc+on+ubuntu+localdomain
202
+ cpu+on+ubuntu+:
203
+ :metrics:
204
+ - cpu-0/cpu-idle
205
+ - cpu-0/cpu-steal
206
+ - cpu-0/cpu-softirq
207
+ - cpu-0/cpu-user
208
+ - cpu-0/cpu-system
209
+ - cpu-0/cpu-nice
210
+ - cpu-0/cpu-wait
211
+ - cpu-0/cpu-interrupt
212
+ :hosts:
213
+ - ubuntu.localdomain
214
+ :profile_name: "cpu on ubuntu "
215
+ :url: cpu+on+ubuntu+
216
+ swap+on+ubuntu:
217
+ :metrics:
218
+ - swap/swap-cached
219
+ - swap/swap-used
220
+ - swap/swap_io-out
221
+ - swap/swap-free
222
+ - swap/swap_io-in
223
+ :hosts:
224
+ - ubuntu.localdomain
225
+ :profile_name: swap on ubuntu
226
+ :url: swap+on+ubuntu
227
+ load+on+blah+baz+bar:
228
+ :metrics:
229
+ - load/load
230
+ :hosts:
231
+ - blah
232
+ - bar
233
+ - baz
234
+ :profile_name: load on blah + baz + bar
235
+ :url: load+on+blah+baz+bar
236
+ cpu+on+blah+doom:
237
+ :metrics:
238
+ - cpu-0/cpu-steal
239
+ - cpu-0/cpu-system
240
+ - cpu-0/cpu-user
241
+ - cpu-0/cpu-wait
242
+ - cpu-0/cpu-idle
243
+ - cpu-0/cpu-interrupt
244
+ - cpu-0/cpu-nice
245
+ - cpu-0/cpu-softirq
246
+ :hosts:
247
+ - blah
248
+ - doom
249
+ :profile_name: cpu on blah + doom
250
+ :url: cpu+on+blah+doom
251
+ cpu+on+blah:
252
+ :metrics:
253
+ - cpu-0/cpu-system
254
+ - cpu-0/cpu-user
255
+ - cpu-0/cpu-wait
256
+ - cpu-0/cpu-interrupt
257
+ - cpu-0/cpu-nice
258
+ - cpu-0/cpu-softirq
259
+ - cpu-0/cpu-steal
260
+ :hosts:
261
+ - blah
262
+ :profile_name: cpu on blah
263
+ :url: cpu+on+blah
264
+ df+var+run+and+df+root+on+ubuntu:
265
+ :metrics:
266
+ - df/df-root
267
+ - df/df-var-run
268
+ :hosts:
269
+ - ubuntu.localdomain
270
+ :profile_name: df-var-run and df-root on ubuntu
271
+ :url: df+var+run+and+df+root+on+ubuntu
272
+ memory+and+cpu+on+ubuntu:
273
+ :metrics:
274
+ - memory/memory-buffered
275
+ - memory/memory-cached
276
+ - memory/memory-free
277
+ - memory/memory-used
278
+ - cpu-0/cpu-idle
279
+ - cpu-0/cpu-steal
280
+ - cpu-0/cpu-softirq
281
+ - cpu-0/cpu-user
282
+ - cpu-0/cpu-system
283
+ - cpu-0/cpu-nice
284
+ - cpu-0/cpu-wait
285
+ - cpu-0/cpu-interrupt
286
+ :hosts:
287
+ - ubuntu.localdomain
288
+ :profile_name: memory and cpu on ubuntu
289
+ :url: memory+and+cpu+on+ubuntu
290
+ cpu+no+idle+on+blah+doom:
291
+ :metrics:
292
+ - cpu-0/cpu-interrupt
293
+ - cpu-0/cpu-nice
294
+ - cpu-0/cpu-softirq
295
+ - cpu-0/cpu-steal
296
+ - cpu-0/cpu-system
297
+ - cpu-0/cpu-user
298
+ - cpu-0/cpu-wait
299
+ :hosts:
300
+ - blah
301
+ - doom
302
+ :profile_name: cpu (no idle) on blah + doom
303
+ :url: cpu+no+idle+on+blah+doom
304
+ vmem+on+blah:
305
+ :metrics:
306
+ - vmem/vmpage_number-writeback_temp
307
+ - vmem/vmpage_number-file_pages
308
+ - vmem/vmpage_number-mlock
309
+ - vmem/vmpage_number-unstable
310
+ - vmem/vmpage_number-kernel_stack
311
+ - vmem/vmpage_io-swap
312
+ - vmem/vmpage_number-free_pages
313
+ - vmem/vmpage_number-vmscan_write
314
+ - vmem/vmpage_io-memory
315
+ - vmem/vmpage_number-inactive_anon
316
+ - vmem/vmpage_faults
317
+ - vmem/vmpage_number-unevictable
318
+ - vmem/vmpage_number-slab_unreclaimable
319
+ - vmem/vmpage_number-mapped
320
+ - vmem/vmpage_number-page_table_pages
321
+ - vmem/vmpage_number-anon_pages
322
+ - vmem/vmpage_number-isolated_file
323
+ - vmem/vmpage_number-isolated_anon
324
+ - vmem/vmpage_number-inactive_file
325
+ - vmem/vmpage_number-active_anon
326
+ - vmem/vmpage_number-dirty
327
+ - vmem/vmpage_number-shmem
328
+ - vmem/vmpage_number-slab_reclaimable
329
+ - vmem/vmpage_number-writeback
330
+ - vmem/vmpage_number-bounce
331
+ - vmem/vmpage_number-active_file
332
+ :hosts:
333
+ - blah
334
+ :profile_name: vmem on blah
335
+ :url: vmem+on+blah