flapjack 0.4.11 → 0.4.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/TODO.md CHANGED
@@ -1,5 +1,21 @@
1
1
  * create events for failed checks
2
- * build option to specify notifier(s) directory
2
+
3
+ * rethink Notifier/NotifierCLI split
4
+ Notifier + NotifierCLI are tightly coupled, which makes it difficult to refactor
5
+ follow Puppet's lead with Puppet::Application (NotifierCLI translates to Flapjack::Notifier::Application)
6
+ implement simple interface application interface => Flapjack::Notifier::Application.run(options)
7
+
8
+
9
+ * reduce notifier dependencies (e.g. xmpp4r over xmpp4r-simple)
10
+ * make notification/escalation logic pluggable (to reduce packaging dependencies)
11
+
12
+ * release Flapjack as a distribution-consumable tarball
13
+ * automate building of release tarball that optionally pulls in dependencies
14
+ * add lintian-like checks for verifying packagability (see http://pkg-ruby-extras.alioth.debian.org/upstream-devs.html)
15
+
16
+ * build benchmarks for flapjack-{worker,notifier}
17
+
18
+ * setup wiki.flapjack-project.com
3
19
  * documentation!
4
20
  * user
5
21
  * developer
@@ -7,20 +23,31 @@
7
23
  * scaling guide
8
24
  * integrating with collectd guide
9
25
  * writing custom populators guide
10
- * build benchmarks for flapjack-{worker,notifier}
11
26
  * write puppet manifests
12
- * package with pallet
13
- * generate .deb/.rpms
14
- * build packages for gem dependencies
27
+
28
+ * build option to specify notifier(s) directory
15
29
  * sandbox flapjack-worker
16
30
  * provide config option for specifying sandbox dir
31
+
17
32
  * provide common interface for loading checks into beanstalk (extract from populator)
18
- * write check generator
19
- * include a collection of common functions
20
- (logging to rrd, retreiving values, executing check)
33
+ * make message queueing interface more abstract (support for AMQP/RabbitMQ)
34
+
21
35
  * write zeroconf/avahi notifier
22
36
  * write growl notifier
23
- * write way to customise notifier messages (email body, xmpp format)
24
37
  * write sms notifier
25
- * patch beanstalk-client to recognise DRAINING status
38
+ * write way to customise notifier messages (email body, xmpp format)
39
+
26
40
  * http://www.kitchensoap.com/2009/10/05/meanwhile-more-meta-metrics/
41
+
42
+ * write beanstalkd.yreserve to simplify code
43
+ * write beanstalkd.jput, beanstalkd.jreserve for native json api
44
+
45
+ * add support to worker and notifier for multiple beanstalkds
46
+
47
+ * write check generator
48
+ * include a collection of common functions
49
+ (logging to rrd, retreiving values, executing check)
50
+ * patch beanstalk-client to recognise DRAINING status
51
+
52
+
53
+
data/flapjack.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'flapjack'
3
- s.version = '0.4.11'
4
- s.date = '2009-10-24'
3
+ s.version = '0.4.12'
4
+ s.date = '2009-11-22'
5
5
 
6
6
  s.summary = "a scalable and distributed monitoring system"
7
7
  s.description = "Flapjack is highly scalable and distributed monitoring system. It understands the Nagios plugin format, and can easily be scaled from 1 server to 1000."
@@ -11,11 +11,11 @@ Gem::Specification.new do |s|
11
11
  s.homepage = 'http://flapjack-project.com'
12
12
  s.has_rdoc = false
13
13
 
14
- s.add_dependency('daemons', '>= 1.0.10')
15
- s.add_dependency('beanstalk-client', '>= 1.0.2')
16
- s.add_dependency('log4r', '>= 1.0.5')
17
- s.add_dependency('xmpp4r-simple', '>= 0.8.8')
18
- s.add_dependency('mailfactory', '>= 1.4.0')
14
+ s.add_dependency('daemons', '= 1.0.10')
15
+ s.add_dependency('beanstalk-client', '= 1.0.2')
16
+ s.add_dependency('log4r', '= 1.0.5')
17
+ s.add_dependency('xmpp4r', '= 0.5')
18
+ s.add_dependency('tmail', '= 1.2.3.1')
19
19
  s.add_dependency('dm-core', '= 0.9.11')
20
20
  s.add_dependency('dm-timestamps', '= 0.9.11')
21
21
  s.add_dependency('dm-types', '= 0.9.11')
@@ -224,13 +224,14 @@ module Flapjack
224
224
  if any_parents_warning_or_critical?(result)
225
225
  @log.info("Not notifying on check '#{result.id}' as parent is failing.")
226
226
  else
227
+ @log.info("Creating event for check '#{result.id}'")
228
+ # FIXME: this will be a performance hit
229
+ event = ::Event.new(:check_id => result.id)
230
+ raise unless event.save
231
+
227
232
  @log.info("Notifying on check '#{result.id}'")
228
- @notifier.notify!(result)
233
+ @notifier.notify!(result, event)
229
234
  end
230
-
231
- @log.info("Creating event for check '#{result.id}'")
232
- event = Event.new(:check_id => result.id)
233
- raise unless event.save
234
235
  end
235
236
 
236
237
  @log.info("Storing status of check in database")
@@ -22,12 +22,13 @@ module Flapjack
22
22
  @log.warning("there are no notifiers")
23
23
  end
24
24
  end
25
-
26
- def notify!(result)
25
+
26
+ # FIXME: use opts={} convention
27
+ def notify!(result, event)
27
28
  @notifiers.each do |n|
28
29
  @recipients.each do |recipient|
29
30
  @log.info("Notifying #{recipient.name} via #{n.class} about check #{result.id}")
30
- n.notify(:result => result, :who => recipient)
31
+ n.notify(:result => result, :who => recipient, :event => event)
31
32
  end
32
33
  end
33
34
  end
@@ -2,7 +2,8 @@
2
2
 
3
3
  require 'rubygems'
4
4
  require 'net/smtp'
5
- require 'mailfactory'
5
+ require 'tmail'
6
+ require 'log4r'
6
7
 
7
8
  module Flapjack
8
9
  module Notifiers
@@ -10,20 +11,25 @@ module Flapjack
10
11
  class Mailer
11
12
 
12
13
  def initialize(opts={})
13
- @from_address = opts[:from_address]
14
+ if opts[:from_address]
15
+ @from_address = opts[:from_address]
16
+ else
17
+ raise ArgumentError, "from address must be provided"
18
+ end
14
19
  @website_uri = opts[:website_uri] ? opts[:website_uri].gsub(/\/$/, '') : "http://#{`hostname`}"
15
20
  @log = opts[:logger]
16
- @log ||= Log4r::Logger.new("notifier")
21
+ @log ||= ::Log4r::Logger.new("notifier")
17
22
  end
18
23
 
19
24
  def notify(opts={})
20
- raise unless (opts[:who] && opts[:result])
25
+ raise ArgumentError, "a recipient was not specified" unless opts[:who]
26
+ raise ArgumentError, "a result was not specified" unless opts[:result]
21
27
 
22
- mail = MailFactory.new
28
+ mail = TMail::Mail.new
23
29
  mail.to = opts[:who].email
24
30
  mail.from = @from_address
25
31
  mail.subject = "Check: #{opts[:result].id}, Status: #{opts[:result].status}"
26
- mail.text = <<-DESC
32
+ mail.body = <<-DESC
27
33
  Check #{opts[:result].id} returned the status "#{opts[:result].status}".
28
34
 
29
35
  Here was the output:
@@ -35,7 +41,7 @@ module Flapjack
35
41
 
36
42
  begin
37
43
  Net::SMTP.start('localhost') do |smtp|
38
- smtp.sendmail(mail.to_s, mail.from, mail.to)
44
+ return smtp.sendmail(mail.to_s, mail.from, mail.to)
39
45
  end
40
46
  rescue Errno::ECONNREFUSED
41
47
  @log.error("Couldn't establish connection to mail server!")
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'xmpp4r-simple'
3
+ require 'xmpp4r'
4
4
 
5
5
  module Flapjack
6
6
  module Notifiers
@@ -16,7 +16,9 @@ module Flapjack
16
16
  end
17
17
 
18
18
  begin
19
- @xmpp = Jabber::Simple.new(@jid, @password)
19
+ @xmpp = Jabber::Client.new(@jid)
20
+ @xmpp.connect
21
+ @xmpp.auth(@password)
20
22
  rescue SocketError => e
21
23
  @log.error("XMPP: #{e.message}")
22
24
  end
@@ -25,14 +27,16 @@ module Flapjack
25
27
 
26
28
  def notify(opts={})
27
29
 
28
- raise unless opts[:who] && opts[:result]
30
+ raise ArgumentError, "a recipient was not specified" unless opts[:who]
31
+ raise ArgumentError, "a result was not specified" unless opts[:result]
29
32
 
30
- message = <<-DESC
33
+ text = <<-DESC
31
34
  Check #{opts[:result].id} returned the status "#{opts[:result].status}".
32
35
  http://localhost:4000/checks/#{opts[:result].id}
33
36
  DESC
34
-
35
- @xmpp.deliver(opts[:who].jid, message)
37
+
38
+ message = Jabber::Message.new(opts[:who].jid, text)
39
+ @xmpp.send(message)
36
40
 
37
41
  end
38
42
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flapjack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.11
4
+ version: 0.4.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lindsay Holmwood
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-24 00:00:00 +02:00
12
+ date: 2009-11-22 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -18,7 +18,7 @@ dependencies:
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - ">="
21
+ - - "="
22
22
  - !ruby/object:Gem::Version
23
23
  version: 1.0.10
24
24
  version:
@@ -28,7 +28,7 @@ dependencies:
28
28
  version_requirement:
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.0.2
34
34
  version:
@@ -38,29 +38,29 @@ dependencies:
38
38
  version_requirement:
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - ">="
41
+ - - "="
42
42
  - !ruby/object:Gem::Version
43
43
  version: 1.0.5
44
44
  version:
45
45
  - !ruby/object:Gem::Dependency
46
- name: xmpp4r-simple
46
+ name: xmpp4r
47
47
  type: :runtime
48
48
  version_requirement:
49
49
  version_requirements: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ">="
51
+ - - "="
52
52
  - !ruby/object:Gem::Version
53
- version: 0.8.8
53
+ version: "0.5"
54
54
  version:
55
55
  - !ruby/object:Gem::Dependency
56
- name: mailfactory
56
+ name: tmail
57
57
  type: :runtime
58
58
  version_requirement:
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ">="
61
+ - - "="
62
62
  - !ruby/object:Gem::Version
63
- version: 1.4.0
63
+ version: 1.2.3.1
64
64
  version:
65
65
  - !ruby/object:Gem::Dependency
66
66
  name: dm-core