srvmonitor 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -1
- data/lib/srvmonitor/application.rb +19 -3
- data/lib/srvmonitor/monitor.rb +10 -20
- data/lib/srvmonitor/notifiers/mailer.rb +1 -2
- data/lib/srvmonitor/scouts/timed_http.rb +7 -2
- data/lib/srvmonitor/server.rb +3 -2
- data/lib/srvmonitor/version.rb +1 -1
- metadata +38 -21
data/README.markdown
CHANGED
@@ -36,7 +36,7 @@ module SrvMonitor
|
|
36
36
|
|
37
37
|
def servers(*args)
|
38
38
|
servers = args.find_all{ |r| r.is_a?(SrvMonitor::Server) }
|
39
|
-
options = args.find{ |r| r.is_a?(Hash) }
|
39
|
+
options = args.find{ |r| r.is_a?(Hash) } || {}
|
40
40
|
servers.each{ |r| server(r, options) }
|
41
41
|
end
|
42
42
|
|
@@ -49,12 +49,28 @@ module SrvMonitor
|
|
49
49
|
@reports[params] = status
|
50
50
|
end
|
51
51
|
|
52
|
-
def run
|
52
|
+
def run(alert)
|
53
53
|
puts "\n### Runing #{label}"
|
54
54
|
statuses = []
|
55
|
+
|
56
|
+
tries = 0
|
57
|
+
|
55
58
|
@scouts.each do |scout|
|
59
|
+
tries += 1
|
60
|
+
|
56
61
|
scout.run(@reports)
|
57
|
-
|
62
|
+
|
63
|
+
if scout.status == alert[:if]
|
64
|
+
if tries <= alert[:retries]
|
65
|
+
redo
|
66
|
+
else
|
67
|
+
tries = 0
|
68
|
+
statuses << scout.status
|
69
|
+
end
|
70
|
+
else
|
71
|
+
statuses << scout.status
|
72
|
+
end
|
73
|
+
|
58
74
|
end
|
59
75
|
@status = SrvMonitor::Report.summarize(statuses)
|
60
76
|
end
|
data/lib/srvmonitor/monitor.rb
CHANGED
@@ -32,8 +32,7 @@ module SrvMonitor
|
|
32
32
|
|
33
33
|
def alert(args={})
|
34
34
|
@alert[:if] = args[:if] || :down
|
35
|
-
@alert[:
|
36
|
-
@alert[:count] = 0
|
35
|
+
@alert[:retries] = args[:retries] || 1
|
37
36
|
end
|
38
37
|
|
39
38
|
def notifier(notifier_klass, args={})
|
@@ -45,21 +44,14 @@ module SrvMonitor
|
|
45
44
|
end
|
46
45
|
|
47
46
|
def run
|
48
|
-
loop do
|
49
|
-
@applications.each
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
@alert[:count] += 1
|
57
|
-
sleep @wait
|
58
|
-
redo
|
59
|
-
else
|
60
|
-
notify!
|
61
|
-
@alert[:count] = 0
|
62
|
-
end
|
47
|
+
loop do
|
48
|
+
@applications.each do |app|
|
49
|
+
app.run(@alert)
|
50
|
+
|
51
|
+
unless status == @alert[:if]
|
52
|
+
sleep @wait
|
53
|
+
else
|
54
|
+
notify!
|
63
55
|
end
|
64
56
|
end
|
65
57
|
|
@@ -72,7 +64,5 @@ module SrvMonitor
|
|
72
64
|
return unless @notifier
|
73
65
|
@notifier.send(self)
|
74
66
|
end
|
75
|
-
|
76
67
|
end
|
77
|
-
end
|
78
|
-
|
68
|
+
end
|
@@ -18,13 +18,18 @@ module SrvMonitor
|
|
18
18
|
# @option options [String] :path The path that will be fetched from the host.
|
19
19
|
# @option options [String] :http_class The class that will be used to fetch the page, defaults to Net::HTTP
|
20
20
|
# @option options [Number] :timout
|
21
|
-
def initialize(options)
|
22
|
-
@port = options[:port] || 80
|
21
|
+
def initialize(options)
|
23
22
|
@path = options[:path] || '/'
|
24
23
|
@http_class = options[:http_class] || Net::HTTP
|
25
24
|
@timeout = options[:timeout] || 15
|
26
25
|
@server = options[:server]
|
27
26
|
@host = @server ? @server.host : options[:host] || '127.0.0.1'
|
27
|
+
|
28
|
+
@port = if options[:port]
|
29
|
+
options[:port]
|
30
|
+
else
|
31
|
+
@server ? @server.port : 80
|
32
|
+
end
|
28
33
|
end
|
29
34
|
|
30
35
|
def execute
|
data/lib/srvmonitor/server.rb
CHANGED
@@ -6,7 +6,7 @@ end
|
|
6
6
|
|
7
7
|
module SrvMonitor
|
8
8
|
class Server
|
9
|
-
attr_reader :name, :description, :host, :method, :user, :password
|
9
|
+
attr_reader :name, :description, :host, :method, :user, :password, :port
|
10
10
|
|
11
11
|
def initialize(options)
|
12
12
|
@name = options[:name]
|
@@ -15,6 +15,7 @@ module SrvMonitor
|
|
15
15
|
@method = options[:method] || :local
|
16
16
|
@user = options[:user]
|
17
17
|
@password = options[:password]
|
18
|
+
@port = options[:port]
|
18
19
|
end
|
19
20
|
|
20
21
|
def exec(&block)
|
@@ -24,7 +25,7 @@ module SrvMonitor
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def clone(args={})
|
27
|
-
config = { :name => @name, :description => @description, :host => @host, :method => @method, :user => @user }
|
28
|
+
config = { :name => @name, :description => @description, :host => @host, :method => @method, :user => @user, :port => @port }
|
28
29
|
Server.new config.merge(args)
|
29
30
|
end
|
30
31
|
|
data/lib/srvmonitor/version.rb
CHANGED
metadata
CHANGED
@@ -1,22 +1,32 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: srvmonitor
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 5
|
9
|
+
version: 0.0.5
|
6
10
|
platform: ruby
|
7
|
-
authors:
|
11
|
+
authors:
|
8
12
|
- Click Jogos
|
9
13
|
autorequire:
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
|
-
|
16
|
+
|
17
|
+
date: 2011-11-25 00:00:00 -02:00
|
18
|
+
default_executable:
|
13
19
|
dependencies: []
|
20
|
+
|
14
21
|
description: Server monitor.
|
15
22
|
email: clickjogos@clickjogos.com.br
|
16
23
|
executables: []
|
24
|
+
|
17
25
|
extensions: []
|
26
|
+
|
18
27
|
extra_rdoc_files: []
|
19
|
-
|
28
|
+
|
29
|
+
files:
|
20
30
|
- .gitignore
|
21
31
|
- Gemfile
|
22
32
|
- MIT-LICENSE
|
@@ -40,28 +50,35 @@ files:
|
|
40
50
|
- lib/srvmonitor/server.rb
|
41
51
|
- lib/srvmonitor/version.rb
|
42
52
|
- srvmonitor.gemspec
|
53
|
+
has_rdoc: true
|
43
54
|
homepage: http://www.github.com/clickjogos/srvmonitor
|
44
55
|
licenses: []
|
56
|
+
|
45
57
|
post_install_message:
|
46
58
|
rdoc_options: []
|
47
|
-
|
59
|
+
|
60
|
+
require_paths:
|
48
61
|
- lib
|
49
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
requirements:
|
58
|
-
- -
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
61
76
|
requirements: []
|
77
|
+
|
62
78
|
rubyforge_project: srvmonitor
|
63
|
-
rubygems_version: 1.
|
79
|
+
rubygems_version: 1.3.6
|
64
80
|
signing_key:
|
65
81
|
specification_version: 3
|
66
82
|
summary: Server monitor.
|
67
83
|
test_files: []
|
84
|
+
|