flapjack 0.5.5 → 0.6.23
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/.gitignore +10 -0
- data/.rbenv-version +1 -0
- data/.rspec +10 -0
- data/Gemfile +18 -0
- data/Guardfile +14 -0
- data/README.md +152 -173
- data/Rakefile +53 -150
- data/bin/flapjack +72 -0
- data/bin/flapjack-nagios-receiver +111 -0
- data/bin/flapjack-nagios-receiver-control +15 -0
- data/bin/flapjack-netsaint-parser +0 -2
- data/bin/flapjack-populator +133 -16
- data/bin/install-flapjack-systemwide +2 -2
- data/config.ru +11 -0
- data/dist/etc/init.d/flapjack +46 -0
- data/dist/etc/init.d/flapjack-nagios-receiver +36 -0
- data/doc/GLOSSARY.md +19 -0
- data/etc/flapjack_config.yaml.example +90 -0
- data/features/events.feature +132 -0
- data/features/notifications.feature +57 -0
- data/features/packaging-lintian.feature +5 -3
- data/features/steps/events_steps.rb +164 -0
- data/features/steps/flapjack-importer_steps.rb +2 -5
- data/features/steps/flapjack-worker_steps.rb +13 -6
- data/features/steps/notifications_steps.rb +178 -0
- data/features/steps/packaging-lintian_steps.rb +14 -0
- data/features/steps/time_travel_steps.rb +34 -0
- data/features/support/env.rb +63 -36
- data/flapjack.gemspec +35 -186
- data/lib/flapjack.rb +2 -0
- data/lib/flapjack/api.rb +274 -0
- data/lib/flapjack/api/entity_check_presenter.rb +184 -0
- data/lib/flapjack/api/entity_presenter.rb +66 -0
- data/lib/flapjack/cli/worker_manager.rb +1 -2
- data/lib/flapjack/configuration.rb +11 -0
- data/lib/flapjack/coordinator.rb +288 -0
- data/lib/flapjack/daemonizing.rb +186 -0
- data/lib/flapjack/data/contact.rb +45 -0
- data/lib/flapjack/data/entity.rb +89 -0
- data/lib/flapjack/data/entity_check.rb +396 -0
- data/lib/flapjack/data/event.rb +144 -0
- data/lib/flapjack/data/notification.rb +13 -0
- data/lib/flapjack/executive.rb +289 -0
- data/lib/flapjack/filters/acknowledgement.rb +39 -0
- data/lib/flapjack/filters/{any_parents_failed.rb → base.rb} +6 -4
- data/lib/flapjack/filters/delays.rb +53 -0
- data/lib/flapjack/filters/detect_mass_client_failures.rb +44 -0
- data/lib/flapjack/filters/ok.rb +25 -5
- data/lib/flapjack/filters/scheduled_maintenance.rb +17 -0
- data/lib/flapjack/filters/unscheduled_maintenance.rb +17 -0
- data/lib/flapjack/jabber.rb +294 -0
- data/lib/flapjack/notification/common.rb +23 -0
- data/lib/flapjack/notification/email.rb +107 -0
- data/lib/flapjack/notification/email/alert.html.haml +48 -0
- data/lib/flapjack/notification/email/alert.text.erb +14 -0
- data/lib/flapjack/notification/sms.rb +42 -0
- data/lib/flapjack/notification/sms/messagenet.rb +49 -0
- data/lib/flapjack/notifier_engine.rb +4 -4
- data/lib/flapjack/notifiers/mailer/mailer.rb +6 -7
- data/lib/flapjack/notifiers/xmpp/xmpp.rb +12 -12
- data/lib/flapjack/pagerduty.rb +230 -0
- data/lib/flapjack/patches.rb +108 -19
- data/lib/flapjack/persistence/data_mapper/models/check.rb +5 -3
- data/lib/flapjack/persistence/data_mapper/models/check_template.rb +2 -0
- data/lib/flapjack/persistence/data_mapper/models/event.rb +2 -0
- data/lib/flapjack/persistence/data_mapper/models/node.rb +3 -1
- data/lib/flapjack/persistence/data_mapper/models/related_check.rb +3 -1
- data/lib/flapjack/pikelet.rb +56 -0
- data/lib/flapjack/transports/beanstalkd.rb +1 -1
- data/lib/flapjack/transports/result.rb +6 -6
- data/lib/flapjack/utility.rb +46 -0
- data/lib/flapjack/version.rb +5 -0
- data/lib/flapjack/web.rb +198 -0
- data/lib/flapjack/web/views/acknowledge.haml +55 -0
- data/lib/flapjack/web/views/check.haml +162 -0
- data/lib/flapjack/web/views/index.haml +92 -0
- data/lib/flapjack/web/views/self_stats.haml +56 -0
- data/lib/flapjack/{applications/worker.rb → worker/application.rb} +0 -0
- data/lib/flapjack/worker/cli.rb +49 -0
- data/{spec → spec.old}/check_sandbox/echo +0 -0
- data/{spec → spec.old}/check_sandbox/sandboxed_check +0 -0
- data/{spec → spec.old}/configs/flapjack-notifier-couchdb.ini +0 -0
- data/{spec → spec.old}/configs/flapjack-notifier.ini +0 -0
- data/{spec → spec.old}/configs/recipients.ini +0 -0
- data/{spec → spec.old}/helpers.rb +0 -0
- data/{spec → spec.old}/inifile_spec.rb +0 -0
- data/{spec → spec.old}/mock-notifiers/mock/init.rb +0 -0
- data/{spec → spec.old}/mock-notifiers/mock/mock.rb +0 -0
- data/{spec → spec.old}/notifier-directories/spoons/testmailer/init.rb +0 -0
- data/{spec → spec.old}/notifier_application_spec.rb +0 -0
- data/{spec → spec.old}/notifier_filters_spec.rb +0 -0
- data/{spec → spec.old}/notifier_options_multiplexer_spec.rb +0 -0
- data/{spec → spec.old}/notifier_options_spec.rb +0 -0
- data/{spec → spec.old}/notifier_spec.rb +0 -0
- data/{spec → spec.old}/notifiers/mailer_spec.rb +0 -0
- data/{spec → spec.old}/notifiers/xmpp_spec.rb +0 -0
- data/{spec → spec.old}/persistence/datamapper_spec.rb +0 -0
- data/{spec → spec.old}/persistence/mock_persistence_backend.rb +0 -0
- data/{spec → spec.old}/simple.ini +0 -0
- data/{spec → spec.old}/spec.opts +0 -0
- data/{spec → spec.old}/test-filters/blocker.rb +0 -0
- data/{spec → spec.old}/test-filters/mock.rb +0 -0
- data/{spec → spec.old}/transports/beanstalkd_spec.rb +0 -0
- data/{spec → spec.old}/transports/mock_transport.rb +0 -0
- data/{spec → spec.old}/worker_application_spec.rb +0 -0
- data/{spec → spec.old}/worker_options_spec.rb +0 -0
- data/spec/lib/flapjack/api/entity_check_presenter_spec.rb +117 -0
- data/spec/lib/flapjack/api/entity_presenter_spec.rb +92 -0
- data/spec/lib/flapjack/api_spec.rb +170 -0
- data/spec/lib/flapjack/coordinator_spec.rb +16 -0
- data/spec/lib/flapjack/data/entity_check_spec.rb +398 -0
- data/spec/lib/flapjack/data/entity_spec.rb +71 -0
- data/spec/lib/flapjack/data/event_spec.rb +6 -0
- data/spec/lib/flapjack/executive_spec.rb +59 -0
- data/spec/lib/flapjack/filters/acknowledgement_spec.rb +6 -0
- data/spec/lib/flapjack/filters/delays_spec.rb +6 -0
- data/spec/lib/flapjack/filters/detect_mass_client_failures_spec.rb +6 -0
- data/spec/lib/flapjack/filters/ok_spec.rb +6 -0
- data/spec/lib/flapjack/filters/scheduled_maintenance_spec.rb +6 -0
- data/spec/lib/flapjack/filters/unscheduled_maintenance_spec.rb +6 -0
- data/spec/lib/flapjack/jabber_spec.rb +150 -0
- data/spec/lib/flapjack/notification/email_spec.rb +6 -0
- data/spec/lib/flapjack/notification/sms_spec.rb +6 -0
- data/spec/lib/flapjack/pikelet_spec.rb +28 -0
- data/spec/lib/flapjack/web_spec.rb +188 -0
- data/spec/spec_helper.rb +44 -0
- data/spec/support/profile_all_formatter.rb +44 -0
- data/spec/support/uncolored_doc_formatter.rb +9 -0
- data/tasks/events.rake +85 -0
- data/tmp/acknowledge.rb +14 -0
- data/tmp/create_config_yaml.rb +16 -0
- data/tmp/create_events_failure.rb +33 -0
- data/tmp/create_events_ok.rb +33 -0
- data/tmp/create_events_ok_fail_ack_ok.rb +54 -0
- data/tmp/create_events_ok_failure.rb +40 -0
- data/tmp/create_events_ok_failure_ack.rb +54 -0
- data/tmp/dummy_entities.json +1 -0
- data/tmp/generate_nagios_test_hosts.rb +16 -0
- data/tmp/parse_config_yaml.rb +7 -0
- data/tmp/redis_delete_all_keys.rb +11 -0
- data/tmp/test_entities.json +1 -0
- metadata +482 -221
- data/TODO.md +0 -36
- data/VERSION +0 -1
- data/bin/flapjack-benchmark +0 -50
- data/bin/flapjack-notifier +0 -21
- data/bin/flapjack-notifier-manager +0 -43
- data/bin/flapjack-stats +0 -27
- data/bin/flapjack-worker +0 -13
- data/bin/flapjack-worker-manager +0 -35
- data/dist/etc/init.d/flapjack-notifier +0 -47
- data/dist/etc/init.d/flapjack-workers +0 -44
- data/features/flapjack-notifier-manager.feature +0 -19
- data/features/flapjack-worker-manager.feature +0 -27
- data/features/flapjack-worker.feature +0 -27
- data/features/netsaint-config-converter.feature +0 -126
- data/features/persistence/couch.feature +0 -105
- data/features/persistence/sqlite3.feature +0 -105
- data/features/persistence/steps/couch_steps.rb +0 -25
- data/features/persistence/steps/generic_steps.rb +0 -102
- data/features/persistence/steps/sqlite3_steps.rb +0 -13
- data/features/steps/flapjack-notifier-manager_steps.rb +0 -24
- data/features/steps/flapjack-worker-manager_steps.rb +0 -48
- data/lib/flapjack/applications/notifier.rb +0 -222
- data/lib/flapjack/cli/notifier.rb +0 -108
- data/lib/flapjack/cli/notifier_manager.rb +0 -86
- data/lib/flapjack/cli/worker.rb +0 -51
data/.gitignore
CHANGED
data/.rbenv-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.9.3-p125
|
data/.rspec
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
--color
|
|
2
|
+
--format Fuubar
|
|
3
|
+
--format html
|
|
4
|
+
--out tmp/spec.html
|
|
5
|
+
--require ./spec/support/uncolored_doc_formatter.rb
|
|
6
|
+
--format UncoloredDocFormatter
|
|
7
|
+
--out tmp/spec_doc.txt
|
|
8
|
+
--require ./spec/support/profile_all_formatter.rb
|
|
9
|
+
--format ProfileAllFormatter
|
|
10
|
+
--out tmp/spec_profile.txt
|
data/Gemfile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
source :rubygems
|
|
2
|
+
|
|
3
|
+
gemspec :name => 'flapjack'
|
|
4
|
+
|
|
5
|
+
group :test do
|
|
6
|
+
gem 'rspec'
|
|
7
|
+
gem 'cucumber'
|
|
8
|
+
gem 'delorean'
|
|
9
|
+
gem 'rack-test'
|
|
10
|
+
gem 'resque_spec'
|
|
11
|
+
gem 'webmock'
|
|
12
|
+
gem 'guard'
|
|
13
|
+
gem 'guard-rspec'
|
|
14
|
+
gem 'guard-cucumber'
|
|
15
|
+
gem 'fuubar'
|
|
16
|
+
gem 'fuubar-cucumber'
|
|
17
|
+
gem 'simplecov', :require => false
|
|
18
|
+
end
|
data/Guardfile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
guard 'rspec', :cli => '--format Fuubar --format html --out tmp/spec.html --require ./spec/support/uncolored_doc_formatter.rb --format UncoloredDocFormatter --out tmp/spec_doc.txt --require ./spec/support/profile_all_formatter.rb --format ProfileAllFormatter --out tmp/spec_profile.txt', :version => 2 do
|
|
3
|
+
watch(%r{^spec/.+_spec\.rb$})
|
|
4
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
|
5
|
+
watch('spec/spec_helper.rb') { "spec" }
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# NB: seems to be buggy with the default --progress formatter, was
|
|
9
|
+
# causing failures to parse the features
|
|
10
|
+
guard 'cucumber', :cli => '--no-profile --color --format fuubar --strict' do
|
|
11
|
+
watch(%r{^features/.+\.feature$})
|
|
12
|
+
watch(%r{^features/support/.+$}) { 'features' }
|
|
13
|
+
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
|
|
14
|
+
end
|
data/README.md
CHANGED
|
@@ -1,232 +1,211 @@
|
|
|
1
1
|
Flapjack
|
|
2
2
|
========
|
|
3
3
|
|
|
4
|
-
Flapjack is highly scalable and distributed monitoring system.
|
|
4
|
+
Flapjack is a highly scalable and distributed monitoring notification system.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
from 1 server to 1000.
|
|
6
|
+
Flapjack provides a scalable method for dealing with events representing changes in system state (OK -> WARNING -> CRITICAL transitions) and alerting appropriate people as necessary.
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
=======
|
|
8
|
+
At its core, flapjack process events received from external check execution engines, such as Nagios. Nagios provides a 'perfdata' event output channel, which writes to a named pipe. `flapjack-nagios-receiver` then reads from this named pipe, converts each line to JSON and adds them to the events queue. `executive` picks up the events and processes them - deciding when and who to notifify about problems, recoveries, acknowledgements etc. Additional check engines can be supported by adding additional receiver processes similar to the nagios receiver.
|
|
11
9
|
|
|
12
|
-
**These install instructions are probably wrong. Follow them best you can, and
|
|
13
|
-
please report bugs as you find them!**
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
What things do
|
|
12
|
+
--------------
|
|
17
13
|
|
|
18
|
-
|
|
14
|
+
Executables:
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
* `flapjack` => starts multiple components ('pikelets') within the one ruby process as specified in the configuration file.
|
|
17
|
+
* `flapjack-nagios-receiver` => reads nagios check output on standard input and places them on the events queue in redis as JSON blobs. Currently unable to be run in-process with `flapjack`
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
There are more fun executables in the bin directory.
|
|
24
20
|
|
|
25
|
-
|
|
21
|
+
Pikelets:
|
|
26
22
|
|
|
27
|
-
|
|
23
|
+
* `executive` => processes events off a queue (a redis list) and decides what actions to take (alert, record state changes, etc)
|
|
24
|
+
* `email_notifier` => generates email notifications (resque, mail)
|
|
25
|
+
* `sms_notifier` => generates sms notifications (resque)
|
|
26
|
+
* `jabber_gateway` => connects to an XMPP (jabber) server, sends notifications (to rooms and individuals), handles acknowledgements from jabber users and other commands (blather)
|
|
27
|
+
* `web` => web UI (sinatra, thin)
|
|
28
|
+
* `api` => HTTP API server (sinatra, thin)
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
Pikelets are flapjack components which can be run within the same ruby process, or as separate processes.
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
The simplest configuration will have one `flapjack` process running executive, web, and some notification gateways, and one `flapjack-nagios-receiver` process receiving events from Nagios and placing them on the events queue for processing by executive.
|
|
32
33
|
|
|
33
|
-
sudo apt-get install build-essential libsqlite3-dev
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
Developing
|
|
36
|
+
----------
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
Clone the repository:
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
git clone https://auxesis@github.com/auxesis/flapjack.git
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
Install development dependencies:
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
gem install bundler
|
|
45
|
+
bundle install
|
|
44
46
|
|
|
47
|
+
Run the tests:
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
cucumber features/
|
|
50
|
+
rspec spec
|
|
48
51
|
|
|
49
|
-
|
|
52
|
+
Testing
|
|
53
|
+
-------
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
- libevent (from http://monkey.org/~provos/libevent/)
|
|
55
|
+
Feature tests live in `features/`.
|
|
53
56
|
|
|
57
|
+
To run feature tests:
|
|
54
58
|
|
|
55
|
-
|
|
56
|
-
------------
|
|
59
|
+
$ cucumber features
|
|
57
60
|
|
|
61
|
+
There's some rspec unit tests as well, run these like so:
|
|
58
62
|
|
|
59
|
-
|
|
63
|
+
$ rspec spec
|
|
60
64
|
|
|
61
|
-
|
|
65
|
+
NB, if the cucumber tests fail with a spurious lexing error on line 2 of events.feature, then try this:
|
|
62
66
|
|
|
63
|
-
|
|
67
|
+
$ cucumber -f fuubar features
|
|
64
68
|
|
|
65
|
-
sudo gem install flapjack
|
|
66
69
|
|
|
67
|
-
Then run the magic configuration script to set up init scripts:
|
|
68
70
|
|
|
69
|
-
|
|
71
|
+
Releasing
|
|
72
|
+
---------
|
|
70
73
|
|
|
71
|
-
|
|
74
|
+
Gem releases are handled with [Bundler](http://gembundler.com/rubygems.html).
|
|
72
75
|
|
|
76
|
+
To build the gem, run:
|
|
73
77
|
|
|
74
|
-
|
|
75
|
-
-------
|
|
78
|
+
gem build flapjack.gemspec
|
|
76
79
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
You'll want to set up `/etc/flapjack/recipients.conf` so notifications can be sent via
|
|
80
|
-
`flapjack-notifier`:
|
|
81
|
-
|
|
82
|
-
[John Doe]
|
|
83
|
-
email = johndoe@example.org
|
|
84
|
-
jid = john@example.org
|
|
85
|
-
phone = +61 400 111 222
|
|
86
|
-
pager = 61400111222
|
|
87
|
-
|
|
88
|
-
[Jane Doe]
|
|
89
|
-
email = janedoe@example.org
|
|
90
|
-
jid = jane@example.org
|
|
91
|
-
phone = +61 222 333 111
|
|
92
|
-
pager = 61222333111
|
|
93
|
-
|
|
94
|
-
You also need to set up `/etc/flapjack/notifier.conf`:
|
|
95
|
-
|
|
96
|
-
# top level
|
|
97
|
-
[notifier]
|
|
98
|
-
notifier-directories = /usr/lib/flapjack/notifiers/ /path/to/my/notifiers
|
|
99
|
-
notifiers = mailer, xmpp
|
|
100
|
-
|
|
101
|
-
# persistence layers
|
|
102
|
-
[persistence]
|
|
103
|
-
backend = data_mapper
|
|
104
|
-
uri = sqlite3:///tmp/flapjack.db
|
|
105
|
-
|
|
106
|
-
# message transports
|
|
107
|
-
[transport]
|
|
108
|
-
backend = beanstalkd
|
|
109
|
-
host = localhost
|
|
110
|
-
port = 11300
|
|
111
|
-
|
|
112
|
-
# notifiers
|
|
113
|
-
[mailer-notifier]
|
|
114
|
-
from_address = foo@bar.com
|
|
115
|
-
|
|
116
|
-
[xmpp-notifier]
|
|
117
|
-
jid = foo@bar.com
|
|
118
|
-
password = barfoo
|
|
119
|
-
|
|
120
|
-
# filters
|
|
121
|
-
[filters]
|
|
122
|
-
chain = ok, downtime, any_parents_failed
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
Start up a cluster of workers:
|
|
126
|
-
|
|
127
|
-
flapjack-worker-manager start
|
|
128
|
-
|
|
129
|
-
This will spin up 5 workers in the background. You can specify how many workers
|
|
130
|
-
to start:
|
|
131
|
-
|
|
132
|
-
flapjack-worker-manager start --workers=10
|
|
133
|
-
|
|
134
|
-
Each of the `flapjack-worker`s will output to syslog (check in /var/log/messages).
|
|
135
|
-
|
|
136
|
-
Start up the notifier:
|
|
137
|
-
|
|
138
|
-
flapjack-notifier-manager start --recipients /etc/flapjack/recipients.conf
|
|
139
|
-
|
|
140
|
-
Currently there are email and XMPP notifiers.
|
|
141
|
-
|
|
142
|
-
You'll want to get a copy of (http://github.com/auxesis/flapjack-admin/)[flapjack-admin]
|
|
143
|
-
to set up some checks, then run its populator to get them into Flapjack.
|
|
144
|
-
|
|
145
|
-
What things do
|
|
146
|
-
--------------
|
|
80
|
+
Configuring
|
|
81
|
+
===========
|
|
147
82
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
* `flapjack-stats` => gets stats from beanstalkd tubes (useful for benchmarks + performance analysis)
|
|
152
|
-
* `flapjack-benchmark` => benchmarks various persistence/transport backend combinations
|
|
83
|
+
```
|
|
84
|
+
cp etc/flapjack-config.yaml.example etc/flapjack-config.yaml
|
|
85
|
+
```
|
|
153
86
|
|
|
87
|
+
Edit the configuration to suit (redis connection, smtp server, jabber server, sms gateway, etc)
|
|
154
88
|
|
|
155
|
-
|
|
156
|
-
------------
|
|
89
|
+
The default FLAPJACK_ENV is "development" if there is no environment variable set.
|
|
157
90
|
|
|
158
|
-
|
|
91
|
+
Nagios config
|
|
92
|
+
-------------
|
|
159
93
|
|
|
160
|
-
|
|
94
|
+
You need a Nagios prior to version 3.3 as this breaks perfdata output for checks which don't generate performance data (stuff after a | in the check output). We are developing and running against Nagios version 3.2.3 with success.
|
|
161
95
|
|
|
162
|
-
|
|
163
|
-
/etc/init.d/flapjack-notifier start
|
|
96
|
+
nagios.cfg config file changes:
|
|
164
97
|
|
|
165
|
-
|
|
98
|
+
```
|
|
99
|
+
# modified lines:
|
|
100
|
+
enable_notifications=0
|
|
101
|
+
host_perfdata_file=/var/cache/nagios3/event_stream.fifo
|
|
102
|
+
service_perfdata_file=/var/cache/nagios3/event_stream.fifo
|
|
103
|
+
host_perfdata_file_template=[HOSTPERFDATA]\t$TIMET$\t$HOSTNAME$\tHOST\t$HOSTSTATE$\t$HOSTEXECUTIONTIME$\t$HOSTLATENCY$\t$HOSTOUTPUT$\t$HOSTPERFDATA$
|
|
104
|
+
service_perfdata_file_template=[SERVICEPERFDATA]\t$TIMET$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$
|
|
105
|
+
host_perfdata_file_mode=p
|
|
106
|
+
service_perfdata_file_mode=p
|
|
107
|
+
```
|
|
166
108
|
|
|
167
|
-
|
|
168
|
-
sudo update-rc.d flapjack-notifier defaults
|
|
109
|
+
What we're doing here is telling Nagios to generate a line of output for every host and service check into a named pipe. The template lines must be as above so that `flapjack-nagios-receiver` knows what to expect.
|
|
169
110
|
|
|
170
|
-
|
|
111
|
+
All hosts and services (or templates that they use) will need to have process_perf_data enabled on them. (This is a real misnomer, it doesn't mean the performance data will be processed, just that it will be fed to the perfdata output channel, a named pipe in our case.)
|
|
171
112
|
|
|
113
|
+
Create the named pipe if it doesn't already exist:
|
|
172
114
|
|
|
115
|
+
mkfifo -m 0666 /var/cache/nagios3/event_stream.fifo
|
|
173
116
|
|
|
174
|
-
Testing
|
|
175
|
-
-------
|
|
176
117
|
|
|
177
|
-
|
|
118
|
+
Running
|
|
119
|
+
=======
|
|
120
|
+
|
|
121
|
+
bin/flapjack [options]
|
|
122
|
+
|
|
123
|
+
$ flapjack --help
|
|
124
|
+
Usage: flapjack [options]
|
|
125
|
+
-c, --config [PATH] PATH to the config file to use
|
|
126
|
+
-d, --[no-]daemonize Daemonize?
|
|
127
|
+
|
|
128
|
+
The command line option for daemonize overrides whatever is set in the config file.
|
|
129
|
+
|
|
130
|
+
flapjack-nagios-receiver
|
|
131
|
+
------------------------
|
|
132
|
+
|
|
133
|
+
There is a control script that uses [Daemons](http://daemons.rubyforge.org/) to start, stop, restart, show status etc of the flapjack-nagios-receiver process. Options after -- are passed through to flapjack-nagios-receiver. Run it like so:
|
|
134
|
+
|
|
135
|
+
flapjack-nagios-receiver-control start -- --config /etc/flapjack/flapjack-config.yaml /path/to/nagios/perfdata.fifo
|
|
136
|
+
flapjack-nagios-receiver-control status
|
|
137
|
+
flapjack-nagios-receiver-control restart -- --config /etc/flapjack/flapjack-config.yaml /path/to/nagios/perfdata.fifo
|
|
138
|
+
flapjack-nagios-receiver-control stop
|
|
139
|
+
|
|
140
|
+
* Bypassing daemons control script: *
|
|
141
|
+
|
|
142
|
+
This process needs to be started with the nagios perfdata named pipe attached to its STDIN like so:
|
|
143
|
+
|
|
144
|
+
flapjack-nagios-receiver < /var/cache/nagios3/event_stream.fifo
|
|
145
|
+
|
|
146
|
+
Or the path to the fifo can just be given as an argument, thanks to the magical powers of ARGV:
|
|
147
|
+
|
|
148
|
+
flapjack-nagios-receiver /var/cache/nagios3/event_stream.fifo
|
|
178
149
|
|
|
179
|
-
|
|
150
|
+
Now as nagios feeds check execution results into the perfdata named pipe, flapjack-nagios-receiver will convert them to JSON encoded ruby objects and insert them into the *events* queue.
|
|
180
151
|
|
|
181
|
-
|
|
182
|
-
|
|
152
|
+
Importing contacts and entities
|
|
153
|
+
-------------------------------
|
|
183
154
|
|
|
155
|
+
The `flapjack-populator` script provides a mechanism for importing contacts and entities from JSON formatted import files.
|
|
156
|
+
|
|
157
|
+
bin/flapjack-populator import-contacts --from tmp/dummy_contacts.json --config /etc/flapjack/flapjack-config.yml
|
|
158
|
+
bin/flapjack-populator import-entities --from tmp/dummy_entities.json --config /etc/flapjack/flapjack-config.yml
|
|
159
|
+
|
|
160
|
+
TODO: convert the format documentation into markdown and include in the project
|
|
161
|
+
|
|
162
|
+
In lieu of actual documentation of the formats there are example files, and example ruby code which generated them, in the tmp directory.
|
|
163
|
+
|
|
164
|
+
executive
|
|
165
|
+
---------
|
|
166
|
+
|
|
167
|
+
Flapjack executive processes events from the 'events' list in redis. It does a blocking read on redis so new events are picked off the events list and processed as soon as they created.
|
|
168
|
+
|
|
169
|
+
When executive decides somebody ought to be notified (for a problem, recovery, or acknowledgement or what-have-you) it looks up contact information and then creates a notification job on one of the notification queues (eg sms_notifications) in rescue, or via the jabber_notifications redis list which is processed by the jabber_gateway.
|
|
170
|
+
|
|
171
|
+
Resque Workers
|
|
172
|
+
--------------
|
|
173
|
+
|
|
174
|
+
We're using [Resque](https://github.com/defunkt/resque) to queue email and sms notifications generated by flapjack-executive. The queues are named as follows:
|
|
175
|
+
- email_notifications
|
|
176
|
+
- sms_notifications
|
|
177
|
+
|
|
178
|
+
There'll be more of these as we add more notification mediums.
|
|
179
|
+
|
|
180
|
+
Note that using the flapjack-config.yaml file you can have flapjack start the resque workers in-process. Or you can run them standalone with the `rake resque:work` command as follows.
|
|
181
|
+
|
|
182
|
+
One resque worker that processes both queues (but prioritises SMS above email) can be started as follows:
|
|
183
|
+
|
|
184
|
+
QUEUE=sms_notifications,email_notifications VERBOSE=1 be rake resque:work
|
|
185
|
+
|
|
186
|
+
resque sets the command name so grep'ing ps output for `rake` or `ruby` will NOT find resque processes. Search instead for `resque`. (and remember the 'q').
|
|
187
|
+
|
|
188
|
+
To background it you can add `BACKGROUND=yes`. Excellent documentation is available in [Resque's README](https://github.com/defunkt/resque/blob/master/README.markdown)
|
|
189
|
+
|
|
190
|
+
Redis Database Instances
|
|
191
|
+
------------------------
|
|
192
|
+
|
|
193
|
+
We use the following redis database numbers by convention:
|
|
194
|
+
|
|
195
|
+
* 0 => production
|
|
196
|
+
* 13 => development
|
|
197
|
+
* 14 => testing
|
|
184
198
|
|
|
185
199
|
Architecture
|
|
186
200
|
------------
|
|
187
201
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
| persistence |
|
|
197
|
-
---------------
|
|
198
|
-
|
|
|
199
|
-
-------------------------------
|
|
200
|
-
| |
|
|
201
|
-
| |
|
|
202
|
-
| |
|
|
203
|
-
------------- ------------
|
|
204
|
-
| populator |--- -----| notifier |
|
|
205
|
-
------------- | | ------------
|
|
206
|
-
| |
|
|
207
|
-
--------------
|
|
208
|
-
| beanstalkd |
|
|
209
|
-
--------------
|
|
210
|
-
|
|
|
211
|
-
-----------------------------------
|
|
212
|
-
| | |
|
|
213
|
-
---------- ---------- ----------
|
|
214
|
-
| worker | | worker | | worker |
|
|
215
|
-
---------- ---------- ----------
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
- populator determines checks that need to occur, and puts checks onto `jobs` tube
|
|
219
|
-
- populator fetches jobs from a database
|
|
220
|
-
- populator can be swapped out to get checks from a dsl or flat files
|
|
221
|
-
- workers pop a check off the beanstalk, perform check, put result onto `results` tube,
|
|
222
|
-
re-add check to `jobs` tube with a delay.
|
|
223
|
-
- notifier pops results off `results` tube, notifies as necessary
|
|
202
|
+
TODO: insert architecture diagram and notes here
|
|
203
|
+
|
|
204
|
+
Dependencies
|
|
205
|
+
------------
|
|
206
|
+
|
|
207
|
+
Apart from a bundle of gems (see flapjack.gemspec for runtime gems, and Gemfile for additional gems required for testing):
|
|
208
|
+
- Ruby >= 1.9
|
|
209
|
+
- Redis >= 2.4.15
|
|
224
210
|
|
|
225
|
-
Releasing
|
|
226
|
-
---------
|
|
227
211
|
|
|
228
|
-
1. bump version number + release date in gemspec
|
|
229
|
-
1. create a new tag with `git tag -a -m "releasing 0.9" 0.9`
|
|
230
|
-
1. push to github with `git push --tags`
|
|
231
|
-
1. create a new gem with `rake build`
|
|
232
|
-
1. push gem to Gemcutter with `rake push`
|