god 0.10.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +9 -1
- data/god.gemspec +2 -3
- data/lib/god.rb +30 -22
- data/lib/god/contact.rb +8 -0
- data/lib/god/contacts/campfire.rb +97 -59
- data/lib/god/contacts/email.rb +80 -48
- data/lib/god/contacts/jabber.rb +50 -101
- data/lib/god/contacts/prowl.rb +25 -45
- data/lib/god/contacts/scout.rb +25 -34
- data/lib/god/contacts/twitter.rb +33 -20
- data/lib/god/contacts/webhook.rb +50 -24
- data/test/configs/contact/contact.god +59 -41
- data/test/test_campfire.rb +14 -32
- data/test/test_email.rb +22 -33
- data/test/test_jabber.rb +17 -24
- data/test/test_webhook.rb +7 -9
- metadata +37 -105
@@ -1,66 +1,84 @@
|
|
1
|
-
God::Contacts::
|
1
|
+
# God::Contacts::Campfire.defaults do |d|
|
2
|
+
# d.subdomain = 'github'
|
3
|
+
# d.token = '9fb768e421975cc1c6ff3f4f8306f890cb46e24f'
|
4
|
+
# d.room = 'Notices'
|
5
|
+
# d.ssl = true
|
6
|
+
# end
|
7
|
+
#
|
8
|
+
# God.contact(:campfire) do |c|
|
9
|
+
# c.name = 'tom4'
|
10
|
+
# end
|
2
11
|
|
3
|
-
God
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
12
|
+
# God.contact(:email) do |c|
|
13
|
+
# c.name = 'tom'
|
14
|
+
# c.group = 'developers'
|
15
|
+
# c.to_email = 'tom@lepton.local'
|
16
|
+
# c.from_email = 'god@github.com'
|
17
|
+
# c.from_name = 'God'
|
18
|
+
# c.delivery_method = :sendmail
|
19
|
+
# end
|
8
20
|
|
9
|
-
God
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
21
|
+
# God.contact(:email) do |c|
|
22
|
+
# c.name = 'tom'
|
23
|
+
# c.group = 'developers'
|
24
|
+
# c.to_email = 'tom@mojombo.com'
|
25
|
+
# c.from_email = 'god@github.com'
|
26
|
+
# c.from_name = 'God'
|
27
|
+
# c.server_host = 'smtp.rs.github.com'
|
28
|
+
# end
|
15
29
|
|
16
|
-
God.contact(:
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
30
|
+
# God.contact(:prowl) do |c|
|
31
|
+
# c.name = 'tom3'
|
32
|
+
# c.apikey = 'f0fc8e1f3121672686337a631527eac2f1b6031c'
|
33
|
+
# c.group = 'developers'
|
34
|
+
# end
|
21
35
|
|
22
|
-
God.contact(:
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
36
|
+
# God.contact(:twitter) do |c|
|
37
|
+
# c.name = 'tom6'
|
38
|
+
# c.consumer_token = 'gOhjax6s0L3mLeaTtBWPw'
|
39
|
+
# c.consumer_secret = 'yz4gpAVXJHKxvsGK85tEyzQJ7o2FEy27H1KEWL75jfA'
|
40
|
+
# c.access_token = '17376380-qS391nCrgaP4HKXAmZtM38gB56xUXMhx1NYbjT6mQ'
|
41
|
+
# c.access_secret = 'uMwCDeU4OXlEBWFQBc3KwGyY8OdWCtAV0Jg5KVB0'
|
42
|
+
# end
|
27
43
|
|
28
|
-
God.contact(:
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
end
|
44
|
+
# God.contact(:scout) do |c|
|
45
|
+
# c.name = 'tom5'
|
46
|
+
# c.client_key = '583a51b5-acbc-2421-a830-b6f3f8e4b04e'
|
47
|
+
# c.plugin_id = '230641'
|
48
|
+
# end
|
33
49
|
|
34
|
-
God.contact(:
|
35
|
-
|
36
|
-
|
37
|
-
end
|
50
|
+
# God.contact(:webhook) do |c|
|
51
|
+
# c.name = 'tom'
|
52
|
+
# c.url = "http://www.postbin.org/wk7guh"
|
53
|
+
# end
|
38
54
|
|
39
|
-
God.contact(:
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
55
|
+
# God.contact(:jabber) do |c|
|
56
|
+
# c.name = 'tom'
|
57
|
+
# c.host = 'talk.google.com'
|
58
|
+
# c.to_jid = 'mojombo@jabber.org'
|
59
|
+
# c.from_jid = 'mojombo@gmail.com'
|
60
|
+
# c.password = 'secret'
|
61
|
+
# end
|
44
62
|
|
45
63
|
God.watch do |w|
|
46
64
|
w.name = "contact"
|
47
65
|
w.interval = 5.seconds
|
48
66
|
w.start = "ruby " + File.join(File.dirname(__FILE__), *%w[simple_server.rb])
|
49
67
|
w.log = "/Users/tom/contact.log"
|
50
|
-
|
68
|
+
|
51
69
|
# determine the state on startup
|
52
70
|
w.transition(:init, { true => :up, false => :start }) do |on|
|
53
71
|
on.condition(:process_running) do |c|
|
54
72
|
c.running = true
|
55
73
|
end
|
56
74
|
end
|
57
|
-
|
75
|
+
|
58
76
|
# determine when process has finished starting
|
59
77
|
w.transition([:start, :restart], :up) do |on|
|
60
78
|
on.condition(:process_running) do |c|
|
61
79
|
c.running = true
|
62
80
|
end
|
63
|
-
|
81
|
+
|
64
82
|
# failsafe
|
65
83
|
on.condition(:tries) do |c|
|
66
84
|
c.times = 2
|
@@ -71,10 +89,10 @@ God.watch do |w|
|
|
71
89
|
# start if process is not running
|
72
90
|
w.transition(:up, :start) do |on|
|
73
91
|
on.condition(:process_exits) do |c|
|
74
|
-
c.notify = {:contacts => ['
|
92
|
+
c.notify = {:contacts => ['tom'], :priority => 1, :category => 'product'}
|
75
93
|
end
|
76
94
|
end
|
77
|
-
|
95
|
+
|
78
96
|
# lifecycle
|
79
97
|
w.lifecycle do |on|
|
80
98
|
on.condition(:flapping) do |c|
|
data/test/test_campfire.rb
CHANGED
@@ -2,40 +2,22 @@ require File.dirname(__FILE__) + '/helper'
|
|
2
2
|
require 'tinder'
|
3
3
|
|
4
4
|
class TestCampfire < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
@campfire = God::Contacts::Campfire.new
|
7
|
+
end
|
8
|
+
|
5
9
|
def test_exists
|
6
10
|
God::Contacts::Campfire
|
7
11
|
end
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
g.expects(:room).returns(room)
|
19
|
-
g.notify(:a, :b, :c, :d, :e)
|
20
|
-
assert_equal "notified campfire: ", g.info
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# should not establish a new connection because the older is alive
|
25
|
-
def test_campfire_room_method
|
26
|
-
assert_nothing_raised do
|
27
|
-
room = mock()
|
28
|
-
g = God::Contacts::Campfire.new
|
29
|
-
g.instance_variable_set(:@room,room)
|
30
|
-
assert_equal g.send(:room), room
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# should raise because the connections parameters have not been set
|
35
|
-
def test_campfire_delivery_method_for_notify_without_campfire_params
|
36
|
-
LOG.expects(:log).times(3) # 3 calls: 2 debug (credentials, backtrace) + 1 info (failed message)
|
37
|
-
g = God::Contacts::Campfire.new
|
38
|
-
g.notify(:a, :b, :c, :d, :e)
|
12
|
+
|
13
|
+
def test_notify
|
14
|
+
@campfire.subdomain = 'github'
|
15
|
+
@campfire.token = 'abc'
|
16
|
+
@campfire.room = 'danger'
|
17
|
+
|
18
|
+
time = Time.now
|
19
|
+
body = "[#{time.strftime('%H:%M:%S')}] host - msg"
|
20
|
+
Marshmallow::Connection.any_instance.expects(:speak).with('danger', body)
|
21
|
+
@campfire.notify('msg', time, 'prio', 'cat', 'host')
|
39
22
|
end
|
40
|
-
|
41
23
|
end
|
data/test/test_email.rb
CHANGED
@@ -1,45 +1,34 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/helper'
|
2
2
|
|
3
3
|
class TestEmail < Test::Unit::TestCase
|
4
|
-
def
|
5
|
-
God::Contacts::Email
|
4
|
+
def setup
|
5
|
+
God::Contacts::Email.to_email = 'dev@example.com'
|
6
|
+
God::Contacts::Email.from_email = 'god@example.com'
|
7
|
+
@email = God::Contacts::Email.new
|
6
8
|
end
|
7
9
|
|
8
|
-
def
|
9
|
-
|
10
|
-
|
11
|
-
God::Contacts::Email.any_instance.expects(:notify_sendmail).never
|
12
|
-
God::Contacts::Email.delivery_method = :foo_protocol
|
13
|
-
LOG.expects(:log).times(2)
|
14
|
-
|
15
|
-
g = God::Contacts::Email.new
|
16
|
-
g.notify(:a, :b, :c, :d, :e)
|
17
|
-
assert_nil g.info
|
18
|
-
end
|
10
|
+
def test_validity_delivery
|
11
|
+
@email.delivery_method = :brainwaves
|
12
|
+
assert_equal false, @email.valid?
|
19
13
|
end
|
20
14
|
|
21
15
|
def test_smtp_delivery_method_for_notify
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
assert_equal "sent email to joe@example.com", g.info
|
30
|
-
end
|
16
|
+
@email.delivery_method = :smtp
|
17
|
+
|
18
|
+
God::Contacts::Email.any_instance.expects(:notify_sendmail).never
|
19
|
+
God::Contacts::Email.any_instance.expects(:notify_smtp).once.returns(nil)
|
20
|
+
|
21
|
+
@email.notify('msg', Time.now, 'prio', 'cat', 'host')
|
22
|
+
assert_equal "sent email to dev@example.com via smtp", @email.info
|
31
23
|
end
|
32
|
-
|
24
|
+
|
33
25
|
def test_sendmail_delivery_method_for_notify
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
assert_equal "sent email to joe@example.com", g.info
|
42
|
-
end
|
26
|
+
@email.delivery_method = :sendmail
|
27
|
+
|
28
|
+
God::Contacts::Email.any_instance.expects(:notify_smtp).never
|
29
|
+
God::Contacts::Email.any_instance.expects(:notify_sendmail).once.returns(nil)
|
30
|
+
|
31
|
+
@email.notify('msg', Time.now, 'prio', 'cat', 'host')
|
32
|
+
assert_equal "sent email to dev@example.com via sendmail", @email.info
|
43
33
|
end
|
44
|
-
|
45
34
|
end
|
data/test/test_jabber.rb
CHANGED
@@ -4,33 +4,26 @@ require File.dirname(__FILE__) + '/helper'
|
|
4
4
|
class TestJabber < Test::Unit::TestCase
|
5
5
|
|
6
6
|
def setup
|
7
|
-
God::Contacts::Jabber.settings = {
|
8
|
-
:jabber_id => 'test@example.com',
|
9
|
-
:password => 'pass'
|
10
|
-
}
|
11
7
|
@jabber = God::Contacts::Jabber.new
|
12
|
-
@jabber.jabber_id = 'recipient@example.com'
|
13
8
|
end
|
14
9
|
|
15
10
|
def test_notify
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
11
|
+
@jabber.host = 'talk.google.com'
|
12
|
+
@jabber.from_jid = 'god@jabber.org'
|
13
|
+
@jabber.password = 'secret'
|
14
|
+
@jabber.to_jid = 'dev@jabber.org'
|
15
|
+
|
16
|
+
time = Time.now
|
17
|
+
body = God::Contacts::Jabber.format.call('msg', time, 'prio', 'cat', 'host')
|
18
|
+
|
19
|
+
assert_equal "Message: msg\nHost: host\nPriority: prio\nCategory: cat\n", body
|
20
|
+
|
21
|
+
Jabber::Client.any_instance.expects(:connect).with('talk.google.com', 5222)
|
22
|
+
Jabber::Client.any_instance.expects(:auth).with('secret')
|
23
|
+
Jabber::Client.any_instance.expects(:send)
|
24
|
+
Jabber::Client.any_instance.expects(:close)
|
25
|
+
|
26
|
+
@jabber.notify('msg', Time.now, 'prio', 'cat', 'host')
|
27
|
+
assert_equal "sent jabber message to dev@jabber.org", @jabber.info
|
22
28
|
end
|
23
|
-
|
24
|
-
# def test_live_notify
|
25
|
-
# God::Contacts::Jabber.settings = {
|
26
|
-
# :jabber_id => 'real_user@example.com',
|
27
|
-
# :password => 'pass'
|
28
|
-
# }
|
29
|
-
# recipient = "real_recipient@example.com"
|
30
|
-
#
|
31
|
-
# jabber = God::Contacts::Jabber.new
|
32
|
-
# jabber.jabber_id = recipient
|
33
|
-
# jabber.notify("Hello", Time.now, "Test", "Test", "localhost")
|
34
|
-
# assert_equal "sent jabber message to #{recipient}", jabber.info
|
35
|
-
# end
|
36
29
|
end
|
data/test/test_webhook.rb
CHANGED
@@ -1,17 +1,15 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/helper'
|
2
2
|
|
3
3
|
class TestWebhook < Test::Unit::TestCase
|
4
|
-
def
|
5
|
-
God::Contacts::Webhook
|
4
|
+
def setup
|
5
|
+
@webhook = God::Contacts::Webhook.new
|
6
6
|
end
|
7
7
|
|
8
8
|
def test_notify
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
assert_equal "sent webhook to http://test/switch", g.info
|
15
|
-
end
|
9
|
+
@webhook.url = 'http://example.com/switch'
|
10
|
+
Net::HTTP.any_instance.expects(:request).returns(Net::HTTPSuccess.new('a', 'b', 'c'))
|
11
|
+
|
12
|
+
@webhook.notify('msg', Time.now, 'prio', 'cat', 'host')
|
13
|
+
assert_equal "sent webhook to http://example.com/switch", @webhook.info
|
16
14
|
end
|
17
15
|
end
|
metadata
CHANGED
@@ -1,12 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: god
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 0
|
7
|
-
- 10
|
8
|
-
- 1
|
9
|
-
version: 0.10.1
|
4
|
+
version: 0.11.0
|
10
5
|
platform: ruby
|
11
6
|
authors:
|
12
7
|
- Tom Preston-Werner
|
@@ -16,156 +11,95 @@ autorequire:
|
|
16
11
|
bindir: bin
|
17
12
|
cert_chain: []
|
18
13
|
|
19
|
-
date: 2010-
|
14
|
+
date: 2010-07-01 00:00:00 -07:00
|
20
15
|
default_executable: god
|
21
16
|
dependencies:
|
22
17
|
- !ruby/object:Gem::Dependency
|
23
18
|
name: twitter
|
24
|
-
|
25
|
-
|
19
|
+
type: :development
|
20
|
+
version_requirement:
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
22
|
requirements:
|
27
23
|
- - ">="
|
28
24
|
- !ruby/object:Gem::Version
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
- 3
|
32
|
-
- 7
|
33
25
|
version: 0.3.7
|
34
|
-
|
35
|
-
version_requirements: *id001
|
26
|
+
version:
|
36
27
|
- !ruby/object:Gem::Dependency
|
37
28
|
name: prowly
|
38
|
-
prerelease: false
|
39
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
segments:
|
44
|
-
- 0
|
45
|
-
- 2
|
46
|
-
- 1
|
47
|
-
version: 0.2.1
|
48
29
|
type: :development
|
49
|
-
|
50
|
-
|
51
|
-
name: tinder
|
52
|
-
prerelease: false
|
53
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
30
|
+
version_requirement:
|
31
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
32
|
requirements:
|
55
33
|
- - ">="
|
56
34
|
- !ruby/object:Gem::Version
|
57
|
-
|
58
|
-
|
59
|
-
- 3
|
60
|
-
- 1
|
61
|
-
version: 1.3.1
|
62
|
-
- - <
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
segments:
|
65
|
-
- 2
|
66
|
-
- 0
|
67
|
-
- 0
|
68
|
-
version: 2.0.0
|
69
|
-
type: :development
|
70
|
-
version_requirements: *id003
|
35
|
+
version: 0.2.1
|
36
|
+
version:
|
71
37
|
- !ruby/object:Gem::Dependency
|
72
38
|
name: xmpp4r
|
73
|
-
|
74
|
-
|
39
|
+
type: :development
|
40
|
+
version_requirement:
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
75
42
|
requirements:
|
76
43
|
- - ">="
|
77
44
|
- !ruby/object:Gem::Version
|
78
|
-
segments:
|
79
|
-
- 0
|
80
|
-
- 4
|
81
|
-
- 0
|
82
45
|
version: 0.4.0
|
83
|
-
|
84
|
-
version_requirements: *id004
|
46
|
+
version:
|
85
47
|
- !ruby/object:Gem::Dependency
|
86
48
|
name: dike
|
87
|
-
|
88
|
-
|
49
|
+
type: :development
|
50
|
+
version_requirement:
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
52
|
requirements:
|
90
53
|
- - ">="
|
91
54
|
- !ruby/object:Gem::Version
|
92
|
-
segments:
|
93
|
-
- 0
|
94
|
-
- 0
|
95
|
-
- 3
|
96
55
|
version: 0.0.3
|
97
|
-
|
98
|
-
version_requirements: *id005
|
56
|
+
version:
|
99
57
|
- !ruby/object:Gem::Dependency
|
100
58
|
name: snapshot
|
101
|
-
|
102
|
-
|
59
|
+
type: :development
|
60
|
+
version_requirement:
|
61
|
+
version_requirements: !ruby/object:Gem::Requirement
|
103
62
|
requirements:
|
104
63
|
- - ">="
|
105
64
|
- !ruby/object:Gem::Version
|
106
|
-
segments:
|
107
|
-
- 1
|
108
|
-
- 0
|
109
|
-
- 0
|
110
65
|
version: 1.0.0
|
111
66
|
- - <
|
112
67
|
- !ruby/object:Gem::Version
|
113
|
-
segments:
|
114
|
-
- 2
|
115
|
-
- 0
|
116
|
-
- 0
|
117
68
|
version: 2.0.0
|
118
|
-
|
119
|
-
version_requirements: *id006
|
69
|
+
version:
|
120
70
|
- !ruby/object:Gem::Dependency
|
121
71
|
name: rcov
|
122
|
-
|
123
|
-
|
72
|
+
type: :development
|
73
|
+
version_requirement:
|
74
|
+
version_requirements: !ruby/object:Gem::Requirement
|
124
75
|
requirements:
|
125
76
|
- - ">="
|
126
77
|
- !ruby/object:Gem::Version
|
127
|
-
segments:
|
128
|
-
- 0
|
129
|
-
- 9
|
130
|
-
- 8
|
131
78
|
version: 0.9.8
|
132
|
-
|
133
|
-
version_requirements: *id007
|
79
|
+
version:
|
134
80
|
- !ruby/object:Gem::Dependency
|
135
81
|
name: daemons
|
136
|
-
|
137
|
-
|
82
|
+
type: :development
|
83
|
+
version_requirement:
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
138
85
|
requirements:
|
139
86
|
- - ">="
|
140
87
|
- !ruby/object:Gem::Version
|
141
|
-
segments:
|
142
|
-
- 1
|
143
|
-
- 0
|
144
|
-
- 10
|
145
88
|
version: 1.0.10
|
146
89
|
- - <
|
147
90
|
- !ruby/object:Gem::Version
|
148
|
-
segments:
|
149
|
-
- 2
|
150
|
-
- 0
|
151
|
-
- 0
|
152
91
|
version: 2.0.0
|
153
|
-
|
154
|
-
version_requirements: *id008
|
92
|
+
version:
|
155
93
|
- !ruby/object:Gem::Dependency
|
156
94
|
name: mocha
|
157
|
-
|
158
|
-
|
95
|
+
type: :development
|
96
|
+
version_requirement:
|
97
|
+
version_requirements: !ruby/object:Gem::Requirement
|
159
98
|
requirements:
|
160
99
|
- - ">="
|
161
100
|
- !ruby/object:Gem::Version
|
162
|
-
segments:
|
163
|
-
- 0
|
164
|
-
- 9
|
165
|
-
- 1
|
166
101
|
version: 0.9.1
|
167
|
-
|
168
|
-
version_requirements: *id009
|
102
|
+
version:
|
169
103
|
description: An easy to configure, easy to extend monitoring framework written in Ruby.
|
170
104
|
email: god-rb@googlegroups.com
|
171
105
|
executables:
|
@@ -311,20 +245,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
311
245
|
requirements:
|
312
246
|
- - ">="
|
313
247
|
- !ruby/object:Gem::Version
|
314
|
-
segments:
|
315
|
-
- 0
|
316
248
|
version: "0"
|
249
|
+
version:
|
317
250
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
318
251
|
requirements:
|
319
252
|
- - ">="
|
320
253
|
- !ruby/object:Gem::Version
|
321
|
-
segments:
|
322
|
-
- 0
|
323
254
|
version: "0"
|
255
|
+
version:
|
324
256
|
requirements: []
|
325
257
|
|
326
258
|
rubyforge_project: god
|
327
|
-
rubygems_version: 1.3.
|
259
|
+
rubygems_version: 1.3.5
|
328
260
|
signing_key:
|
329
261
|
specification_version: 2
|
330
262
|
summary: Process monitoring framework.
|