auxesis-flapjack 0.4.2 → 0.4.5

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/README.md CHANGED
@@ -22,7 +22,11 @@ Add GPG keys for the repos:
22
22
 
23
23
  Update your package list:
24
24
 
25
- sudo aptitude update
25
+ sudo apt-get update
26
+
27
+ Install Ruby dependencies:
28
+
29
+ sudo apt-get install build-essential libsqlite3-dev
26
30
 
27
31
  Install rubygems + beanstalkd:
28
32
 
@@ -70,12 +74,24 @@ Make sure beanstalkd is running.
70
74
  You'll want to set up `/etc/flapjack/recipients.yaml` so notifications can be sent via
71
75
  `flapjack-notifier`:
72
76
 
77
+ ---
73
78
  - :name: Jane Doe
74
79
  :email: "jane@doe.com"
75
80
  :phone: "+61 444 222 111"
76
81
  :pager: "61444222111"
77
82
  :jid: "jane@doe.com"
78
83
 
84
+ You also need to set up `/etc/flapjack/flapjack-notifier.yaml`:
85
+
86
+ ---
87
+ :notifiers:
88
+ :mailer:
89
+ :from_address: notifications@my-domain.com
90
+ :xmpp:
91
+ :jid: notifications@my-domain.com
92
+ :password: foo
93
+ :database_uri: "sqlite3:///var/lib/flapjack/flapjack.db"
94
+
79
95
  Start up a cluster of workers:
80
96
 
81
97
  flapjack-worker-manager start
