pimon 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -1
- data/Gemfile.lock +28 -17
- data/README.md +1 -1
- data/bin/pimon +7 -2
- data/config/{development.yml → default.yml} +0 -0
- data/config/deploy.rb +1 -1
- data/lib/pimon.rb +27 -8
- data/lib/pimon/public/index.js +120 -0
- data/lib/pimon/stats_collector.rb +7 -7
- data/lib/pimon/version.rb +1 -1
- data/lib/pimon/views/index.haml +1 -2
- data/pimon.gemspec +14 -13
- data/spec/stats_collector_spec.rb +3 -2
- metadata +36 -35
- data/lib/pimon/views/index.js.haml +0 -111
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,26 +1,32 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
4
|
+
addressable (2.3.2)
|
5
|
+
capistrano (2.13.4)
|
5
6
|
highline
|
6
7
|
net-scp (>= 1.0.0)
|
7
8
|
net-sftp (>= 2.0.0)
|
8
9
|
net-ssh (>= 2.0.14)
|
9
10
|
net-ssh-gateway (>= 1.1.0)
|
10
|
-
coderay (1.0.
|
11
|
+
coderay (1.0.8)
|
11
12
|
daemons (1.1.9)
|
12
13
|
diff-lcs (1.1.3)
|
13
|
-
|
14
|
+
em-websocket (0.3.8)
|
15
|
+
addressable (>= 2.1.1)
|
16
|
+
eventmachine (>= 0.12.9)
|
17
|
+
eventmachine (1.0.0)
|
14
18
|
haml (3.1.7)
|
15
|
-
highline (1.6.
|
19
|
+
highline (1.6.15)
|
20
|
+
jruby-pageant (1.1.1)
|
16
21
|
method_source (0.8)
|
17
|
-
mock_redis (0.5.
|
18
|
-
multi_json (1.
|
22
|
+
mock_redis (0.5.2)
|
23
|
+
multi_json (1.3.6)
|
19
24
|
net-scp (1.0.4)
|
20
25
|
net-ssh (>= 1.99.1)
|
21
26
|
net-sftp (2.0.5)
|
22
27
|
net-ssh (>= 2.0.9)
|
23
|
-
net-ssh (2.
|
28
|
+
net-ssh (2.6.0)
|
29
|
+
jruby-pageant (>= 1.1.1)
|
24
30
|
net-ssh-gateway (1.1.0)
|
25
31
|
net-ssh (>= 1.99.1)
|
26
32
|
pry (0.9.10)
|
@@ -30,34 +36,38 @@ GEM
|
|
30
36
|
rack (1.4.1)
|
31
37
|
rack-protection (1.2.0)
|
32
38
|
rack
|
33
|
-
rack-test (0.6.
|
39
|
+
rack-test (0.6.2)
|
34
40
|
rack (>= 1.0)
|
35
|
-
redis (3.0.
|
41
|
+
redis (3.0.2)
|
36
42
|
rspec (2.11.0)
|
37
43
|
rspec-core (~> 2.11.0)
|
38
44
|
rspec-expectations (~> 2.11.0)
|
39
45
|
rspec-mocks (~> 2.11.0)
|
40
46
|
rspec-core (2.11.1)
|
41
|
-
rspec-expectations (2.11.
|
47
|
+
rspec-expectations (2.11.3)
|
42
48
|
diff-lcs (~> 1.1.3)
|
43
|
-
rspec-mocks (2.11.
|
44
|
-
simplecov (0.6.
|
49
|
+
rspec-mocks (2.11.3)
|
50
|
+
simplecov (0.6.4)
|
45
51
|
multi_json (~> 1.0)
|
46
52
|
simplecov-html (~> 0.5.3)
|
47
53
|
simplecov-html (0.5.3)
|
48
54
|
simplecov-rcov (0.2.3)
|
49
55
|
simplecov (>= 0.4.1)
|
50
|
-
sinatra (1.3.
|
56
|
+
sinatra (1.3.3)
|
51
57
|
rack (~> 1.3, >= 1.3.6)
|
52
58
|
rack-protection (~> 1.2)
|
53
59
|
tilt (~> 1.3, >= 1.3.3)
|
54
|
-
|
55
|
-
|
60
|
+
sinatra-websocket (0.2.0)
|
61
|
+
em-websocket (>= 0.3.6)
|
62
|
+
eventmachine
|
63
|
+
thin (>= 1.3.1)
|
64
|
+
slop (3.3.3)
|
65
|
+
thin (1.5.0)
|
56
66
|
daemons (>= 1.0.9)
|
57
67
|
eventmachine (>= 0.12.6)
|
58
68
|
rack (>= 1.0.0)
|
59
69
|
tilt (1.3.3)
|
60
|
-
timecop (0.
|
70
|
+
timecop (0.5.2)
|
61
71
|
|
62
72
|
PLATFORMS
|
63
73
|
ruby
|
@@ -73,5 +83,6 @@ DEPENDENCIES
|
|
73
83
|
simplecov
|
74
84
|
simplecov-rcov
|
75
85
|
sinatra
|
76
|
-
|
86
|
+
sinatra-websocket (~> 0.2.0)
|
87
|
+
thin (~> 1.5.0)
|
77
88
|
timecop
|
data/README.md
CHANGED
@@ -59,7 +59,7 @@ They just change and generate some random values on the observed stats using /de
|
|
59
59
|
To use them you must first compile them using _make_ and then include the bin directory of this project
|
60
60
|
in your $PATH to have them available when you run the sinatra application.
|
61
61
|
The temperature stat is only available with the latest Raspbian distro (2012-09-18) on your Raspberry Pi and will (may)
|
62
|
-
not work if you're developing on other systems.
|
62
|
+
not work if you're developing on other systems.
|
63
63
|
Pimon only works with Ruby 1.9+, please refer to [my blog](http://blog.pedrocarrico.net/post/29478085586/compiling-and-installing-ruby-on-the-raspberry-pi-using "Compiling and installing ruby on the raspberry pi using rbenv…") for a way to install Ruby 1.9.3 on your Raspberry Pi.
|
64
64
|
|
65
65
|
## Deployment with capistrano
|
data/bin/pimon
CHANGED
@@ -56,10 +56,15 @@ begin
|
|
56
56
|
options[:environment] ? ENV['RACK_ENV'] = options[:environment] : ENV['RACK_ENV'] = 'development'
|
57
57
|
config = "#{File.dirname(__FILE__)}/../config/config.ru"
|
58
58
|
ENV['PIMON_CONFIG'] = options[:pimon_config] if options[:pimon_config]
|
59
|
-
|
60
59
|
puts "Pimon is starting at http://localhost:#{port}"
|
61
60
|
puts "Running in #{ENV['RACK_ENV']} mode."
|
62
|
-
|
61
|
+
|
62
|
+
if ENV['PIMON_CONFIG']
|
63
|
+
puts "Using configuration file #{ENV['PIMON_CONFIG']}"
|
64
|
+
else
|
65
|
+
puts "Using default configuration"
|
66
|
+
end
|
67
|
+
|
63
68
|
server = Rack::Server.new(:config => config, :daemonize => options[:daemonize], :pid => pid_file, :Port => port, :server => 'thin')
|
64
69
|
server.start
|
65
70
|
when 'stop'
|
File without changes
|
data/config/deploy.rb
CHANGED
@@ -19,7 +19,7 @@ after 'deploy:update_code', 'deploy:bundle_install'
|
|
19
19
|
|
20
20
|
namespace :deploy do
|
21
21
|
task :start, :roles => [:web, :app] do
|
22
|
-
run "cd #{deploy_to}/current && nohup thin -C config/thin/config.yml -R config/config.ru start"
|
22
|
+
run "cd #{deploy_to}/current && && PIMON_CONFIG=#{deploy_to}/current/config/production.yml nohup thin -C config/thin/config.yml -R config/config.ru start"
|
23
23
|
end
|
24
24
|
|
25
25
|
task :stop, :roles => [:web, :app] do
|
data/lib/pimon.rb
CHANGED
@@ -5,14 +5,17 @@ if File.file?('Gemfile')
|
|
5
5
|
Bundler.require(:default, ENV['RACK_ENV'])
|
6
6
|
end
|
7
7
|
require 'eventmachine'
|
8
|
+
require 'json'
|
8
9
|
require 'haml'
|
9
10
|
require 'pimon/pimon_config'
|
10
11
|
require 'pimon/stats_collector'
|
11
12
|
require 'sinatra'
|
13
|
+
require 'sinatra-websocket'
|
12
14
|
|
13
15
|
class Pimon < Sinatra::Base
|
14
16
|
set :public_folder, "#{File.dirname(__FILE__)}/pimon/public"
|
15
17
|
set :views, "#{File.dirname(__FILE__)}/pimon/views"
|
18
|
+
set :sockets, []
|
16
19
|
|
17
20
|
def self.configure_basic_auth
|
18
21
|
if settings.config.is_basic_auth_enabled?
|
@@ -24,13 +27,15 @@ class Pimon < Sinatra::Base
|
|
24
27
|
|
25
28
|
configure :development, :production do
|
26
29
|
require 'redis'
|
27
|
-
filename = "#{File.dirname(__FILE__)}/../config
|
30
|
+
filename = "#{File.dirname(__FILE__)}/../config/default.yml"
|
28
31
|
config = PimonConfig.create_new(ENV['PIMON_CONFIG'] || filename)
|
29
32
|
|
30
33
|
EventMachine::next_tick do
|
31
34
|
settings.timer = EventMachine::add_periodic_timer(config.stats[:time_period_in_min] * 60) do
|
32
35
|
settings.stats_checker.collect_stats
|
33
|
-
@
|
36
|
+
@stats = settings.stats_checker.show_stats
|
37
|
+
|
38
|
+
settings.sockets.each{ |s| s.send(@stats) }
|
34
39
|
end
|
35
40
|
end
|
36
41
|
|
@@ -54,11 +59,25 @@ class Pimon < Sinatra::Base
|
|
54
59
|
end
|
55
60
|
|
56
61
|
get '/' do
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
62
|
+
if !request.websocket?
|
63
|
+
last_update = settings.stats_checker.last_update
|
64
|
+
last_modified(last_update) if ENV['RACK_ENV'] != 'development' && last_update
|
65
|
+
|
66
|
+
haml :index
|
67
|
+
else
|
68
|
+
request.websocket do |ws|
|
69
|
+
ws.onopen do
|
70
|
+
settings.sockets << ws
|
71
|
+
@stats ||= settings.stats_checker.show_stats
|
72
|
+
ws.send(@stats)
|
73
|
+
end
|
74
|
+
ws.onmessage do |msg|
|
75
|
+
puts "message received!! -> #{msg}"
|
76
|
+
end
|
77
|
+
ws.onclose do
|
78
|
+
settings.sockets.delete(ws)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
63
82
|
end
|
64
83
|
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
$(function () {
|
2
|
+
var i = 0,
|
3
|
+
titleStats,
|
4
|
+
rotateFaviconInterval;
|
5
|
+
|
6
|
+
function changeFavicon(o) {
|
7
|
+
titleStats = [
|
8
|
+
{ 'legend' : 'CPU', 'stat' : o.cpu.stats[o.cpu.stats.length - 1], 'color' : o.cpu.color, 'unit' : o.cpu.unit } ,
|
9
|
+
{ 'legend' : 'MEM', 'stat' : o.mem.stats[o.mem.stats.length - 1], 'color' : o.mem.color, 'unit' : o.mem.unit } ,
|
10
|
+
{ 'legend' : 'SWAP', 'stat' : o.swap.stats[o.swap.stats.length - 1], 'color' : o.swap.color, 'unit' : o.swap.unit},
|
11
|
+
{ 'legend' : 'DISK', 'stat' : o.disk.stats[o.disk.stats.length - 1], 'color' : o.disk.color, 'unit' : o.disk.unit},
|
12
|
+
{ 'legend' : 'TEMP', 'stat' : o.temp.stats[o.temp.stats.length - 1], 'color' : o.temp.color, 'unit' : o.temp.unit} ];
|
13
|
+
i = 0;
|
14
|
+
if (rotateFaviconInterval === undefined) {
|
15
|
+
rotateFavicon(titleStats);
|
16
|
+
rotateFaviconInterval = setInterval(function() { rotateFavicon(titleStats); }, 3000);
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
function rotateFavicon(titleStats) {
|
21
|
+
Piecon.setOptions({
|
22
|
+
color: titleStats[i]['color'], // Pie chart color
|
23
|
+
background: '#bbb', // Empty pie chart color
|
24
|
+
shadow: '#fff', // Outer ring color
|
25
|
+
fallback: 'force' // Toggles displaying percentage in the title bar (possible values - true, false, 'force')
|
26
|
+
});
|
27
|
+
Piecon.setProgress(titleStats[i]['stat']);
|
28
|
+
|
29
|
+
$('title').text(titleStats[i]['stat'] + titleStats[i]['unit'] + ' ' + titleStats[i]['legend']);
|
30
|
+
i++;
|
31
|
+
if (i >= titleStats.length) {
|
32
|
+
i = 0;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
function drawChart(o) {
|
37
|
+
new Highcharts.Chart({
|
38
|
+
chart: {
|
39
|
+
renderTo: 'chart',
|
40
|
+
type: 'line',
|
41
|
+
marginRight: 130,
|
42
|
+
marginBottom: 25
|
43
|
+
},
|
44
|
+
title: {
|
45
|
+
text: 'Pimon',
|
46
|
+
x: -20
|
47
|
+
},
|
48
|
+
subtitle: {
|
49
|
+
text: 'My raspberry PI',
|
50
|
+
x: -20
|
51
|
+
},
|
52
|
+
xAxis: {
|
53
|
+
categories: o.time.stats
|
54
|
+
},
|
55
|
+
yAxis: {
|
56
|
+
title: {
|
57
|
+
text: 'Usage'
|
58
|
+
},
|
59
|
+
plotLines: [{
|
60
|
+
value: 0,
|
61
|
+
width: 1,
|
62
|
+
color: '#808080'
|
63
|
+
}],
|
64
|
+
max: 100,
|
65
|
+
min: 0
|
66
|
+
},
|
67
|
+
tooltip: {
|
68
|
+
formatter: function() {
|
69
|
+
return '<b>'+ this.series.name +'</b><br/>'+
|
70
|
+
this.x +': '+ this.y + (this.series.name === 'temp' ? o.temp.unit : '%');
|
71
|
+
}
|
72
|
+
},
|
73
|
+
legend: {
|
74
|
+
layout: 'vertical',
|
75
|
+
align: 'right',
|
76
|
+
verticalAlign: 'top',
|
77
|
+
x: -10,
|
78
|
+
y: 100,
|
79
|
+
borderWidth: 0
|
80
|
+
},
|
81
|
+
series: [{
|
82
|
+
name: 'cpu',
|
83
|
+
color: o.cpu.color,
|
84
|
+
data: o.cpu.stats
|
85
|
+
},
|
86
|
+
{
|
87
|
+
name: 'mem',
|
88
|
+
color: o.mem.color,
|
89
|
+
data: o.mem.stats
|
90
|
+
},
|
91
|
+
{
|
92
|
+
name: 'swap',
|
93
|
+
color: o.swap.color,
|
94
|
+
data: o.swap.stats
|
95
|
+
},
|
96
|
+
{
|
97
|
+
name: 'disk',
|
98
|
+
color: o.disk.color,
|
99
|
+
data: o.disk.stats
|
100
|
+
},
|
101
|
+
{
|
102
|
+
name: 'temp',
|
103
|
+
color: o.temp.color,
|
104
|
+
data: o.temp.stats
|
105
|
+
}],
|
106
|
+
credits: {
|
107
|
+
enabled: false
|
108
|
+
}
|
109
|
+
});
|
110
|
+
}
|
111
|
+
|
112
|
+
var ws = new WebSocket('ws://' + window.location.host + window.location.pathname);
|
113
|
+
//ws.onopen = function() { console.log('opened socket'); };
|
114
|
+
ws.onclose = function() { alert('Connection to Pimon server lost...'); };
|
115
|
+
ws.onmessage = function(m) {
|
116
|
+
var o = $.parseJSON(m.data);
|
117
|
+
drawChart(o);
|
118
|
+
changeFavicon(o);
|
119
|
+
};
|
120
|
+
});
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'date'
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
2
|
+
require 'json'
|
3
|
+
require 'pimon/probe/cpu_usage'
|
4
|
+
require 'pimon/probe/disk_usage'
|
5
|
+
require 'pimon/probe/memory_usage'
|
6
|
+
require 'pimon/probe/swap_usage'
|
7
|
+
require 'pimon/probe/temperature'
|
8
8
|
|
9
9
|
class StatsCollector
|
10
10
|
def initialize(config, redis)
|
@@ -45,7 +45,7 @@ class StatsCollector
|
|
45
45
|
}
|
46
46
|
end
|
47
47
|
|
48
|
-
stats
|
48
|
+
stats.to_json
|
49
49
|
end
|
50
50
|
|
51
51
|
private
|
data/lib/pimon/version.rb
CHANGED
data/lib/pimon/views/index.haml
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
%script{ :src => '//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.0/jquery-1.8.0.min.js' }
|
5
5
|
%script{ :src => '//cdnjs.cloudflare.com/ajax/libs/highcharts/2.3.1/highcharts.js' }
|
6
6
|
%script{ :src => '//lipka.github.com/piecon/piecon.min.js' }
|
7
|
+
%script{ :src => '/index.js' }
|
7
8
|
%body
|
8
9
|
#chart
|
9
|
-
|
10
|
-
= render(:haml,:'index.js',:locals => { :o => @o })
|
data/pimon.gemspec
CHANGED
@@ -11,24 +11,25 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = 'http://pimon.pedrocarrico.net/'
|
12
12
|
s.summary = 'Pimon - Raspberry Pi server monitor'
|
13
13
|
s.description = 'Pimon is a simple server monitor designed for the Raspberry Pi. It uses redis lists to keep the latest observed statistics and also uses highcharts to display some nice charts on your web browser.'
|
14
|
+
s.post_install_message = 'Before running Pimon be sure to have a redis instance up and running and listening on /tmp/redis.sock'
|
14
15
|
|
15
|
-
s.required_ruby_version =
|
16
|
+
s.required_ruby_version = '>= 1.9'
|
16
17
|
|
17
18
|
s.files = `git ls-files`.split("\n")
|
18
19
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
20
|
s.executables = `git ls-files -- bin/pimon`.split("\n").map{ |f| File.basename(f) }
|
20
|
-
s.require_paths = [
|
21
|
+
s.require_paths = ['lib']
|
21
22
|
|
22
|
-
s.add_runtime_dependency
|
23
|
-
s.add_runtime_dependency
|
24
|
-
s.add_runtime_dependency
|
25
|
-
s.add_runtime_dependency
|
26
|
-
s.add_runtime_dependency
|
23
|
+
s.add_runtime_dependency 'haml', '~> 3.1.7'
|
24
|
+
s.add_runtime_dependency 'redis', '~> 3.0.1'
|
25
|
+
s.add_runtime_dependency 'sinatra', '~> 1.3.2'
|
26
|
+
s.add_runtime_dependency 'sinatra-websocket', '~> 0.2.0'
|
27
|
+
s.add_runtime_dependency 'thin', '~> 1.5.0'
|
27
28
|
|
28
|
-
s.add_development_dependency
|
29
|
-
s.add_development_dependency
|
30
|
-
s.add_development_dependency
|
31
|
-
s.add_development_dependency
|
32
|
-
s.add_development_dependency
|
33
|
-
s.add_development_dependency
|
29
|
+
s.add_development_dependency 'rack-test', '~> 0'
|
30
|
+
s.add_development_dependency 'mock_redis', '~> 0.5.0'
|
31
|
+
s.add_development_dependency 'rspec', '~> 2.11.0'
|
32
|
+
s.add_development_dependency 'simplecov'
|
33
|
+
s.add_development_dependency 'simplecov-rcov'
|
34
|
+
s.add_development_dependency 'timecop'
|
34
35
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
+
require 'json'
|
4
5
|
|
5
6
|
describe 'StatsCollector' do
|
6
7
|
context 'when new with a valid config and redis' do
|
@@ -28,7 +29,7 @@ describe 'StatsCollector' do
|
|
28
29
|
:swap => {:stats => [], :color => '#3CB371', :unit => '%' },
|
29
30
|
:disk => {:stats => [], :color => '#CDC673', :unit => '%' },
|
30
31
|
:temp => {:stats => [], :color => '#FF9B04', :unit => 'ºC' }
|
31
|
-
}
|
32
|
+
}.to_json
|
32
33
|
}
|
33
34
|
|
34
35
|
context 'when collected some stats' do
|
@@ -54,7 +55,7 @@ describe 'StatsCollector' do
|
|
54
55
|
:swap=>{ :stats => [50, 50, 50, 50, 50, 50], :color => '#3CB371', :unit => '%'},
|
55
56
|
:disk=>{ :stats => [25, 25, 25, 25, 25, 25], :color => '#CDC673', :unit => '%'},
|
56
57
|
:temp=>{ :stats => [40, 40, 40, 40, 40, 40], :color => '#FF9B04', :unit => 'ºC'}
|
57
|
-
}
|
58
|
+
}.to_json
|
58
59
|
}
|
59
60
|
end
|
60
61
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pimon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,94 +9,94 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: haml
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 3.1.7
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 3.1.7
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
31
|
+
name: redis
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 3.1
|
37
|
+
version: 3.0.1
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 3.1
|
45
|
+
version: 3.0.1
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
47
|
+
name: sinatra
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 3.
|
53
|
+
version: 1.3.2
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 3.
|
61
|
+
version: 1.3.2
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
|
-
name: sinatra
|
63
|
+
name: sinatra-websocket
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: 0.2.0
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
77
|
+
version: 0.2.0
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: thin
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
81
81
|
none: false
|
82
82
|
requirements:
|
83
|
-
- -
|
83
|
+
- - ~>
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 1.
|
85
|
+
version: 1.5.0
|
86
86
|
type: :runtime
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
89
|
none: false
|
90
90
|
requirements:
|
91
|
-
- -
|
91
|
+
- - ~>
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: 1.
|
93
|
+
version: 1.5.0
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: rack-test
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|
99
|
-
- -
|
99
|
+
- - ~>
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
102
|
type: :development
|
@@ -104,7 +104,7 @@ dependencies:
|
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - ~>
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
- !ruby/object:Gem::Dependency
|
@@ -112,7 +112,7 @@ dependencies:
|
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
113
113
|
none: false
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ~>
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: 0.5.0
|
118
118
|
type: :development
|
@@ -120,7 +120,7 @@ dependencies:
|
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
none: false
|
122
122
|
requirements:
|
123
|
-
- -
|
123
|
+
- - ~>
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: 0.5.0
|
126
126
|
- !ruby/object:Gem::Dependency
|
@@ -128,7 +128,7 @@ dependencies:
|
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
none: false
|
130
130
|
requirements:
|
131
|
-
- -
|
131
|
+
- - ~>
|
132
132
|
- !ruby/object:Gem::Version
|
133
133
|
version: 2.11.0
|
134
134
|
type: :development
|
@@ -136,7 +136,7 @@ dependencies:
|
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
137
|
none: false
|
138
138
|
requirements:
|
139
|
-
- -
|
139
|
+
- - ~>
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: 2.11.0
|
142
142
|
- !ruby/object:Gem::Dependency
|
@@ -214,8 +214,8 @@ files:
|
|
214
214
|
- bin/vmstat.c
|
215
215
|
- config/config.ru
|
216
216
|
- config/config_dev.ru
|
217
|
+
- config/default.yml
|
217
218
|
- config/deploy.rb
|
218
|
-
- config/development.yml
|
219
219
|
- config/production.yml
|
220
220
|
- config/test.yml
|
221
221
|
- config/test_broken.yml
|
@@ -231,10 +231,10 @@ files:
|
|
231
231
|
- lib/pimon/probe/system_memory.rb
|
232
232
|
- lib/pimon/probe/temperature.rb
|
233
233
|
- lib/pimon/public/favicon.ico
|
234
|
+
- lib/pimon/public/index.js
|
234
235
|
- lib/pimon/stats_collector.rb
|
235
236
|
- lib/pimon/version.rb
|
236
237
|
- lib/pimon/views/index.haml
|
237
|
-
- lib/pimon/views/index.js.haml
|
238
238
|
- pimon.gemspec
|
239
239
|
- spec/pimon_config_spec.rb
|
240
240
|
- spec/pimon_spec.rb
|
@@ -242,7 +242,8 @@ files:
|
|
242
242
|
- spec/stats_collector_spec.rb
|
243
243
|
homepage: http://pimon.pedrocarrico.net/
|
244
244
|
licenses: []
|
245
|
-
post_install_message:
|
245
|
+
post_install_message: Before running Pimon be sure to have a redis instance up and
|
246
|
+
running and listening on /tmp/redis.sock
|
246
247
|
rdoc_options: []
|
247
248
|
require_paths:
|
248
249
|
- lib
|
@@ -1,111 +0,0 @@
|
|
1
|
-
:javascript
|
2
|
-
$(function () {
|
3
|
-
var chart,
|
4
|
-
cpu = #{o[:cpu][:stats]},
|
5
|
-
disk = #{o[:disk][:stats]},
|
6
|
-
mem = #{o[:mem][:stats]},
|
7
|
-
swap = #{o[:swap][:stats]},
|
8
|
-
time = #{o[:time][:stats]},
|
9
|
-
temp = #{o[:temp][:stats]},
|
10
|
-
titleStats = [ { 'legend' : 'CPU', 'stat' : cpu[cpu.length - 1], 'color' : '#{o[:cpu][:color]}', 'unit' : '#{o[:cpu][:unit]}' } ,
|
11
|
-
{ 'legend' : 'MEM', 'stat' : mem[mem.length - 1], 'color' : '#{o[:mem][:color]}', 'unit' : '#{o[:mem][:unit]}' } ,
|
12
|
-
{ 'legend' : 'SWAP', 'stat' : swap[swap.length - 1], 'color' : '#{o[:swap][:color]}', 'unit' : '#{o[:swap][:unit]}'},
|
13
|
-
{ 'legend' : 'DISK', 'stat' : disk[disk.length - 1], 'color' : '#{o[:disk][:color]}', 'unit' : '#{o[:disk][:unit]}'},
|
14
|
-
{ 'legend' : 'TEMP', 'stat' : temp[temp.length - 1], 'color' : '#{o[:temp][:color]}', 'unit' : '#{o[:temp][:unit]}'} ],
|
15
|
-
i = 0;
|
16
|
-
|
17
|
-
$(document).ready(function() {
|
18
|
-
chart = new Highcharts.Chart({
|
19
|
-
chart: {
|
20
|
-
renderTo: 'chart',
|
21
|
-
type: 'line',
|
22
|
-
marginRight: 130,
|
23
|
-
marginBottom: 25
|
24
|
-
},
|
25
|
-
title: {
|
26
|
-
text: 'Pimon',
|
27
|
-
x: -20
|
28
|
-
},
|
29
|
-
subtitle: {
|
30
|
-
text: 'My raspberry PI',
|
31
|
-
x: -20
|
32
|
-
},
|
33
|
-
xAxis: {
|
34
|
-
categories: time
|
35
|
-
},
|
36
|
-
yAxis: {
|
37
|
-
title: {
|
38
|
-
text: 'Usage'
|
39
|
-
},
|
40
|
-
plotLines: [{
|
41
|
-
value: 0,
|
42
|
-
width: 1,
|
43
|
-
color: '#808080'
|
44
|
-
}],
|
45
|
-
max: 100,
|
46
|
-
min: 0
|
47
|
-
},
|
48
|
-
tooltip: {
|
49
|
-
formatter: function() {
|
50
|
-
return '<b>'+ this.series.name +'</b><br/>'+
|
51
|
-
this.x +': '+ this.y + (this.series.name === 'temp' ? '#{o[:temp][:unit]}' : '%');
|
52
|
-
}
|
53
|
-
},
|
54
|
-
legend: {
|
55
|
-
layout: 'vertical',
|
56
|
-
align: 'right',
|
57
|
-
verticalAlign: 'top',
|
58
|
-
x: -10,
|
59
|
-
y: 100,
|
60
|
-
borderWidth: 0
|
61
|
-
},
|
62
|
-
series: [{
|
63
|
-
name: 'cpu',
|
64
|
-
color: '#{o[:cpu][:color]}',
|
65
|
-
data: cpu
|
66
|
-
},
|
67
|
-
{
|
68
|
-
name: 'mem',
|
69
|
-
color: '#{o[:mem][:color]}',
|
70
|
-
data: mem
|
71
|
-
},
|
72
|
-
{
|
73
|
-
name: 'swap',
|
74
|
-
color: '#{o[:swap][:color]}',
|
75
|
-
data: swap
|
76
|
-
},
|
77
|
-
{
|
78
|
-
name: 'disk',
|
79
|
-
color: '#{o[:disk][:color]}',
|
80
|
-
data: disk
|
81
|
-
},
|
82
|
-
{
|
83
|
-
name: 'temp',
|
84
|
-
color: '#{o[:temp][:color]}',
|
85
|
-
data: temp
|
86
|
-
}]
|
87
|
-
});
|
88
|
-
});
|
89
|
-
|
90
|
-
function changeFavicon() {
|
91
|
-
Piecon.setOptions({
|
92
|
-
color: titleStats[i]['color'], // Pie chart color
|
93
|
-
background: '#bbb', // Empty pie chart color
|
94
|
-
shadow: '#fff', // Outer ring color
|
95
|
-
fallback: 'force' // Toggles displaying percentage in the title bar (possible values - true, false, 'force')
|
96
|
-
});
|
97
|
-
Piecon.setProgress(titleStats[i]['stat']);
|
98
|
-
|
99
|
-
$('title').text(titleStats[i]['stat'] + titleStats[i]['unit'] + ' ' + titleStats[i]['legend'])
|
100
|
-
i++;
|
101
|
-
if (i >= titleStats.length) {
|
102
|
-
i = 0;
|
103
|
-
}
|
104
|
-
}
|
105
|
-
|
106
|
-
setInterval(changeFavicon, 3000);
|
107
|
-
changeFavicon();
|
108
|
-
setTimeout(function() {
|
109
|
-
window.location.reload();
|
110
|
-
}, #{@o[:refresh_interval_in_millis]});
|
111
|
-
});
|