scales-monitor 0.0.1.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +6 -0
- data/LICENSE +22 -0
- data/Rakefile +8 -0
- data/bin/scales-monitor +8 -0
- data/lib/scales-monitor.rb +11 -0
- data/lib/scales-monitor/app/Gemfile +3 -0
- data/lib/scales-monitor/app/Rakefile +0 -0
- data/lib/scales-monitor/app/app/assets/images/.gitignore +0 -0
- data/lib/scales-monitor/app/app/assets/images/glyphicons-halflings-white.png +0 -0
- data/lib/scales-monitor/app/app/assets/images/glyphicons-halflings.png +0 -0
- data/lib/scales-monitor/app/app/assets/javascripts/app/config/config.js.coffee +8 -0
- data/lib/scales-monitor/app/app/assets/javascripts/app/config/routes.js.coffee +15 -0
- data/lib/scales-monitor/app/app/assets/javascripts/app/controllers/.gitignore +0 -0
- data/lib/scales-monitor/app/app/assets/javascripts/app/controllers/log.jst.coffee +58 -0
- data/lib/scales-monitor/app/app/assets/javascripts/app/controllers/machines.js.coffee +60 -0
- data/lib/scales-monitor/app/app/assets/javascripts/app/controllers/queues.js.coffee +55 -0
- data/lib/scales-monitor/app/app/assets/javascripts/app/controllers/resources.js.coffee +128 -0
- data/lib/scales-monitor/app/app/assets/javascripts/app/index.js.coffee +8 -0
- data/lib/scales-monitor/app/app/assets/javascripts/app/models/.gitignore +0 -0
- data/lib/scales-monitor/app/app/assets/javascripts/app/models/socket.js.coffee +9 -0
- data/lib/scales-monitor/app/app/assets/javascripts/app/views/.gitignore +0 -0
- data/lib/scales-monitor/app/app/assets/javascripts/app/views/_format_bar.jst.eco +10 -0
- data/lib/scales-monitor/app/app/assets/javascripts/app/views/_machine.jst.eco +11 -0
- data/lib/scales-monitor/app/app/assets/javascripts/app/views/_queue_item.jst.eco +10 -0
- data/lib/scales-monitor/app/app/assets/javascripts/app/views/_resource.jst.eco +5 -0
- data/lib/scales-monitor/app/app/assets/javascripts/app/views/_top.jst.eco +1 -0
- data/lib/scales-monitor/app/app/assets/javascripts/app/views/log.jst.eco +11 -0
- data/lib/scales-monitor/app/app/assets/javascripts/app/views/machines.jst.eco +33 -0
- data/lib/scales-monitor/app/app/assets/javascripts/app/views/queues.jst.eco +33 -0
- data/lib/scales-monitor/app/app/assets/javascripts/app/views/resources.jst.eco +31 -0
- data/lib/scales-monitor/app/app/assets/javascripts/application.js.coffee +16 -0
- data/lib/scales-monitor/app/app/assets/javascripts/lib/bootstrap.js +1825 -0
- data/lib/scales-monitor/app/app/assets/javascripts/lib/jquery.js +4 -0
- data/lib/scales-monitor/app/app/assets/javascripts/lib/jquery.timeago.js +152 -0
- data/lib/scales-monitor/app/app/assets/javascripts/lib/json2.js +485 -0
- data/lib/scales-monitor/app/app/assets/javascripts/lib/spine/ajax.coffee +208 -0
- data/lib/scales-monitor/app/app/assets/javascripts/lib/spine/list.coffee +43 -0
- data/lib/scales-monitor/app/app/assets/javascripts/lib/spine/local.coffee +16 -0
- data/lib/scales-monitor/app/app/assets/javascripts/lib/spine/manager.coffee +83 -0
- data/lib/scales-monitor/app/app/assets/javascripts/lib/spine/relation.coffee +144 -0
- data/lib/scales-monitor/app/app/assets/javascripts/lib/spine/route.coffee +145 -0
- data/lib/scales-monitor/app/app/assets/javascripts/lib/spine/spine.coffee +537 -0
- data/lib/scales-monitor/app/app/assets/stylesheets/application.css.scss +58 -0
- data/lib/scales-monitor/app/app/assets/stylesheets/bootstrap-docs.css +845 -0
- data/lib/scales-monitor/app/app/assets/stylesheets/bootstrap-responsive.css +815 -0
- data/lib/scales-monitor/app/app/assets/stylesheets/bootstrap.css +4983 -0
- data/lib/scales-monitor/app/app/views/index.html.erb +45 -0
- data/lib/scales-monitor/app/config.ru +3 -0
- data/lib/scales-monitor/app/config/config.rb +17 -0
- data/lib/scales-monitor/app/config/routes.rb +13 -0
- data/lib/scales-monitor/app/public/assets/.gitignore +0 -0
- data/lib/scales-monitor/app/public/assets/application.css +6709 -0
- data/lib/scales-monitor/app/public/assets/application.js +5563 -0
- data/lib/scales-monitor/app/public/assets/glyphicons-halflings-white.png +0 -0
- data/lib/scales-monitor/app/public/assets/glyphicons-halflings.png +0 -0
- data/lib/scales-monitor/app/public/index.html +45 -0
- data/lib/scales-monitor/base.rb +17 -0
- data/lib/scales-monitor/boot/autoload.rb +5 -0
- data/lib/scales-monitor/boot/initializers/goliath.rb +3 -0
- data/lib/scales-monitor/monitor.rb +33 -0
- data/lib/scales-monitor/version.rb +5 -0
- data/lib/scales-monitor/web_socket.rb +180 -0
- data/scales-monitor.gemspec +24 -0
- data/spec/gem_spec.rb +7 -0
- data/spec/helper.rb +50 -0
- data/spec/monitor_spec.rb +50 -0
- data/spec/web_socket_spec.rb +103 -0
- metadata +174 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Thomas Fankhauser
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/bin/scales-monitor
ADDED
File without changes
|
File without changes
|
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class App.Routes extends Spine.Stack
|
2
|
+
controllers:
|
3
|
+
machines : App.Machines
|
4
|
+
queues : App.Queues
|
5
|
+
resources : App.Resources
|
6
|
+
log : App.Log
|
7
|
+
|
8
|
+
routes:
|
9
|
+
'/machines' : 'machines'
|
10
|
+
'/queues' : 'queues'
|
11
|
+
'/resources' : 'resources'
|
12
|
+
'/log' : 'log'
|
13
|
+
|
14
|
+
default: 'machines'
|
15
|
+
className: 'stack base'
|
File without changes
|
@@ -0,0 +1,58 @@
|
|
1
|
+
class App.Log extends Spine.Controller
|
2
|
+
|
3
|
+
elements:
|
4
|
+
'#events' : 'eventsDiv'
|
5
|
+
|
6
|
+
constructor: ->
|
7
|
+
super
|
8
|
+
@render()
|
9
|
+
@bindEvents()
|
10
|
+
setInterval =>
|
11
|
+
@eventsDiv.animate({ scrollTop: @eventsDiv[0].scrollHeight }, 500)
|
12
|
+
, 1000
|
13
|
+
|
14
|
+
activate: ->
|
15
|
+
@el.addClass("active")
|
16
|
+
$("li#nav_log").addClass('active')
|
17
|
+
@
|
18
|
+
|
19
|
+
deactivate: ->
|
20
|
+
@el.removeClass("active")
|
21
|
+
$("li#nav_log").removeClass('active')
|
22
|
+
@
|
23
|
+
|
24
|
+
bindEvents: ->
|
25
|
+
|
26
|
+
Spine.bind 'server_started', (event) => @add(event)
|
27
|
+
Spine.bind 'server_stopped', (event) => @add(event)
|
28
|
+
|
29
|
+
Spine.bind 'worker_started', (event) => @add(event)
|
30
|
+
Spine.bind 'worker_stopped', (event) => @add(event)
|
31
|
+
|
32
|
+
Spine.bind 'cache_started', (event) => @add(event)
|
33
|
+
Spine.bind 'cache_stopped', (event) => @add(event)
|
34
|
+
|
35
|
+
Spine.bind 'server_put_request_in_queue', (event) => @add(event)
|
36
|
+
Spine.bind 'server_took_response_from_queue', (event) => @add(event)
|
37
|
+
Spine.bind 'worker_took_request_from_queue', (event) => @add(event)
|
38
|
+
Spine.bind 'worker_put_response_in_queue', (event) => @add(event)
|
39
|
+
|
40
|
+
Spine.bind 'push_resource', (event) => @add(event)
|
41
|
+
Spine.bind 'destroy_resource', (event) => @add(event)
|
42
|
+
|
43
|
+
Spine.bind 'push_partial', (event) => @add(event)
|
44
|
+
Spine.bind 'destroy_partial', (event) => @add(event)
|
45
|
+
|
46
|
+
|
47
|
+
render: (event) ->
|
48
|
+
@html JST['app/views/log'](@)
|
49
|
+
|
50
|
+
add: (event) ->
|
51
|
+
out = "<br/><span class='date'>#{new Date().getTime()}</span> <span class='event'>#{event.type}</span>"
|
52
|
+
for item, data of event
|
53
|
+
if item == "key" or item == "safe" or item == "escape" or item == "server" or item == "color" or item == "type"
|
54
|
+
# no need for them
|
55
|
+
else
|
56
|
+
out += "<br/> -> #{item} = #{data}"
|
57
|
+
|
58
|
+
@eventsDiv.append out
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class App.Machines extends Spine.Controller
|
2
|
+
|
3
|
+
elements:
|
4
|
+
'#servers' : 'serversDiv'
|
5
|
+
'#caches' : 'cachesDiv'
|
6
|
+
'#workers' : 'workersDiv'
|
7
|
+
|
8
|
+
constructor: ->
|
9
|
+
super
|
10
|
+
[@servers, @caches, @workers] = [{}, {}, {}]
|
11
|
+
@render()
|
12
|
+
@bindEvents()
|
13
|
+
|
14
|
+
activate: ->
|
15
|
+
@el.addClass("active")
|
16
|
+
$("li#nav_machines").addClass('active')
|
17
|
+
@
|
18
|
+
|
19
|
+
deactivate: ->
|
20
|
+
@el.removeClass("active")
|
21
|
+
$("li#nav_machines").removeClass('active')
|
22
|
+
@
|
23
|
+
|
24
|
+
bindEvents: ->
|
25
|
+
|
26
|
+
Spine.bind 'server_started', (server) =>
|
27
|
+
@servers[server.id] = server
|
28
|
+
@renderMachines(@servers, @serversDiv)
|
29
|
+
|
30
|
+
Spine.bind 'server_stopped', (server) =>
|
31
|
+
delete @servers[server.id]
|
32
|
+
@renderMachines(@servers, @serversDiv)
|
33
|
+
|
34
|
+
Spine.bind 'worker_started', (worker) =>
|
35
|
+
@workers[worker.id] = worker
|
36
|
+
@renderMachines(@workers, @workersDiv)
|
37
|
+
|
38
|
+
Spine.bind 'worker_stopped', (worker) =>
|
39
|
+
delete @workers[worker.id]
|
40
|
+
@renderMachines(@workers, @workersDiv)
|
41
|
+
|
42
|
+
Spine.bind 'cache_started', (cache) =>
|
43
|
+
@caches[cache.id] = cache
|
44
|
+
@renderMachines(@caches, @cachesDiv)
|
45
|
+
|
46
|
+
Spine.bind 'cache_stopped', (cache) =>
|
47
|
+
delete @caches[cache.id]
|
48
|
+
@renderMachines(@caches, @cachesDiv)
|
49
|
+
|
50
|
+
render: ->
|
51
|
+
@html JST['app/views/machines'](@)
|
52
|
+
|
53
|
+
renderMachines: (machines, div) ->
|
54
|
+
machineAmount = 0
|
55
|
+
machineAmount += 1 for id, machine of machines
|
56
|
+
out = JST['app/views/_top']({amount: machineAmount})
|
57
|
+
|
58
|
+
out += JST['app/views/_machine'](machine) for id, machine of machines
|
59
|
+
div.html out
|
60
|
+
$("time.timeago").timeago()
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class App.Queues extends Spine.Controller
|
2
|
+
|
3
|
+
elements:
|
4
|
+
'#requests' : 'requestsDiv'
|
5
|
+
'#processing' : 'processingDiv'
|
6
|
+
'#responses' : 'responsesDiv'
|
7
|
+
|
8
|
+
constructor: ->
|
9
|
+
super
|
10
|
+
[@requests, @processing, @responses] = [{}, {}, {}]
|
11
|
+
@render()
|
12
|
+
@bindEvents()
|
13
|
+
|
14
|
+
activate: ->
|
15
|
+
@el.addClass("active")
|
16
|
+
$("li#nav_queues").addClass('active')
|
17
|
+
@
|
18
|
+
|
19
|
+
deactivate: ->
|
20
|
+
@el.removeClass("active")
|
21
|
+
$("li#nav_queues").removeClass('active')
|
22
|
+
@
|
23
|
+
|
24
|
+
bindEvents: ->
|
25
|
+
|
26
|
+
Spine.bind 'server_put_request_in_queue', (request) =>
|
27
|
+
@requests[request.id] = request
|
28
|
+
@renderQueueItems(@requests, @requestsDiv)
|
29
|
+
|
30
|
+
Spine.bind 'worker_took_request_from_queue', (request) =>
|
31
|
+
delete @requests[request.id]
|
32
|
+
@processing[request.id] = request
|
33
|
+
@renderQueueItems(@requests, @requestsDiv)
|
34
|
+
@renderQueueItems(@processing, @processingDiv)
|
35
|
+
|
36
|
+
Spine.bind 'worker_put_response_in_queue', (response) =>
|
37
|
+
delete @processing[response.id]
|
38
|
+
@responses[response.id] = response
|
39
|
+
@renderQueueItems(@processing, @processingDiv)
|
40
|
+
@renderQueueItems(@responses, @responsesDiv)
|
41
|
+
|
42
|
+
Spine.bind 'server_took_response_from_queue', (response) =>
|
43
|
+
delete @responses[response.id]
|
44
|
+
@renderQueueItems(@responses, @responsesDiv)
|
45
|
+
|
46
|
+
render: ->
|
47
|
+
@html JST['app/views/queues'](@)
|
48
|
+
|
49
|
+
renderQueueItems: (items, div) ->
|
50
|
+
itemAmount = 0
|
51
|
+
itemAmount += 1 for id, item of items
|
52
|
+
out = JST['app/views/_top']({amount: itemAmount})
|
53
|
+
|
54
|
+
out += JST['app/views/_queue_item'](item) for id, item of items
|
55
|
+
div.html out
|
@@ -0,0 +1,128 @@
|
|
1
|
+
class App.Resources extends Spine.Controller
|
2
|
+
|
3
|
+
elements:
|
4
|
+
'#resources' : 'resourcesDiv'
|
5
|
+
'#partials' : 'partialsDiv'
|
6
|
+
'#content_types' : 'contentTypesDiv'
|
7
|
+
|
8
|
+
constructor: ->
|
9
|
+
super
|
10
|
+
[@resources, @partials, @servers] = [{}, {}, {}]
|
11
|
+
@colors = {}
|
12
|
+
@bindColors()
|
13
|
+
@render()
|
14
|
+
@bindEvents()
|
15
|
+
|
16
|
+
activate: ->
|
17
|
+
@el.addClass("active")
|
18
|
+
$("li#nav_resources").addClass('active')
|
19
|
+
@
|
20
|
+
|
21
|
+
deactivate: ->
|
22
|
+
@el.removeClass("active")
|
23
|
+
$("li#nav_resources").removeClass('active')
|
24
|
+
@
|
25
|
+
|
26
|
+
bindColors: ->
|
27
|
+
@colors =
|
28
|
+
'HTML' : '#EDFFA3'
|
29
|
+
'CSS' : '#A3E2FF'
|
30
|
+
'JS' : '#FFDAA3'
|
31
|
+
'JSON' : '#FFA3A3'
|
32
|
+
'XML' : '#A3FFE5'
|
33
|
+
'PDF' : '#FFA3E2'
|
34
|
+
'TXT' : '#C0A3FF'
|
35
|
+
'PNG' : '#FFC4EE'
|
36
|
+
'JPG' : '#C4FFF3'
|
37
|
+
'ZIP' : '#FDFFC4'
|
38
|
+
|
39
|
+
bindEvents: ->
|
40
|
+
|
41
|
+
Spine.bind 'push_resource', (resource) =>
|
42
|
+
@resources[resource.path] = resource
|
43
|
+
@renderResources(@resources, @resourcesDiv)
|
44
|
+
|
45
|
+
Spine.bind 'destroy_resource', (resource) =>
|
46
|
+
delete @resources[resource.path]
|
47
|
+
@renderResources(@resources, @resourcesDiv)
|
48
|
+
|
49
|
+
Spine.bind 'push_partial', (partial) =>
|
50
|
+
@partials[partial.path] = partial
|
51
|
+
@renderResources(@partials, @partialsDiv)
|
52
|
+
|
53
|
+
Spine.bind 'destroy_partial', (partial) =>
|
54
|
+
delete @partials[partial.path]
|
55
|
+
@renderResources(@partials, @partialsDiv)
|
56
|
+
|
57
|
+
Spine.bind 'server_started', (server) =>
|
58
|
+
@servers[server.id] = server
|
59
|
+
@renderResources(@resources, @resourcesDiv)
|
60
|
+
|
61
|
+
Spine.bind 'server_stopped', (server) =>
|
62
|
+
delete @servers[server.id]
|
63
|
+
@renderResources(@resources, @resourcesDiv)
|
64
|
+
|
65
|
+
render: ->
|
66
|
+
@html JST['app/views/resources'](@)
|
67
|
+
|
68
|
+
renderResources: (resources, div) ->
|
69
|
+
resourceAmount = 0
|
70
|
+
resourceAmount += 1 for id, resource of resources
|
71
|
+
out = JST['app/views/_top']({amount: resourceAmount})
|
72
|
+
|
73
|
+
resourcesArray = []
|
74
|
+
resourcesArray.push(resource) for id, resource of resources
|
75
|
+
resourcesArray.sort (a, b) ->
|
76
|
+
return -1 if a.format < b.format
|
77
|
+
return 1 if a.format > b.format
|
78
|
+
0
|
79
|
+
|
80
|
+
@i = 0
|
81
|
+
for resource in resourcesArray
|
82
|
+
out += "<div class='row'>" if @i == 0
|
83
|
+
resource.color = @colors[resource.format]
|
84
|
+
resource.server = server for id, server of @servers
|
85
|
+
out += JST['app/views/_resource'](resource)
|
86
|
+
@i += 1
|
87
|
+
if @i == 4
|
88
|
+
out += "</div>"
|
89
|
+
@i = 0
|
90
|
+
|
91
|
+
div.html out
|
92
|
+
div.tooltip({ selector: "a" })
|
93
|
+
@renderContentTypes()
|
94
|
+
|
95
|
+
processContentTypes: ->
|
96
|
+
formats = {}
|
97
|
+
total = 0
|
98
|
+
for id, resource of @resources
|
99
|
+
total += 1
|
100
|
+
if not formats[resource.format] then formats[resource.format] = { amount: 1 } else formats[resource.format].amount += 1
|
101
|
+
|
102
|
+
for id, partial of @partials
|
103
|
+
total += 1
|
104
|
+
if not formats[partial.format] then formats[partial.format] = { amount: 1 } else formats[partial.format].amount += 1
|
105
|
+
|
106
|
+
formatsArray = []
|
107
|
+
for format, model of formats
|
108
|
+
model.format = format
|
109
|
+
model.progress = (model.amount / total) * 100
|
110
|
+
model.color = @colors[model.format]
|
111
|
+
formatsArray.push(model)
|
112
|
+
|
113
|
+
formatsArray.sort (a, b) ->
|
114
|
+
return 1 if a.progress < b.progress
|
115
|
+
return -1 if a.progress > b.progress
|
116
|
+
0
|
117
|
+
|
118
|
+
[formatsArray, total]
|
119
|
+
|
120
|
+
renderContentTypes: ->
|
121
|
+
[formats, total] = @processContentTypes()
|
122
|
+
|
123
|
+
out = JST['app/views/_top']({amount: total})
|
124
|
+
out += JST['app/views/_format_bar'](format) for format in formats
|
125
|
+
@contentTypesDiv.html out
|
126
|
+
|
127
|
+
|
128
|
+
|
File without changes
|