@@ -89,7 +105,7 @@ Each of the `flapjack-worker`s will output to syslog (check in /var/log/messages
89
105
 
90
106
  Start up the notifier:
91
107
 
92
- flapjack-notifier --recipients /etc/flapjack/recipients.yaml
108
+ flapjack-notifier-manager start --recipients /etc/flapjack/recipients.yaml
93
109
 
94
110
  Currently there are email and XMPP notifiers.
95
111
 
data/TODO.md CHANGED
@@ -7,6 +7,9 @@
7
7
  * update status of checks - DONE
8
8
  * relationships + cascading notifications - DONE
9
9
  * simple graphs
10
+ * documentation!
11
+ * user
12
+ * developer
10
13
  * package with pallet
11
14
  * generate .deb/.rpms
12
15
  * build packages for gem dependencies
data/bin/flapjack-worker CHANGED
@@ -17,7 +17,9 @@ trap("INT") do
17
17
  end
18
18
 
19
19
  @options = Flapjack::WorkerOptions.parse(ARGV)
20
- @worker = Flapjack::Worker.new(:host => @options.host, :port => @options.port)
20
+ @worker = Flapjack::Worker.new(:host => @options.host,
21
+ :port => @options.port,
22
+ :checks_directory => @options.check_directory)
21
23
 
22
24
  begin
23
25
  @worker.process_loop
@@ -39,7 +39,7 @@ end
39
39
  system("mkdir -p /var/run/flapjack")
40
40
  system("chmod a+rw /var/run/flapjack")
41
41
 
42
- etc_path=`gem contents flapjack |grep etc`.split.first.gsub(/etc\/.+/, 'etc').strip
42
+ etc_path=`gem contents auxesis-flapjack |grep etc`.split.first.gsub(/etc\/.+/, 'etc').strip
43
43
  system("cp -aiv #{etc_path}/* /etc")
44
44
 
45
45
  # set sequence number to 50 so beanstalkd has a chance to boot
@@ -49,6 +49,10 @@ system("update-rc.d flapjack-notifier defaults 50")
49
49
  puts
50
50
  puts "Setup complete!"
51
51
  puts
52
- puts "You may want to customise /etc/flapjack/recipients.yaml"
52
+ puts "You will want to customise:"
53
+ puts " * /etc/flapjack/recipients.yaml"
54
+ puts " * /etc/flapjack/flapjack-notifier.yaml"
55
+ puts
56
+ puts ".examples of these files exist in /etc/flapjack/'
53
57
 
54
58
 
@@ -0,0 +1,38 @@
1
+ ### Configuring ###
2
+
3
+ You can configure who receives notifications from `flapjack-notifier`
4
+ in `/etc/flapjack/recipients.yaml`:
5
+
6
+ ---
7
+ - :name: Jane Doe
8
+ :email: "jane@doe.com"
9
+ :phone: "+61 444 222 111"
10
+ :pager: "61444222111"
11
+ :jid: "jane@doe.com"
12
+
13
+ Then you can configure how people are notified in `/etc/flapjack/flapjack-notifier.yaml`:
14
+
15
+ ---
16
+ :notifiers:
17
+ :mailer:
18
+ :from_address: notifications@my-domain.com
19
+ :xmpp:
20
+ :jid: notifications@my-domain.com
21
+ :password: foo
22
+ :database_uri: "sqlite3:///var/lib/flapjack/flapjack.db"
23
+
24
+ Currently there are email and XMPP notifiers.
25
+
26
+ The `database_uri` setting must point to the database `flapjack-admin` backs
27
+ onto. This can be SQLite3, MySQL, or PostgreSQL:
28
+
29
+ :database_uri: "mysql://user:password@localhost/flapjack_production"
30
+ # or
31
+ :database_uri: "postgres://me:spoons@db.mydomain.com/flapjack_production"
32
+
33
+ Now you need to restart the notifier:
34
+
35
+ flapjack-notifier-manager restart --recipients /etc/flapjack/recipients.yaml \
36
+ --config /etc/flapjack/flapjack-notifier.yaml
37
+
38
+
data/doc/DEVELOPING.md ADDED
@@ -0,0 +1,35 @@
1
+ Developing
2
+ ----------
3
+
4
+ You can write your own notifiers and place them in `lib/flapjack/notifiers/`.
5
+
6
+ Your notifier just needs to implement the `notify` method, and take in a hash:
7
+
8
+ class Sms
9
+ def initialize(opts={})
10
+ # you may want to set from address here
11
+ @from = (opts[:from] || "0431 112 233")
12
+ end
13
+
14
+ def notify(opts={})
15
+ who = opts[:who]
16
+ result = opts[:result]
17
+ # sms to your hearts content
18
+ end
19
+ end
20
+
21
+
22
+ Testing
23
+ -------
24
+
25
+ Flapjack is, and will continue to be, well tested. Monitoring is like continuous
26
+ integration for production apps, so why shouldn't your monitoring system have tests?
27
+
28
+ Testing is done with rspec, and tests live in `spec/`.
29
+
30
+ To run the tests, check out the code and run:
31
+
32
+ $ rake spec
33
+
34
+
35
+
data/doc/INSTALL.md ADDED
@@ -0,0 +1,64 @@
1
+ Dependencies
2
+ ------------
3
+
4
+ Before installing Flapjack you will need to setup some dependencies.
5
+
6
+ ### Setup dependencies (Ubuntu Hardy) ###
7
+
8
+ Add the following lines to `/etc/apt/sources.list`
9
+
10
+ deb http://ppa.launchpad.net/ubuntu-ruby-backports/ubuntu hardy main
11
+ deb http://ppa.launchpad.net/auxesis/ppa/ubuntu hardy main
12
+
13
+ Add GPG keys for the repos:
14
+
15
+ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 288BA53BCB7DA731
16
+
17
+ Update your package list:
18
+
19
+ sudo apt-get update
20
+
21
+ Install Ruby dependencies:
22
+
23
+ sudo apt-get install build-essential libsqlite3-dev
24
+
25
+ Install rubygems + beanstalkd:
26
+
27
+ sudo apt-get install rubygems beanstalkd
28
+
29
+ Set `ENABLED=1` in `/etc/default/beanstalkd`.
30
+
31
+ Start beanstalkd:
32
+
33
+ sudo /etc/init.d/beanstalkd start
34
+
35
+
36
+ ### Setup dependencies (everyone else) ###
37
+
38
+ Install the following software through your package manager or from source:
39
+
40
+ - beanstalkd (from [http://xph.us/software/beanstalkd/](http://xph.us/software/beanstalkd/))
41
+ - libevent (from [http://monkey.org/~provos/libevent/](http://monkey.org/~provos/libevent/))
42
+ - latest RubyGems (from [http://rubyforge.org/projects/rubygems/](http://rubyforge.org/projects/rubygems/))
43
+
44
+
45
+ ## Installation ##
46
+
47
+ Add GitHub's RubyGems server to your Gem sources:
48
+
49
+ sudo gem sources -a http://gems.github.com
50
+
51
+ Install the Flapjack gem:
52
+
53
+ sudo gem install auxesis-flapjack
54
+
55
+ Then run the magic configuration script to set up init scripts:
56
+
57
+ sudo install-flapjack-systemwide
58
+
59
+ The script will prompt you if it wants to do anything destructive.
60
+
61
+ ## Packages ##
62
+
63
+ We want to provide native packages for Flapjack (`.deb`, `.rpm`, `.ebuild`). If
64
+ you'd like to contribute please let us know!
@@ -0,0 +1,8 @@
1
+ ---
2
+ :notifiers:
3
+ :mailer:
4
+ :from_address: notifications@my-domain.com
5
+ :xmpp:
6
+ :jid: notifications@my-domain.com
7
+ :password: foo
8
+ :database_uri: "sqlite3:///var/lib/flapjack/flapjack.db"
data/flapjack.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'flapjack'
3
- s.version = '0.4.2'
3
+ s.version = '0.4.5'
4
4
  s.date = '2009-06-30'
5
5
 
6
6
  s.summary = "a scalable and distributed monitoring system"
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
25
25
 
26
26
  s.bindir = "bin"
27
27
  s.executables = ["flapjack-notifier", "flapjack-notifier-manager", "flapjack-stats", "flapjack-worker", "flapjack-worker-manager", "install-flapjack-systemwide"]
28
- s.files = ["LICENCE", "README.md", "Rakefile", "TODO.md", "bin/flapjack-notifier", "bin/flapjack-notifier-manager", "bin/flapjack-stats", "bin/flapjack-worker", "bin/flapjack-worker-manager", "bin/install-flapjack-systemwide", "etc/default/flapjack-notifier", "etc/default/flapjack-workers", "etc/flapjack/recipients.yaml", "etc/init.d/flapjack-notifier", "etc/init.d/flapjack-workers", "flapjack.gemspec", "lib/flapjack/cli/notifier.rb", "lib/flapjack/cli/notifier_manager.rb", "lib/flapjack/cli/worker.rb", "lib/flapjack/cli/worker_manager.rb", "lib/flapjack/database.rb", "lib/flapjack/models/check.rb", "lib/flapjack/models/check_template.rb", "lib/flapjack/models/node.rb", "lib/flapjack/models/related_check.rb", "lib/flapjack/notifier.rb", "lib/flapjack/notifiers/mailer/init.rb", "lib/flapjack/notifiers/mailer/mailer.rb", "lib/flapjack/notifiers/xmpp/init.rb", "lib/flapjack/notifiers/xmpp/xmpp.rb", "lib/flapjack/patches.rb", "lib/flapjack/result.rb"]
28
+ s.files = ["LICENCE", "README.md", "Rakefile", "TODO.md", "bin/flapjack-notifier", "bin/flapjack-notifier-manager", "bin/flapjack-stats", "bin/flapjack-worker", "bin/flapjack-worker-manager", "bin/install-flapjack-systemwide", "doc/CONFIGURING.md", "doc/DEVELOPING.md", "doc/INSTALL.md", "etc/default/flapjack-notifier", "etc/default/flapjack-workers", "etc/flapjack/flapjack-notifier.yaml.example", "etc/flapjack/recipients.yaml.example", "etc/init.d/flapjack-notifier", "etc/init.d/flapjack-workers", "flapjack.gemspec", "lib/flapjack/checks/http_content", "lib/flapjack/cli/notifier.rb", "lib/flapjack/cli/notifier_manager.rb", "lib/flapjack/cli/worker.rb", "lib/flapjack/cli/worker_manager.rb", "lib/flapjack/database.rb", "lib/flapjack/models/check.rb", "lib/flapjack/models/check_template.rb", "lib/flapjack/models/node.rb", "lib/flapjack/models/related_check.rb", "lib/flapjack/notifier.rb", "lib/flapjack/notifiers/mailer/init.rb", "lib/flapjack/notifiers/mailer/mailer.rb", "lib/flapjack/notifiers/xmpp/init.rb", "lib/flapjack/notifiers/xmpp/xmpp.rb", "lib/flapjack/patches.rb", "lib/flapjack/result.rb"]
29
29
  end
30
30
 
31
31
 
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'open-uri'
4
+
5
+ page = ARGV[0]
6
+ string = ARGV[1]
7
+
8
+ exit 2 unless page && string
9
+
10
+ body = open(page).read
11
+ if body =~ /#{string}/
12
+ exit 0
13
+ else
14
+ exit 2
15
+ end
@@ -192,6 +192,7 @@ module Flapjack
192
192
  end
193
193
  end
194
194
 
195
+ # FIXME: we're doing a lookup twice - optimise out
195
196
  def save_result(result)
196
197
  if check = Check.get(result.id)
197
198
  check.status = result.retval
@@ -201,6 +202,7 @@ module Flapjack
201
202
  end
202
203
  end
203
204
 
205
+ # FIXME: we're doing a lookup twice - optimise out
204
206
  def any_parents_warning_or_critical?(result)
205
207
  if check = Check.get(result.id)
206
208
  check.worst_parent_status > 0 ? true : false
@@ -21,6 +21,9 @@ module Flapjack
21
21
  opts.on('-p', '--port PORT', 'beanstalkd port') do |port|
22
22
  options.port = port.to_i
23
23
  end
24
+ opts.on('-c', '--checks-directory DIR', 'sandboxed check directory') do |dir|
25
+ options.checks_directory = dir.to_s
26
+ end
24
27
  opts.on_tail("-h", "--help", "Show this message") do
25
28
  puts opts
26
29
  exit
@@ -40,6 +43,7 @@ module Flapjack
40
43
  # default the port
41
44
  options.host ||= 'localhost'
42
45
  options.port ||= 11300
46
+ options.checks_directory ||= File.join(File.dirname(__FILE__), '..', 'checks')
43
47
 
44
48
  options
45
49
  end
@@ -52,6 +56,7 @@ module Flapjack
52
56
  def initialize(opts={})
53
57
  @jobs = Beanstalk::Pool.new(["#{opts[:host]}:#{opts[:port]}"], 'jobs')
54
58
  @results = Beanstalk::Pool.new(["#{opts[:host]}:#{opts[:port]}"], 'results')
59
+ @sandbox = (opts[:check_directory] || File.expand_path(File.join(File.dirname(__FILE__), '..', 'checks')))
55
60
 
56
61
  if opts[:logger]
57
62
  @log = opts[:logger]
@@ -84,7 +89,7 @@ module Flapjack
84
89
  end
85
90
 
86
91
  def perform_check(cmd)
87
- command = "sh -c '#{cmd}'"
92
+ command = "sh -c '#{@sandbox}/#{cmd}'"
88
93
  @log.debug("Executing check: \"#{command}\"")
89
94
  result = `#{command}`
90
95
  retval = $?.exitstatus
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.2
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lindsay Holmwood
@@ -146,12 +146,17 @@ files:
146
146
  - bin/flapjack-worker
147
147
  - bin/flapjack-worker-manager
148
148
  - bin/install-flapjack-systemwide
149
+ - doc/CONFIGURING.md
150
+ - doc/DEVELOPING.md
151
+ - doc/INSTALL.md
149
152
  - etc/default/flapjack-notifier
150
153
  - etc/default/flapjack-workers
151
- - etc/flapjack/recipients.yaml
154
+ - etc/flapjack/flapjack-notifier.yaml.example
155
+ - etc/flapjack/recipients.yaml.example
152
156
  - etc/init.d/flapjack-notifier
153
157
  - etc/init.d/flapjack-workers
154
158
  - flapjack.gemspec
159
+ - lib/flapjack/checks/http_content
155
160
  - lib/flapjack/cli/notifier.rb
156
161
  - lib/flapjack/cli/notifier_manager.rb
157
162
  - lib/flapjack/cli/worker.rb