flapjack 1.0.0rc1 → 1.0.0rc2
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.
- checksums.yaml +4 -4
- data/.gitignore +8 -0
- data/CHANGELOG.md +15 -0
- data/README.md +4 -0
- data/bin/flapjack +15 -2
- data/build.sh +22 -0
- data/dist/etc/init.d/flapjack +1 -1
- data/dist/etc/init.d/flapjack-nagios-receiver +3 -3
- data/dist/etc/init.d/flapper +3 -3
- data/etc/flapjack_config.yaml.example +35 -17
- data/lib/flapjack/cli/receiver.rb +25 -1
- data/lib/flapjack/cli/simulate.rb +16 -9
- data/lib/flapjack/data/entity.rb +17 -21
- data/lib/flapjack/data/entity_check.rb +10 -0
- data/lib/flapjack/gateways/jabber.rb +36 -12
- data/lib/flapjack/gateways/jsonapi/check_methods.rb +32 -0
- data/lib/flapjack/gateways/jsonapi/report_methods.rb +1 -5
- data/lib/flapjack/gateways/web/views/check.html.erb +1 -1
- data/lib/flapjack/gateways/web/views/checks.html.erb +2 -2
- data/lib/flapjack/gateways/web/views/contact.html.erb +2 -2
- data/lib/flapjack/gateways/web/views/entity.html.erb +1 -1
- data/lib/flapjack/patches.rb +70 -0
- data/lib/flapjack/version.rb +1 -1
- data/libexec/httpbroker.go +161 -0
- data/libexec/oneoff.go +75 -0
- data/spec/lib/flapjack/data/entity_spec.rb +1 -1
- data/spec/lib/flapjack/gateways/jabber_spec.rb +15 -17
- data/spec/lib/flapjack/gateways/jsonapi/check_methods_spec.rb +57 -0
- data/src/flapjack/event.go +25 -0
- data/src/flapjack/event_test.go +26 -0
- data/src/flapjack/transport.go +49 -0
- data/src/flapjack/transport_test.go +15 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcd6cb806d57b78108cc67f2064b1b435a73f79e
|
4
|
+
data.tar.gz: 753950c0c1decff7c6d5fc954eede8a0e686d0ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08641c26fb0307d9d9df4d97cc28876d962e883ea5094e719a2837eaad608f8f03d5c936a495cb42aba8d67c651c89dfc1a70da2a22e4aaf5caa70d5414c61b3
|
7
|
+
data.tar.gz: 7011a9ad02bf9bebed297f288496f7e1dc5af7a91e9fffa1d85e78a040514fc069e9cbe021917533f32b3f224b3f1b7c63f5f5d981749c0420afcbd04f52a1dc
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
## Flapjack Changelog
|
2
2
|
|
3
|
+
# 1.0.0rc2 - 2014-07-17
|
4
|
+
- Feature: jsonapi GET /checks badab0d (@ali-graham)
|
5
|
+
- Feature: Add HTTP broker, one-off event submitter, general Go support #553 (@auxesis)
|
6
|
+
- Feature: Add ability to disable check via JSON API #529 (@ali-graham)
|
7
|
+
- Feature: Jabber - Resource in JID should be supported in the config #557 (@jessereynolds)
|
8
|
+
- Feature: Jabber - add an 'identifiers' list to the config #558 (@jessereynolds)
|
9
|
+
- Feature: Jabber - handle HipChat style status updates as per XEP-0085 #559 (@jessereynolds)
|
10
|
+
- Feature: auto generate entity ID on creation if none supplied #568 (@jessereynolds)
|
11
|
+
- Feature: Use friendly help if you run the server with old syntax #564 (@Hobbsee)
|
12
|
+
- Bug: Decommission Check button returning a 404 #538 (@ali-graham)
|
13
|
+
- Bug: incorrect default config path in flapjack gli #554 (@jessereynolds)
|
14
|
+
- Bug: make sure that base_url isn't escaped so that links work correctly #556 (@mattdelves)
|
15
|
+
- Chore: Update development section of example config file #546 (@Hobbsee)
|
16
|
+
|
17
|
+
|
3
18
|
# 1.0.0rc1 - 2014-06-25
|
4
19
|
- Feature: Allow ncsm to be skipped using a configured whitelist #485 (@StephenWeber)
|
5
20
|
- Feature: GLI the CLI (one command to rule them all) #478 (@auxesis, @ali-graham)
|
data/README.md
CHANGED
@@ -15,6 +15,10 @@ Flapjack will be immediately useful to you if:
|
|
15
15
|
* Your monitoring infrastructure is **multitenant**, and each customer has a **bespoke alerting strategy**.
|
16
16
|
* You want to dip your toe in the water and try alternative check execution engines like Sensu, Icinga, or cron in parallel to Nagios.
|
17
17
|
|
18
|
+
### Try it out with the Quickstart Guide
|
19
|
+
|
20
|
+
The [Quickstart](http://flapjack.io/quickstart/) guide will help you get Flapjack up and running in a VM locally using Vagrant and VirtualBox.
|
21
|
+
|
18
22
|
### The technical low-down
|
19
23
|
|
20
24
|
Flapjack provides a scalable method for dealing with events representing changes in system state (OK -> WARNING -> CRITICAL transitions) and alerting appropriate people as necessary.
|
data/bin/flapjack
CHANGED
@@ -12,7 +12,7 @@ program_desc 'Flexible monitoring notification routing system'
|
|
12
12
|
version Flapjack::VERSION
|
13
13
|
|
14
14
|
desc 'Configuration file to use'
|
15
|
-
default_value '/etc/flapjack/
|
15
|
+
default_value '/etc/flapjack/flapjack_config.yaml'
|
16
16
|
arg_name '/path/to/flapjack.yaml'
|
17
17
|
flag [:c,:config]
|
18
18
|
|
@@ -34,7 +34,20 @@ post do |global,command,options,args|
|
|
34
34
|
end
|
35
35
|
|
36
36
|
on_error do |exception|
|
37
|
-
|
37
|
+
# We've changed the commands to control the flapjack server. If we detect
|
38
|
+
# the user has tried one of the old commands, show them what they should
|
39
|
+
# have used instead.
|
40
|
+
SERVER_COMMANDS = %w(start stop restart reload status)
|
41
|
+
message = exception.message
|
42
|
+
input = message.split("'").last.downcase
|
43
|
+
old_command = message.start_with?('Unknown command') && SERVER_COMMANDS.include?(input)
|
44
|
+
if old_command
|
45
|
+
puts exception.message
|
46
|
+
puts "\nDid you mean: #{$PROGRAM_NAME} server #{input}?"
|
47
|
+
puts "\nTry #{$PROGRAM_NAME} help"
|
48
|
+
end
|
49
|
+
# If this wasn't an old server command, return true to show the standard error dialog
|
50
|
+
!old_command
|
38
51
|
end
|
39
52
|
|
40
53
|
exit run(ARGV)
|
data/build.sh
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
export GOPATH=$(pwd):$GOPATH
|
6
|
+
|
7
|
+
go get github.com/garyburd/redigo/redis
|
8
|
+
go get github.com/go-martini/martini
|
9
|
+
go get gopkg.in/alecthomas/kingpin.v1
|
10
|
+
|
11
|
+
go test flapjack
|
12
|
+
|
13
|
+
go build -x -o libexec/httpbroker libexec/httpbroker.go
|
14
|
+
go build -x -o libexec/oneoff libexec/oneoff.go
|
15
|
+
|
16
|
+
|
17
|
+
if [ ! -z "$CROSSCOMPILE" ]; then
|
18
|
+
for command in httpbroker oneoff; do
|
19
|
+
GOOS=linux GOARCH=amd64 CGOENABLED=0 go build -x -o libexec/$command.linux_amd64 libexec/$command.go
|
20
|
+
GOOS=linux GOARCH=386 CGOENABLED=0 go build -x -o libexec/$command.linux_386 libexec/$command.go
|
21
|
+
done
|
22
|
+
fi
|
data/dist/etc/init.d/flapjack
CHANGED
@@ -8,14 +8,14 @@
|
|
8
8
|
|
9
9
|
PATH=/opt/flapjack/bin:$PATH
|
10
10
|
|
11
|
-
if [ ! $(which flapjack
|
12
|
-
echo "Error: flapjack
|
11
|
+
if [ ! $(which flapjack) ]; then
|
12
|
+
echo "Error: flapjack isn't in PATH."
|
13
13
|
echo "Refusing to do anything!"
|
14
14
|
exit 1
|
15
15
|
fi
|
16
16
|
|
17
17
|
# Evaluate command
|
18
|
-
flapjack
|
18
|
+
flapjack receiver nagios $1 --daemonize
|
19
19
|
|
20
20
|
RETVAL=$?
|
21
21
|
exit $RETVAL
|
data/dist/etc/init.d/flapper
CHANGED
@@ -5,14 +5,14 @@
|
|
5
5
|
|
6
6
|
PATH=/opt/flapjack/bin:$PATH
|
7
7
|
|
8
|
-
if [ ! $(which
|
9
|
-
echo "Error:
|
8
|
+
if [ ! $(which flapjack) ]; then
|
9
|
+
echo "Error: flapjack isn't in PATH."
|
10
10
|
echo "Refusing to do anything!"
|
11
11
|
exit 1
|
12
12
|
fi
|
13
13
|
|
14
14
|
# Evaluate command
|
15
|
-
flapper $1
|
15
|
+
flapjack flapper $1
|
16
16
|
|
17
17
|
RETVAL=$?
|
18
18
|
exit $RETVAL
|
@@ -90,6 +90,8 @@ production:
|
|
90
90
|
jabberid: "flapjack@jabber.example.com"
|
91
91
|
password: "good-password"
|
92
92
|
alias: "flapjack"
|
93
|
+
identifiers:
|
94
|
+
- "@flapjack"
|
93
95
|
rooms:
|
94
96
|
- "gimp@conference.jabber.example.com"
|
95
97
|
- "log@conference.jabber.example.com"
|
@@ -152,7 +154,7 @@ development:
|
|
152
154
|
log_file: log/flapjack.log
|
153
155
|
daemonize: yes
|
154
156
|
logger:
|
155
|
-
level:
|
157
|
+
level: DEBUG
|
156
158
|
syslog_errors: yes
|
157
159
|
redis:
|
158
160
|
host: 127.0.0.1
|
@@ -165,7 +167,8 @@ development:
|
|
165
167
|
archive_events: true
|
166
168
|
events_archive_maxage: 10800
|
167
169
|
new_check_scheduled_maintenance_duration: 100 years
|
168
|
-
|
170
|
+
new_check_scheduled_maintenance_ignore_tags:
|
171
|
+
- bypass_ncsm
|
169
172
|
logger:
|
170
173
|
level: DEBUG
|
171
174
|
syslog_errors: yes
|
@@ -182,19 +185,25 @@ development:
|
|
182
185
|
level: DEBUG
|
183
186
|
syslog_errors: yes
|
184
187
|
nagios-receiver:
|
185
|
-
fifo: "/
|
188
|
+
fifo: "/var/cache/nagios3/event_stream.fifo"
|
186
189
|
pid_file: "tmp/pids/flapjack-nagios-receiver.pid"
|
187
190
|
log_file: "log/flapjack-nagios-receiver.log"
|
191
|
+
nsca-receiver:
|
192
|
+
fifo: "/var/lib/nagios3/rw/nagios.cmd"
|
193
|
+
pid_file: "/var/run/flapjack/flapjack-nsca-receiver.pid"
|
194
|
+
log_file: "/var/log/flapjack/flapjack-nsca-receiver.log"
|
188
195
|
gateways:
|
189
196
|
email:
|
190
|
-
enabled:
|
197
|
+
enabled: no
|
191
198
|
queue: email_notifications
|
192
199
|
logger:
|
193
|
-
level:
|
200
|
+
level: DEBUG
|
194
201
|
syslog_errors: yes
|
195
202
|
smtp_config:
|
196
|
-
#
|
203
|
+
# from: "Flapjack Example <flapjack@noreply.example>"
|
204
|
+
# reply_to: "flapjack@support.example"
|
197
205
|
host: 127.0.0.1
|
206
|
+
# 1025 is the default port for http://mailcatcher.me
|
198
207
|
port: 1025
|
199
208
|
starttls: false
|
200
209
|
#auth:
|
@@ -210,15 +219,13 @@ development:
|
|
210
219
|
# rollup.html: '/etc/flapjack/templates/email/rollup.html.erb'
|
211
220
|
# alert.html: '/etc/flapjack/templates/email/alert.html.erb'
|
212
221
|
sms:
|
213
|
-
enabled:
|
222
|
+
enabled: no
|
214
223
|
queue: sms_notifications
|
215
|
-
|
216
|
-
|
217
|
-
endpoint: 'http://localhost:9292/FakeMessagenetAPI.aspx'
|
218
|
-
username: "gretta"
|
224
|
+
endpoint: 'https://www.messagenet.com.au/dotnet/Lodge.asmx/LodgeSMSMessage'
|
225
|
+
username: "ermahgerd"
|
219
226
|
password: "xxxx"
|
220
227
|
logger:
|
221
|
-
level:
|
228
|
+
level: DEBUG
|
222
229
|
syslog_errors: yes
|
223
230
|
# location of custom alert templates
|
224
231
|
#templates:
|
@@ -230,13 +237,13 @@ development:
|
|
230
237
|
server: "jabber.example.com"
|
231
238
|
port: 5222
|
232
239
|
jabberid: "flapjack@jabber.example.com"
|
233
|
-
password: "
|
240
|
+
password: "good-password"
|
234
241
|
alias: "flapjack"
|
235
242
|
rooms:
|
236
243
|
- "gimp@conference.jabber.example.com"
|
237
244
|
- "log@conference.jabber.example.com"
|
238
245
|
logger:
|
239
|
-
level:
|
246
|
+
level: DEBUG
|
240
247
|
syslog_errors: yes
|
241
248
|
# location of custom alert templates
|
242
249
|
#templates:
|
@@ -253,11 +260,22 @@ development:
|
|
253
260
|
# alert.text: '/etc/flapjack/templates/pagerduty/alert.text.erb'
|
254
261
|
web:
|
255
262
|
enabled: yes
|
256
|
-
port:
|
263
|
+
port: 3080
|
257
264
|
timeout: 300
|
258
265
|
access_log: "log/web_access.log"
|
266
|
+
api_url: "http://localhost:3081/"
|
267
|
+
#logo_image_path: "/etc/flapjack/web/custom_logo/flapjack-2013-notext-transparent-300-300.png"
|
259
268
|
logger:
|
260
|
-
level:
|
269
|
+
level: DEBUG
|
270
|
+
syslog_errors: yes
|
271
|
+
jsonapi:
|
272
|
+
enabled: yes
|
273
|
+
port: 3081
|
274
|
+
timeout: 300
|
275
|
+
access_log: "log/jsonapi_access.log"
|
276
|
+
base_url: "http://localhost:3081/"
|
277
|
+
logger:
|
278
|
+
level: DEBUG
|
261
279
|
syslog_errors: yes
|
262
280
|
oobetet:
|
263
281
|
enabled: no
|
@@ -275,7 +293,7 @@ development:
|
|
275
293
|
- "gimp@conference.jabber.example.com"
|
276
294
|
- "log@conference.jabber.example.com"
|
277
295
|
logger:
|
278
|
-
level:
|
296
|
+
level: DEBUG
|
279
297
|
syslog_errors: yes
|
280
298
|
|
281
299
|
test:
|
@@ -8,6 +8,7 @@ Oj.default_options = { :indent => 0, :mode => :strict }
|
|
8
8
|
|
9
9
|
require 'flapjack/configuration'
|
10
10
|
require 'flapjack/data/event'
|
11
|
+
require 'flapjack/patches'
|
11
12
|
|
12
13
|
# TODO options should be overridden by similar config file options
|
13
14
|
|
@@ -630,8 +631,31 @@ command :receiver do |receiver|
|
|
630
631
|
end
|
631
632
|
end
|
632
633
|
|
633
|
-
end
|
634
634
|
|
635
|
+
receiver.desc 'One-off event submitter'
|
636
|
+
receiver.command :oneoff do |oneoff|
|
637
|
+
oneoff.passthrough = true
|
638
|
+
oneoff.action do |global_options, options, args|
|
639
|
+
libexec = Pathname.new(__FILE__).parent.parent.parent.parent.join('libexec').expand_path
|
640
|
+
oneoff = libexec.join('oneoff')
|
641
|
+
if oneoff.exist?
|
642
|
+
Kernel.exec(oneoff.to_s, *ARGV)
|
643
|
+
end
|
644
|
+
end
|
645
|
+
end
|
646
|
+
|
647
|
+
receiver.desc 'HTTP API that caches and submits events'
|
648
|
+
receiver.command :httpbroker do |httpbroker|
|
649
|
+
httpbroker.passthrough = true
|
650
|
+
httpbroker.action do |global_options, options, args|
|
651
|
+
libexec = Pathname.new(__FILE__).parent.parent.parent.parent.join('libexec').expand_path
|
652
|
+
httpbroker = libexec.join('httpbroker')
|
653
|
+
if httpbroker.exist?
|
654
|
+
Kernel.exec(httpbroker.to_s, *ARGV)
|
655
|
+
end
|
656
|
+
end
|
657
|
+
end
|
658
|
+
end
|
635
659
|
|
636
660
|
|
637
661
|
# # Nsca example line for a storage-device check:
|
@@ -1,6 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require 'eventmachine'
|
4
|
+
require 'em-synchrony'
|
3
5
|
require 'redis'
|
6
|
+
require 'redis/connection/synchrony'
|
4
7
|
|
5
8
|
require 'flapjack/configuration'
|
6
9
|
require 'flapjack/data/event'
|
@@ -66,25 +69,29 @@ module Flapjack
|
|
66
69
|
recovery = event.merge('state' => 'ok', 'summary' => 'Simulated check output (test by operator)')
|
67
70
|
key = "#{event['entity']}:#{event['check']}"
|
68
71
|
|
69
|
-
|
70
|
-
Flapjack::Data::Event.add(failure, :redis => redis)
|
72
|
+
EM.synchrony do
|
71
73
|
|
72
|
-
|
74
|
+
puts "#{Time.now}: sending failure event (#{state}) for #{key}"
|
75
|
+
Flapjack::Data::Event.add(failure, :redis => redis)
|
73
76
|
|
74
77
|
EM.add_timer(stop_after) do
|
75
78
|
puts "#{Time.now}: stopping"
|
76
79
|
if recover
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
+
EM.synchrony do
|
81
|
+
puts "#{Time.now}: sending recovery event for #{key}"
|
82
|
+
Flapjack::Data::Event.add(recovery.merge('time' => Time.now.to_i),
|
83
|
+
:redis => redis)
|
84
|
+
end
|
80
85
|
end
|
81
86
|
EM.stop
|
82
87
|
end
|
83
88
|
|
84
89
|
EM.add_periodic_timer(opts[:interval]) do
|
85
|
-
|
86
|
-
|
87
|
-
|
90
|
+
EM.synchrony do
|
91
|
+
puts "#{Time.now}: sending failure event (#{state}) for #{key}"
|
92
|
+
Flapjack::Data::Event.add(failure.merge('time' => Time.now.to_i),
|
93
|
+
:redis => redis)
|
94
|
+
end
|
88
95
|
end
|
89
96
|
|
90
97
|
end
|
data/lib/flapjack/data/entity.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require 'securerandom'
|
4
|
+
|
3
5
|
require 'flapjack/data/contact'
|
4
6
|
require 'flapjack/data/tag'
|
5
7
|
require 'flapjack/data/tag_set'
|
@@ -34,28 +36,22 @@ module Flapjack
|
|
34
36
|
|
35
37
|
#FIXME: should probably raise an exception if trying to create a new entity with the
|
36
38
|
# same name or id as an existing entity. (Go away and use update instead.)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
self.new(:name => entity['name'],
|
51
|
-
:id => entity['id'],
|
52
|
-
:redis => redis)
|
53
|
-
else
|
54
|
-
# empty string is the redis equivalent of a Ruby nil, i.e. key with
|
55
|
-
# no value
|
56
|
-
redis.set("entity_id:#{entity['name']}", '')
|
57
|
-
nil
|
39
|
+
entity_id = entity['id'] ? entity['id'] : SecureRandom.uuid
|
40
|
+
existing_name = redis.hget("entity:#{entity_id}", 'name')
|
41
|
+
redis.del("entity_id:#{existing_name}") unless existing_name == entity['name']
|
42
|
+
redis.set("entity_id:#{entity['name']}", entity_id)
|
43
|
+
redis.hset("entity:#{entity_id}", 'name', entity['name'])
|
44
|
+
|
45
|
+
redis.del("contacts_for:#{entity_id}")
|
46
|
+
if entity['contacts'] && entity['contacts'].respond_to?(:each)
|
47
|
+
entity['contacts'].each {|contact_id|
|
48
|
+
next if Flapjack::Data::Contact.find_by_id(contact_id, :redis => redis).nil?
|
49
|
+
redis.sadd("contacts_for:#{entity_id}", contact_id)
|
50
|
+
}
|
58
51
|
end
|
52
|
+
self.new(:name => entity['name'],
|
53
|
+
:id => entity_id,
|
54
|
+
:redis => redis)
|
59
55
|
end
|
60
56
|
|
61
57
|
def self.find_by_name(entity_name, options = {})
|
@@ -661,6 +661,16 @@ module Flapjack
|
|
661
661
|
@ack_hash
|
662
662
|
end
|
663
663
|
|
664
|
+
def to_jsonapi(opts = {})
|
665
|
+
{
|
666
|
+
"name" => @check,
|
667
|
+
"entity_name" => @entity.name,
|
668
|
+
"links" => {
|
669
|
+
:entities => opts[:entity_ids] || [],
|
670
|
+
}
|
671
|
+
}.to_json
|
672
|
+
end
|
673
|
+
|
664
674
|
private
|
665
675
|
|
666
676
|
def initialize(entity, check, options = {})
|