visage-app 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/README.md +138 -0
- data/Rakefile +33 -0
- data/VERSION +1 -0
- data/bin/visage +17 -0
- data/config.ru +7 -0
- data/features/json.feature +66 -0
- data/features/site.feature +9 -0
- data/features/step_definitions/form_steps.rb +6 -0
- data/features/step_definitions/json_steps.rb +79 -0
- data/features/step_definitions/result_steps.rb +19 -0
- data/features/step_definitions/site_steps.rb +4 -0
- data/features/step_definitions/visage_steps.rb +20 -0
- data/features/step_definitions/webrat_steps.rb +42 -0
- data/features/support/env.rb +36 -0
- data/features/visage.feature +11 -0
- data/lib/visage/collectd/json.rb +142 -0
- data/lib/visage/collectd/profile.rb +36 -0
- data/lib/visage/config/fallback-colors.yaml +82 -0
- data/lib/visage/config/init.rb +33 -0
- data/lib/visage/config/plugin-colors.yaml +63 -0
- data/lib/visage/config/profiles.yaml +35 -0
- data/lib/visage/config/profiles.yaml.sample +33 -0
- data/lib/visage/config.rb +51 -0
- data/lib/visage/patches.rb +18 -0
- data/lib/visage/public/favicon.gif +0 -0
- data/lib/visage/public/javascripts/application.js +4 -0
- data/lib/visage/public/javascripts/g.line.js +217 -0
- data/lib/visage/public/javascripts/g.raphael.js +7 -0
- data/lib/visage/public/javascripts/graph.js +510 -0
- data/lib/visage/public/javascripts/mootools-1.2.3-core.js +4036 -0
- data/lib/visage/public/javascripts/mootools-1.2.3.1-more.js +104 -0
- data/lib/visage/public/javascripts/raphael-min.js +7 -0
- data/lib/visage/public/javascripts/raphael.js +3215 -0
- data/lib/visage/public/stylesheets/screen.css +96 -0
- data/lib/visage/views/index.haml +48 -0
- data/lib/visage/views/layout.haml +22 -0
- data/lib/visage/views/single.haml +43 -0
- data/lib/visage-app.rb +81 -0
- metadata +142 -0
@@ -0,0 +1,96 @@
|
|
1
|
+
/* resets */
|
2
|
+
body {
|
3
|
+
font-size: 62.5%;
|
4
|
+
}
|
5
|
+
|
6
|
+
* {
|
7
|
+
margin: 0;
|
8
|
+
padding: 0;
|
9
|
+
}
|
10
|
+
|
11
|
+
a {
|
12
|
+
text-decoration: none;
|
13
|
+
}
|
14
|
+
|
15
|
+
/* styles */
|
16
|
+
|
17
|
+
a { color: #3465a4; padding: 2px 0px; }
|
18
|
+
a:hover { color: white; background-color: #3465a4; }
|
19
|
+
a:visited { color: #75507b; }
|
20
|
+
a:hover:visited { color: white; background-color: #75507b; }
|
21
|
+
a:active { color: white; background-color: #cc0000; }
|
22
|
+
|
23
|
+
p {
|
24
|
+
margin: 0 0 1em;
|
25
|
+
}
|
26
|
+
|
27
|
+
li {
|
28
|
+
margin: 0.55em 0 0.55em 1em;
|
29
|
+
list-style-type: none;
|
30
|
+
}
|
31
|
+
|
32
|
+
body {
|
33
|
+
font-family: Bitstream Vera Serif, Baskerville, Garamond, serif;
|
34
|
+
font-size: 1.2em;
|
35
|
+
}
|
36
|
+
|
37
|
+
div#header {
|
38
|
+
float: left;
|
39
|
+
width: 20em;
|
40
|
+
}
|
41
|
+
|
42
|
+
div.nav {
|
43
|
+
float: left;
|
44
|
+
margin: 1em;
|
45
|
+
margin-right: 2em;
|
46
|
+
}
|
47
|
+
|
48
|
+
div.nav li {
|
49
|
+
margin-left: 2px;
|
50
|
+
}
|
51
|
+
|
52
|
+
div#header {
|
53
|
+
margin: 1em 0.5em;
|
54
|
+
}
|
55
|
+
|
56
|
+
div#graphs {
|
57
|
+
clear: both;
|
58
|
+
padding: 0 2em;
|
59
|
+
border-top: 1px dashed #babdb6;
|
60
|
+
margin-top: 2em;
|
61
|
+
}
|
62
|
+
|
63
|
+
div.graph {
|
64
|
+
margin: 0.5em 0;
|
65
|
+
clear: both;
|
66
|
+
}
|
67
|
+
|
68
|
+
h1, h2, h3, h4, h5 {
|
69
|
+
font-family: Bitstream Vera Sans, Helvetica Neue, sans-serif;
|
70
|
+
}
|
71
|
+
|
72
|
+
h2, h3, h4, h5 {
|
73
|
+
/*text-transform: uppercase;*/
|
74
|
+
}
|
75
|
+
|
76
|
+
h1 {
|
77
|
+
font-size: 4em;
|
78
|
+
}
|
79
|
+
|
80
|
+
h1 span.project-name {
|
81
|
+
padding: 0 0.1em 0.1em;
|
82
|
+
background-color: #3465a4;
|
83
|
+
color: white;
|
84
|
+
}
|
85
|
+
|
86
|
+
div#footer {
|
87
|
+
font-size: 0.6em;
|
88
|
+
color: gray;
|
89
|
+
text-align: center;
|
90
|
+
margin-bottom: 2em;
|
91
|
+
}
|
92
|
+
|
93
|
+
div#nothing {
|
94
|
+
margin-top: 1em;
|
95
|
+
}
|
96
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
%div#nav
|
2
|
+
%div#hosts.nav
|
3
|
+
%h2 Hosts
|
4
|
+
%ul
|
5
|
+
- if !Visage::Config.rrddir
|
6
|
+
%li
|
7
|
+
You need to specify <strong>rrddir</strong> in config/init.rb!
|
8
|
+
- elsif @hosts.empty?
|
9
|
+
%li
|
10
|
+
No hosts found. Please check <strong>rrddir</strong> in config/init.rb!
|
11
|
+
- else
|
12
|
+
- @hosts.each do |host|
|
13
|
+
%li
|
14
|
+
%a{:href => "/#{host}"}= host
|
15
|
+
|
16
|
+
- if host = params[:host]
|
17
|
+
%div#profiles.nav
|
18
|
+
%h2 Profiles
|
19
|
+
|
20
|
+
%ul
|
21
|
+
- @profiles.each do |profile|
|
22
|
+
%li
|
23
|
+
%a{:href => "/#{host}/#{profile.splat}"}= profile.name
|
24
|
+
|
25
|
+
%div#graphs
|
26
|
+
- if @profile && @profile.plugins
|
27
|
+
- @profile.plugins.each do |graph|
|
28
|
+
- plugin, plugin_instances = graph.split('/', 2)
|
29
|
+
- graph_id = "graph#{graph.gsub(/[^\w+]/, '_')}"
|
30
|
+
%div.graph
|
31
|
+
%div{:id => graph_id}
|
32
|
+
:javascript
|
33
|
+
window.addEvent('domready', function() {
|
34
|
+
var graph = new visageGraph('#{graph_id}', '#{params[:host]}', '#{plugin}', {
|
35
|
+
width: 900,
|
36
|
+
height: 220,
|
37
|
+
gridWidth: 800,
|
38
|
+
gridHeight: 200,
|
39
|
+
shade: #{Visage::Config.shade || false},
|
40
|
+
pluginInstance: '#{plugin_instances || ''}',
|
41
|
+
name: '#{plugin} on #{host}'
|
42
|
+
});
|
43
|
+
});
|
44
|
+
|
45
|
+
- else
|
46
|
+
%div#nothing
|
47
|
+
Sorry, nothing to display!
|
48
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
!!!
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%title Visage
|
5
|
+
%link{:rel => "icon", :type => "image/gif", :href => "/favicon.gif"}
|
6
|
+
%link{:rel => 'stylesheet', :href => '/stylesheets/screen.css', :type => 'text/css'}
|
7
|
+
%script{:type => "text/javascript", :src => "/javascripts/raphael-min.js"}
|
8
|
+
%script{:type => "text/javascript", :src => "/javascripts/g.raphael.js"}
|
9
|
+
%script{:type => "text/javascript", :src => "/javascripts/g.line.js"}
|
10
|
+
%script{:type => "text/javascript", :src => "/javascripts/mootools-1.2.3-core.js"}
|
11
|
+
%script{:type => "text/javascript", :src => "/javascripts/mootools-1.2.3.1-more.js"}
|
12
|
+
%script{:type => "text/javascript", :src => "/javascripts/graph.js"}
|
13
|
+
%script{:type => "text/javascript", :src => "/javascripts/application.js"}
|
14
|
+
|
15
|
+
%body
|
16
|
+
%div#wrapper
|
17
|
+
%div#header
|
18
|
+
%h1.project
|
19
|
+
%span.project-name Visage
|
20
|
+
%div#content
|
21
|
+
= yield
|
22
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
%div#header
|
2
|
+
%h1 Visage
|
3
|
+
|
4
|
+
%div#single
|
5
|
+
%h3 Graph
|
6
|
+
%div.labels.container
|
7
|
+
%div#graph.holder
|
8
|
+
:javascript
|
9
|
+
window.addEvent('domready', function() {
|
10
|
+
var graph = new visageGraph('graph', 'theodor', 'cpu-0', {
|
11
|
+
width: 900,
|
12
|
+
height: 220,
|
13
|
+
gridWidth: 800,
|
14
|
+
gridHeight: 200
|
15
|
+
});
|
16
|
+
});
|
17
|
+
|
18
|
+
%h3 Load
|
19
|
+
%div.labels.container
|
20
|
+
%div#graph-load.holder
|
21
|
+
:javascript
|
22
|
+
window.addEvent('domready', function() {
|
23
|
+
var graph = new visageGraph('graph-load', 'theodor', 'load', {
|
24
|
+
width: 900,
|
25
|
+
height: 220,
|
26
|
+
gridWidth: 800,
|
27
|
+
gridHeight: 200
|
28
|
+
});
|
29
|
+
});
|
30
|
+
|
31
|
+
%h3 Memory
|
32
|
+
%div.labels.container
|
33
|
+
%div#graph-memory.holder
|
34
|
+
:javascript
|
35
|
+
window.addEvent('domready', function() {
|
36
|
+
var graph = new visageGraph('graph-memory', 'theodor', 'memory', {
|
37
|
+
width: 900,
|
38
|
+
height: 220,
|
39
|
+
gridWidth: 800,
|
40
|
+
gridHeight: 200
|
41
|
+
});
|
42
|
+
});
|
43
|
+
|
data/lib/visage-app.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
@root = Pathname.new(File.dirname(__FILE__)).expand_path
|
5
|
+
$: << @root.to_s
|
6
|
+
|
7
|
+
require 'sinatra'
|
8
|
+
require 'errand'
|
9
|
+
require 'yajl'
|
10
|
+
require 'haml'
|
11
|
+
require 'visage/collectd/json'
|
12
|
+
require 'visage/config'
|
13
|
+
|
14
|
+
set :public, @root.join('visage/public')
|
15
|
+
set :views, @root.join('visage/views')
|
16
|
+
|
17
|
+
configure do
|
18
|
+
require 'visage/config/init'
|
19
|
+
|
20
|
+
CollectdJSON.rrddir = Visage::Config.rrddir
|
21
|
+
Visage::Config::Profiles.profiles = Visage::Config.profiles
|
22
|
+
end
|
23
|
+
|
24
|
+
# infrastructure for embedding
|
25
|
+
get '/javascripts/visage.js' do
|
26
|
+
javascript = ""
|
27
|
+
%w{raphael-min g.raphael g.line mootools-1.2.3-core mootools-1.2.3.1-more graph}.each do |js|
|
28
|
+
javascript += File.read(File.join(__DIR__, 'public', 'javascripts', "#{js}.js"))
|
29
|
+
end
|
30
|
+
javascript
|
31
|
+
end
|
32
|
+
|
33
|
+
# user facing
|
34
|
+
get '/' do
|
35
|
+
@hosts = CollectdJSON.hosts
|
36
|
+
haml :index
|
37
|
+
end
|
38
|
+
|
39
|
+
get '/:host' do
|
40
|
+
@hosts = CollectdJSON.hosts
|
41
|
+
@profiles = Visage::Config::Profiles.all
|
42
|
+
|
43
|
+
haml :index
|
44
|
+
end
|
45
|
+
|
46
|
+
get '/:host/:profile' do
|
47
|
+
@hosts = CollectdJSON.hosts
|
48
|
+
@profiles = Visage::Config::Profiles.all
|
49
|
+
@profile = Visage::Config::Profiles.get(params[:profile])
|
50
|
+
|
51
|
+
haml :index
|
52
|
+
end
|
53
|
+
|
54
|
+
# JSON data backend
|
55
|
+
|
56
|
+
# /data/:host/:plugin/:optional_plugin_instance
|
57
|
+
get %r{/data/([^/]+)/([^/]+)((/[^/]+)*)} do
|
58
|
+
host = params[:captures][0]
|
59
|
+
plugin = params[:captures][1]
|
60
|
+
plugin_instances = params[:captures][2]
|
61
|
+
|
62
|
+
collectd = CollectdJSON.new(:rrddir => Visage::Config.rrddir,
|
63
|
+
:fallback_colors => Visage::Config.fallback_colors)
|
64
|
+
json = collectd.json(:host => host,
|
65
|
+
:plugin => plugin,
|
66
|
+
:plugin_instances => plugin_instances,
|
67
|
+
:start => params[:start],
|
68
|
+
:finish => params[:finish],
|
69
|
+
:plugin_colors => Visage::Config.plugin_colors)
|
70
|
+
# if the request is cross-domain, we need to serve JSONP
|
71
|
+
maybe_wrap_with_callback(json)
|
72
|
+
end
|
73
|
+
|
74
|
+
# wraps json with a callback method that JSONP clients can call
|
75
|
+
def maybe_wrap_with_callback(json)
|
76
|
+
if params[:callback]
|
77
|
+
params[:callback] + '(' + json + ')'
|
78
|
+
else
|
79
|
+
json
|
80
|
+
end
|
81
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: visage-app
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lindsay Holmwood
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-06-24 00:00:00 -07:00
|
13
|
+
default_executable: visage
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: sinatra
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - "="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "1.0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: tilt
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.1
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: haml
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 3.0.13
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: errand
|
47
|
+
type: :runtime
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.7.2
|
54
|
+
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: yajl-ruby
|
57
|
+
type: :runtime
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 0.7.6
|
64
|
+
version:
|
65
|
+
description: Visage is a web interface for viewing collectd statistics. It also provides a JSON interface onto collectd's RRD data, giving you an easy way to mash up the data.
|
66
|
+
email: lindsay@holmwood.id.au
|
67
|
+
executables:
|
68
|
+
- visage
|
69
|
+
extensions: []
|
70
|
+
|
71
|
+
extra_rdoc_files:
|
72
|
+
- README.md
|
73
|
+
files:
|
74
|
+
- .gitignore
|
75
|
+
- README.md
|
76
|
+
- Rakefile
|
77
|
+
- VERSION
|
78
|
+
- bin/visage
|
79
|
+
- config.ru
|
80
|
+
- features/json.feature
|
81
|
+
- features/site.feature
|
82
|
+
- features/step_definitions/form_steps.rb
|
83
|
+
- features/step_definitions/json_steps.rb
|
84
|
+
- features/step_definitions/result_steps.rb
|
85
|
+
- features/step_definitions/site_steps.rb
|
86
|
+
- features/step_definitions/visage_steps.rb
|
87
|
+
- features/step_definitions/webrat_steps.rb
|
88
|
+
- features/support/env.rb
|
89
|
+
- features/visage.feature
|
90
|
+
- lib/visage-app.rb
|
91
|
+
- lib/visage/collectd/json.rb
|
92
|
+
- lib/visage/collectd/profile.rb
|
93
|
+
- lib/visage/config.rb
|
94
|
+
- lib/visage/config/fallback-colors.yaml
|
95
|
+
- lib/visage/config/init.rb
|
96
|
+
- lib/visage/config/plugin-colors.yaml
|
97
|
+
- lib/visage/config/profiles.yaml
|
98
|
+
- lib/visage/config/profiles.yaml.sample
|
99
|
+
- lib/visage/patches.rb
|
100
|
+
- lib/visage/public/favicon.gif
|
101
|
+
- lib/visage/public/javascripts/application.js
|
102
|
+
- lib/visage/public/javascripts/g.line.js
|
103
|
+
- lib/visage/public/javascripts/g.raphael.js
|
104
|
+
- lib/visage/public/javascripts/graph.js
|
105
|
+
- lib/visage/public/javascripts/mootools-1.2.3-core.js
|
106
|
+
- lib/visage/public/javascripts/mootools-1.2.3.1-more.js
|
107
|
+
- lib/visage/public/javascripts/raphael-min.js
|
108
|
+
- lib/visage/public/javascripts/raphael.js
|
109
|
+
- lib/visage/public/stylesheets/screen.css
|
110
|
+
- lib/visage/views/index.haml
|
111
|
+
- lib/visage/views/layout.haml
|
112
|
+
- lib/visage/views/single.haml
|
113
|
+
has_rdoc: true
|
114
|
+
homepage: http://github.com/auxesis/visage
|
115
|
+
licenses: []
|
116
|
+
|
117
|
+
post_install_message:
|
118
|
+
rdoc_options:
|
119
|
+
- --charset=UTF-8
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: "0"
|
127
|
+
version:
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: "0"
|
133
|
+
version:
|
134
|
+
requirements: []
|
135
|
+
|
136
|
+
rubyforge_project:
|
137
|
+
rubygems_version: 1.3.5
|
138
|
+
signing_key:
|
139
|
+
specification_version: 3
|
140
|
+
summary: a web (interface | service) for viewing collectd statistics
|
141
|
+
test_files: []
|
142
|
+
|