auxesis-flapjack 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
data/TODO.md CHANGED
@@ -7,12 +7,22 @@
7
7
  * update status of checks - DONE
8
8
  * relationships + cascading notifications - DONE
9
9
  * simple graphs
10
+ * event/result history
11
+ * build option to specify notifier(s) directory
10
12
  * documentation!
11
13
  * user
12
14
  * developer
15
+ * step-by-step install guide
16
+ * scaling guide
17
+ * integrating with collectd guide
18
+ * writing custom populators guide
19
+ * write puppet manifests
20
+ * write chef cookbooks
13
21
  * package with pallet
14
22
  * generate .deb/.rpms
15
23
  * build packages for gem dependencies
24
+ * sandbox flapjack-worker
25
+ * provide config option for specifying sandbox dir
16
26
  * provide common interface for loading checks into beanstalk
17
27
  * write check generator
18
28
  * include a collection of common functions
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.5'
4
- s.date = '2009-06-30'
3
+ s.version = '0.4.6'
4
+ s.date = '2009-07-14'
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."
@@ -6,6 +6,8 @@ require 'optparse'
6
6
  require 'log4r'
7
7
  require 'log4r/outputter/syslogoutputter'
8
8
  require File.join(File.dirname(__FILE__), '..', 'database')
9
+ require File.join(File.dirname(__FILE__), '..', 'notifier')
10
+ require File.join(File.dirname(__FILE__), '..', 'result')
9
11
 
10
12
  module Flapjack
11
13
  class NotifierOptions
@@ -152,12 +154,13 @@ module Flapjack
152
154
  raise ArgumentError, "notifiers directory doesn't exist!" unless File.exists?(notifiers_directory)
153
155
 
154
156
  @notifiers = []
155
-
157
+
156
158
  @config.notifiers.each_pair do |notifier, config|
157
159
  filename = File.join(notifiers_directory, notifier.to_s, 'init')
158
160
  if File.exists?(filename + '.rb')
159
161
  @log.debug("Loading the #{notifier.to_s.capitalize} notifier")
160
162
  require filename
163
+ config.merge!(:logger => @log, :website_uri => @config.website_uri)
161
164
  @notifiers << Flapjack::Notifiers.const_get("#{notifier.to_s.capitalize}").new(config)
162
165
  else
163
166
  @log.warning("Flapjack::Notifiers::#{notifier.to_s.capitalize} doesn't exist!")
@@ -214,7 +217,7 @@ module Flapjack
214
217
  def process_result
215
218
  @log.debug("Waiting for new result...")
216
219
  result_job = @results_queue.reserve # blocks until a job is reserved
217
- result = Result.new(YAML::load(result_job.body))
220
+ result = Flapjack::Result.new(YAML::load(result_job.body))
218
221
 
219
222
  @log.info("Processing result for check '#{result.id}'")
220
223
  if result.warning? || result.critical?
@@ -11,6 +11,9 @@ module Flapjack
11
11
 
12
12
  def initialize(opts={})
13
13
  @from_address = opts[:from_address]
14
+ @website_uri = opts[:website_uri].gsub(/\/$/, '')
15
+ @log = opts[:logger]
16
+ @log ||= Log4r::Logger.new("notifier")
14
17
  end
15
18
 
16
19
  def notify(opts={})
@@ -27,11 +30,15 @@ module Flapjack
27
30
  #{opts[:result].output}
28
31
 
29
32
  You can respond to this issue at:
30
- http://localhost:4000/issue/#{opts[:result].object_id * -1}
33
+ #{@website_uri}/issue/#{opts[:result].id}
31
34
  DESC
32
-
33
- Net::SMTP.start('localhost') do |smtp|
34
- smtp.sendmail(mail.to_s, mail.from, mail.to)
35
+
36
+ begin
37
+ Net::SMTP.start('localhost') do |smtp|
38
+ smtp.sendmail(mail.to_s, mail.from, mail.to)
39
+ end
40
+ rescue Errno::ECONNREFUSED
41
+ @log.error("Couldn't establish connection to mail server!")
35
42
  end
36
43
  end
37
44
 
@@ -9,37 +9,39 @@ require 'ostruct'
9
9
  #
10
10
  # Convenience methods are used by the Notifier to determine whether a
11
11
  # notification needs to be sent out.
12
- class Result < OpenStruct
13
-
14
- # Whether a check returns an ok status.
15
- def ok?
16
- self.retval == 0
17
- end
18
-
19
- # Whether a check has a warning status.
20
- def warning?
21
- self.retval == 1
22
- end
23
-
24
- # Whether a check has a critical status.
25
- def critical?
26
- self.retval == 2
27
- end
28
-
29
- # Human readable representation of the check's return value.
30
- def status
31
- case self.retval
32
- when 0 ; "ok"
33
- when 1 ; "warning"
34
- when 2 ; "critical"
12
+ module Flapjack
13
+ class Result < OpenStruct
14
+
15
+ # Whether a check returns an ok status.
16
+ def ok?
17
+ self.retval == 0
35
18
  end
19
+
20
+ # Whether a check has a warning status.
21
+ def warning?
22
+ self.retval == 1
23
+ end
24
+
25
+ # Whether a check has a critical status.
26
+ def critical?
27
+ self.retval == 2
28
+ end
29
+
30
+ # Human readable representation of the check's return value.
31
+ def status
32
+ case self.retval
33
+ when 0 ; "ok"
34
+ when 1 ; "warning"
35
+ when 2 ; "critical"
36
+ end
37
+ end
38
+
39
+ # The id of a check result.
40
+ def id
41
+ # openstruct won't respond, so we have to manually define it
42
+ @table[:id]
43
+ end
44
+
36
45
  end
37
-
38
- # The id of a check result.
39
- def id
40
- # openstruct won't respond, so we have to manually define it
41
- @table[:id]
42
- end
43
-
44
46
  end
45
47
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auxesis-flapjack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
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-06-30 00:00:00 -07:00
12
+ date: 2009-07-14 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency