flapjack 0.7.29 → 0.7.30
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +8 -0
- data/bin/flapjack-nagios-receiver +20 -15
- data/bin/flapjack-populator +30 -13
- data/bin/flapper +1 -1
- data/bin/receive-events +13 -10
- data/bin/simulate-failed-check +13 -3
- data/dist/etc/init.d/flapjack +5 -42
- data/dist/etc/init.d/flapjack-nagios-receiver +3 -17
- data/dist/etc/init.d/flapper +3 -12
- data/etc/flapjack_config.yaml.example +81 -52
- data/features/cli.feature +30 -13
- data/features/cli_flapjack-nagios-receiver.feature +66 -0
- data/features/cli_flapjack-populator.feature +80 -0
- data/features/cli_flapper.feature +45 -0
- data/features/cli_receive-events.feature +27 -0
- data/features/cli_simulate-failed-check.feature +31 -0
- data/features/events.feature +3 -6
- data/features/packaging-lintian.feature +2 -2
- data/features/rollup.feature +2 -4
- data/features/steps/cli_steps.rb +25 -7
- data/features/steps/packaging-lintian_steps.rb +12 -6
- data/features/support/daemons.rb +11 -1
- data/features/support/env.rb +16 -4
- data/lib/flapjack/coordinator.rb +1 -1
- data/lib/flapjack/filters/delays.rb +1 -1
- data/lib/flapjack/gateways/email/alert.html.erb +1 -1
- data/lib/flapjack/gateways/email/alert.text.erb +1 -1
- data/lib/flapjack/gateways/email/rollup.html.erb +1 -1
- data/lib/flapjack/gateways/email/rollup.text.erb +1 -1
- data/lib/flapjack/gateways/web/views/check.html.erb +1 -1
- data/lib/flapjack/gateways/web/views/contact.html.erb +37 -32
- data/lib/flapjack/gateways/web.rb +7 -7
- data/lib/flapjack/logger.rb +25 -45
- data/lib/flapjack/version.rb +1 -1
- data/spec/lib/flapjack/coordinator_spec.rb +9 -7
- data/spec/lib/flapjack/logger_spec.rb +19 -13
- data/tasks/benchmarks.rake +1 -1
- data/tasks/support/flapjack_config_benchmark.yaml +1 -29
- metadata +97 -47
- checksums.yaml +0 -7
- data/bin/flapjack-netsaint-parser +0 -432
- data/dist/puppet/flapjack/files/.stub +0 -0
- data/dist/puppet/flapjack/manifests/common.pp +0 -61
- data/dist/puppet/flapjack/manifests/notifier.pp +0 -13
- data/dist/puppet/flapjack/manifests/worker.pp +0 -13
- data/dist/puppet/flapjack/templates/.stub +0 -0
- data/dist/puppet/ruby/manifests/dev.pp +0 -5
- data/dist/puppet/ruby/manifests/rubygems.pp +0 -14
- data/dist/puppet/sqlite3/manifests/dev.pp +0 -5
data/features/cli.feature
CHANGED
@@ -5,7 +5,7 @@ Feature: command line utility
|
|
5
5
|
From the command line
|
6
6
|
|
7
7
|
Background:
|
8
|
-
Given a file named "flapjack_cfg.
|
8
|
+
Given a file named "flapjack_cfg.yaml" with:
|
9
9
|
"""
|
10
10
|
test:
|
11
11
|
redis:
|
@@ -15,7 +15,7 @@ test:
|
|
15
15
|
logger:
|
16
16
|
level: warn
|
17
17
|
"""
|
18
|
-
And a file named "flapjack_cfg_d.
|
18
|
+
And a file named "flapjack_cfg_d.yaml" with:
|
19
19
|
"""
|
20
20
|
test:
|
21
21
|
pid_file: tmp/cucumber_cli/flapjack_d.pid
|
@@ -28,34 +28,49 @@ test:
|
|
28
28
|
level: warn
|
29
29
|
"""
|
30
30
|
|
31
|
+
Scenario: Running with --help shows usage information
|
32
|
+
When I run `bin/flapjack --help`
|
33
|
+
Then the exit status should be 0
|
34
|
+
And the output should contain "Usage: flapjack"
|
35
|
+
And the output should contain " reload "
|
36
|
+
And the output should contain "-c, --config"
|
37
|
+
|
38
|
+
Scenario: Getting status when stopped
|
39
|
+
When I run `bin/flapjack status --config tmp/cucumber_cli/flapjack_cfg_d.yaml`
|
40
|
+
Then the exit status should not be 0
|
41
|
+
And the output should contain "Flapjack is not running"
|
42
|
+
|
31
43
|
Scenario: Starting flapjack
|
32
|
-
When I start flapjack with `flapjack start --config tmp/cucumber_cli/flapjack_cfg.
|
44
|
+
When I start flapjack with `flapjack start --config tmp/cucumber_cli/flapjack_cfg.yaml`
|
33
45
|
Then flapjack should start within 15 seconds
|
34
46
|
|
35
47
|
Scenario: Stopping flapjack via SIGINT
|
36
|
-
When I start flapjack with `flapjack start --config tmp/cucumber_cli/flapjack_cfg.
|
48
|
+
When I start flapjack with `flapjack start --config tmp/cucumber_cli/flapjack_cfg.yaml`
|
37
49
|
Then flapjack should start within 15 seconds
|
38
50
|
When I send a SIGINT to the flapjack process
|
39
51
|
Then flapjack should stop within 15 seconds
|
40
52
|
|
41
|
-
Scenario: Starting and stopping flapjack, daemonized
|
42
|
-
When I start flapjack (daemonised) with `flapjack start -d --config tmp/cucumber_cli/flapjack_cfg_d.
|
53
|
+
Scenario: Starting, status and stopping flapjack, daemonized
|
54
|
+
When I start flapjack (daemonised) with `flapjack start -d --config tmp/cucumber_cli/flapjack_cfg_d.yaml`
|
43
55
|
Then flapjack should start within 15 seconds
|
44
|
-
When I
|
56
|
+
When I run `bin/flapjack status --config tmp/cucumber_cli/flapjack_cfg_d.yaml`
|
57
|
+
Then the exit status should be 0
|
58
|
+
And the output should contain "Flapjack is running"
|
59
|
+
When I stop flapjack with `flapjack stop --config tmp/cucumber_cli/flapjack_cfg_d.yaml`
|
45
60
|
Then flapjack should stop within 15 seconds
|
46
61
|
|
47
62
|
Scenario: Starting, restarting and stopping flapjack, daemonized
|
48
|
-
When I start flapjack (daemonised) with `flapjack start -d --config tmp/cucumber_cli/flapjack_cfg_d.
|
63
|
+
When I start flapjack (daemonised) with `flapjack start -d --config tmp/cucumber_cli/flapjack_cfg_d.yaml`
|
49
64
|
Then flapjack should start within 15 seconds
|
50
|
-
When I restart flapjack with `flapjack restart -d --config tmp/cucumber_cli/flapjack_cfg_d.
|
65
|
+
When I restart flapjack with `flapjack restart -d --config tmp/cucumber_cli/flapjack_cfg_d.yaml`
|
51
66
|
Then flapjack should restart within 15 seconds
|
52
|
-
When I stop flapjack with `flapjack stop --config tmp/cucumber_cli/flapjack_cfg_d.
|
67
|
+
When I stop flapjack with `flapjack stop --config tmp/cucumber_cli/flapjack_cfg_d.yaml`
|
53
68
|
Then flapjack should stop within 15 seconds
|
54
69
|
|
55
70
|
Scenario: Reloading flapjack configuration
|
56
|
-
When I start flapjack with `flapjack start --config tmp/cucumber_cli/flapjack_cfg.
|
57
|
-
When I run `mv tmp/cucumber_cli/flapjack_cfg.
|
58
|
-
Given a file named "flapjack_cfg.
|
71
|
+
When I start flapjack with `flapjack start --config tmp/cucumber_cli/flapjack_cfg.yaml`
|
72
|
+
When I run `mv tmp/cucumber_cli/flapjack_cfg.yaml tmp/cucumber_cli/flapjack_cfg.yaml.bak`
|
73
|
+
Given a file named "flapjack_cfg.yaml" with:
|
59
74
|
"""
|
60
75
|
test:
|
61
76
|
redis:
|
@@ -67,3 +82,5 @@ test:
|
|
67
82
|
# TODO how to test for config file change?
|
68
83
|
When I send a SIGINT to the flapjack process
|
69
84
|
Then flapjack should stop within 15 seconds
|
85
|
+
|
86
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
@process
|
2
|
+
Feature: flapjack-nagios-receiver command line
|
3
|
+
As a systems administrator
|
4
|
+
I should be able to manage flapjack-nagios-receiver
|
5
|
+
From the command line
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given a fifo named "tmp/cucumber_cli/nagios_perfdata.fifo" exists
|
9
|
+
And a file named "flapjack-nagios-receiver.yaml" with:
|
10
|
+
"""
|
11
|
+
test:
|
12
|
+
redis:
|
13
|
+
db: 14
|
14
|
+
nagios-receiver:
|
15
|
+
fifo: "tmp/cucumber_cli/nagios_perfdata.fifo"
|
16
|
+
"""
|
17
|
+
And a file named "flapjack-nagios-receiver_d.yaml" with:
|
18
|
+
"""
|
19
|
+
test:
|
20
|
+
redis:
|
21
|
+
db: 14
|
22
|
+
nagios-receiver:
|
23
|
+
fifo: "tmp/cucumber_cli/nagios_perfdata.fifo"
|
24
|
+
pid_file: "tmp/cucumber_cli/flapjack-nagios-receiver_d.pid"
|
25
|
+
log_file: "tmp/cucumber_cli/flapjack-nagios-receiver_d.log"
|
26
|
+
"""
|
27
|
+
|
28
|
+
Scenario: Running with --help shows usage information
|
29
|
+
When I run `bin/flapjack-nagios-receiver --help`
|
30
|
+
Then the exit status should be 0
|
31
|
+
And the output should contain "Usage: flapjack-nagios-receiver"
|
32
|
+
And the output should contain "-f, --fifo FIFO"
|
33
|
+
|
34
|
+
Scenario: Starting flapjack-nagios-receiver
|
35
|
+
When I start flapjack-nagios-receiver with `flapjack-nagios-receiver start --no-daemonize --config tmp/cucumber_cli/flapjack-nagios-receiver.yaml`
|
36
|
+
Then flapjack-nagios-receiver should start within 15 seconds
|
37
|
+
|
38
|
+
Scenario: Stopping flapjack-nagios-receiver via SIGINT
|
39
|
+
When I start flapjack-nagios-receiver with `flapjack-nagios-receiver start --no-daemonize --config tmp/cucumber_cli/flapjack-nagios-receiver.yaml`
|
40
|
+
Then flapjack-nagios-receiver should start within 15 seconds
|
41
|
+
When I send a SIGINT to the flapjack-nagios-receiver process
|
42
|
+
Then flapjack-nagios-receiver should stop within 15 seconds
|
43
|
+
|
44
|
+
Scenario: Starting, status, and stopping flapjack-nagios-receiver, daemonized
|
45
|
+
When I start flapjack-nagios-receiver (daemonised) with `flapjack-nagios-receiver start -d --config tmp/cucumber_cli/flapjack-nagios-receiver_d.yaml`
|
46
|
+
Then flapjack-nagios-receiver should start within 15 seconds
|
47
|
+
When I run `bin/flapjack-nagios-receiver status --config tmp/cucumber_cli/flapjack-nagios-receiver_d.yaml`
|
48
|
+
Then the exit status should be 0
|
49
|
+
And the output should contain "flapjack-nagios-receiver is running"
|
50
|
+
When I stop flapjack-nagios-receiver with `flapjack-nagios-receiver stop --config tmp/cucumber_cli/flapjack-nagios-receiver_d.yaml`
|
51
|
+
Then flapjack-nagios-receiver should stop within 15 seconds
|
52
|
+
|
53
|
+
Scenario: Starting, restarting and stopping flapjack-nagios-receiver, daemonized
|
54
|
+
When I start flapjack-nagios-receiver (daemonised) with `flapjack-nagios-receiver start -d --config tmp/cucumber_cli/flapjack-nagios-receiver_d.yaml`
|
55
|
+
Then flapjack-nagios-receiver should start within 15 seconds
|
56
|
+
When I restart flapjack-nagios-receiver (daemonised) with `flapjack-nagios-receiver restart -d --config tmp/cucumber_cli/flapjack-nagios-receiver_d.yaml`
|
57
|
+
Then flapjack-nagios-receiver should restart within 15 seconds
|
58
|
+
When I stop flapjack-nagios-receiver with `flapjack-nagios-receiver stop --config tmp/cucumber_cli/flapjack-nagios-receiver_d.yaml`
|
59
|
+
Then flapjack-nagios-receiver should stop within 15 seconds
|
60
|
+
|
61
|
+
Scenario: Getting status when stopped
|
62
|
+
When I run `bin/flapjack-nagios-receiver status --config tmp/cucumber_cli/flapjack-nagios-receiver_d.yaml`
|
63
|
+
Then the exit status should not be 0
|
64
|
+
And the output should contain "flapjack-nagios-receiver is not running"
|
65
|
+
|
66
|
+
|
@@ -0,0 +1,80 @@
|
|
1
|
+
@process
|
2
|
+
Feature: flapjack-populator command line
|
3
|
+
As a systems administrator
|
4
|
+
I should be able to use flapjack-populator
|
5
|
+
From the command line
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given a file named "flapjack-populator.yaml" with:
|
9
|
+
"""
|
10
|
+
test:
|
11
|
+
redis:
|
12
|
+
db: 14
|
13
|
+
"""
|
14
|
+
And a file named "flapjack-populator-contacts.json" with:
|
15
|
+
"""
|
16
|
+
[
|
17
|
+
{
|
18
|
+
"id": "21",
|
19
|
+
"first_name": "Ada",
|
20
|
+
"last_name": "Lovelace",
|
21
|
+
"email": "ada@example.com",
|
22
|
+
"media": {
|
23
|
+
"sms": {
|
24
|
+
"address": "+61412345678",
|
25
|
+
"interval": "3600",
|
26
|
+
"rollup_threshold": "5"
|
27
|
+
},
|
28
|
+
"email": {
|
29
|
+
"address": "ada@example.com",
|
30
|
+
"interval": "7200",
|
31
|
+
"rollup_threshold": null
|
32
|
+
}
|
33
|
+
},
|
34
|
+
"tags": [
|
35
|
+
"legend",
|
36
|
+
"first computer programmer"
|
37
|
+
]
|
38
|
+
}
|
39
|
+
]
|
40
|
+
"""
|
41
|
+
And a file named "flapjack-populator-entities.json" with:
|
42
|
+
"""
|
43
|
+
[
|
44
|
+
{
|
45
|
+
"id": "10001",
|
46
|
+
"name": "clientx-app-01",
|
47
|
+
"contacts": [
|
48
|
+
"362",
|
49
|
+
"363",
|
50
|
+
"364"
|
51
|
+
],
|
52
|
+
"tags": [
|
53
|
+
"source:titanium",
|
54
|
+
"foo"
|
55
|
+
]
|
56
|
+
}
|
57
|
+
]
|
58
|
+
"""
|
59
|
+
|
60
|
+
Scenario: Running with --help shows usage information
|
61
|
+
When I run `bin/flapjack-populator --help`
|
62
|
+
Then the exit status should be 0
|
63
|
+
And the output should contain "Usage: flapjack-populator"
|
64
|
+
And the output should contain "import-contacts"
|
65
|
+
And the output should contain "import-entities"
|
66
|
+
And the output should contain "--config"
|
67
|
+
|
68
|
+
Scenario: Running flapjack-populator with no arguments exits uncleanly and shows usage
|
69
|
+
When I run `bin/flapjack-populator`
|
70
|
+
Then the exit status should not be 0
|
71
|
+
And the output should contain "Usage: flapjack-populator"
|
72
|
+
|
73
|
+
Scenario: Importing contacts
|
74
|
+
When I run `bin/flapjack-populator import-contacts --from tmp/cucumber_cli/flapjack-populator-contacts.json --config tmp/cucumber_cli/flapjack-populator.yaml`
|
75
|
+
Then the exit status should be 0
|
76
|
+
|
77
|
+
Scenario: Importing entities
|
78
|
+
When I run `bin/flapjack-populator import-entities --from tmp/cucumber_cli/flapjack-populator-entities.json --config tmp/cucumber_cli/flapjack-populator.yaml`
|
79
|
+
Then the exit status should be 0
|
80
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
@process
|
2
|
+
Feature: Flapper command line
|
3
|
+
As a systems administrator
|
4
|
+
I should be able to manage flapper
|
5
|
+
From the command line
|
6
|
+
|
7
|
+
Scenario: Running with --help shows usage information
|
8
|
+
When I run `bin/flapper --help`
|
9
|
+
Then the exit status should be 0
|
10
|
+
And the output should contain "Usage: flapper"
|
11
|
+
And the output should contain "-b, --bind-ip"
|
12
|
+
|
13
|
+
Scenario: Starting flapper
|
14
|
+
When I start flapper with `flapper start --no-daemonize`
|
15
|
+
Then flapper should start within 15 seconds
|
16
|
+
|
17
|
+
Scenario: Stopping flapper via SIGINT
|
18
|
+
When I start flapper with `flapper start --no-daemonize`
|
19
|
+
Then flapper should start within 15 seconds
|
20
|
+
When I send a SIGINT to the flapper process
|
21
|
+
Then flapper should stop within 15 seconds
|
22
|
+
|
23
|
+
Scenario: Starting, status, and stopping flapper, daemonized
|
24
|
+
When I start flapper (daemonised) with `flapper start -d -p tmp/cucumber_cli/flapper_d.pid -l tmp/cucumber_cli/flapper_d.log`
|
25
|
+
Then flapper should start within 15 seconds
|
26
|
+
When I run `bin/flapper status -p tmp/cucumber_cli/flapper_d.pid`
|
27
|
+
Then the exit status should be 0
|
28
|
+
And the output should contain "flapper is running"
|
29
|
+
When I stop flapper with `flapper stop -p tmp/cucumber_cli/flapper_d.pid`
|
30
|
+
Then flapper should stop within 15 seconds
|
31
|
+
|
32
|
+
Scenario: Starting, restarting and stopping flapper, daemonized
|
33
|
+
When I start flapper (daemonised) with `flapper start -d -p tmp/cucumber_cli/flapper_d.pid -l tmp/cucumber_cli/flapper_d.log`
|
34
|
+
Then flapper should start within 15 seconds
|
35
|
+
When I restart flapper (daemonised) with `flapper restart -d -p tmp/cucumber_cli/flapper_d.pid -l tmp/cucumber_cli/flapper_d.log`
|
36
|
+
Then flapper should restart within 15 seconds
|
37
|
+
When I stop flapper with `flapper stop -p tmp/cucumber_cli/flapper_d.pid`
|
38
|
+
Then flapper should stop within 15 seconds
|
39
|
+
|
40
|
+
Scenario: Getting status when stopped
|
41
|
+
When I run `bin/flapper status -p tmp/cucumber_cli/flapper_d.pid`
|
42
|
+
Then the exit status should not be 0
|
43
|
+
And the output should contain "flapper is not running"
|
44
|
+
|
45
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
@process
|
2
|
+
Feature: receive-events command line
|
3
|
+
As a systems administrator
|
4
|
+
I should be able to use receive-events
|
5
|
+
From the command line
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given a file named "receive-events.yaml" with:
|
9
|
+
"""
|
10
|
+
test:
|
11
|
+
redis:
|
12
|
+
db: 14
|
13
|
+
"""
|
14
|
+
|
15
|
+
Scenario: Running with --help shows usage information
|
16
|
+
When I run `bin/receive-events --help`
|
17
|
+
Then the exit status should be 0
|
18
|
+
And the output should contain "Usage: receive-events"
|
19
|
+
And the output should contain "-s, --source URL"
|
20
|
+
|
21
|
+
Scenario: Running receive-events with no arguments exits uncleanly and shows usage
|
22
|
+
When I run `bin/receive-events`
|
23
|
+
Then the exit status should not be 0
|
24
|
+
And the output should contain "Usage: receive-events"
|
25
|
+
|
26
|
+
#TODO: put some archived events into a separate redis db and then run receive-events to suck them up
|
27
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
@process
|
2
|
+
Feature: simulate-failed-check command line
|
3
|
+
As a systems administrator
|
4
|
+
I should be able to use simulate-failed-check
|
5
|
+
From the command line
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given a file named "simulate-failed-check.yaml" with:
|
9
|
+
"""
|
10
|
+
test:
|
11
|
+
redis:
|
12
|
+
db: 14
|
13
|
+
"""
|
14
|
+
|
15
|
+
Scenario: Running with --help shows usage information
|
16
|
+
When I run `bin/simulate-failed-check --help`
|
17
|
+
Then the exit status should be 0
|
18
|
+
And the output should contain "Usage: simulate-failed-check"
|
19
|
+
And the output should contain "-k, --check CHECK"
|
20
|
+
|
21
|
+
Scenario: Running simulate-failed-check with no arguments exits uncleanly and shows usage
|
22
|
+
When I run `bin/simulate-failed-check`
|
23
|
+
Then the exit status should not be 0
|
24
|
+
And the output should contain "Usage: simulate-failed-check"
|
25
|
+
|
26
|
+
Scenario: Simulate a failed check
|
27
|
+
When I run `bin/simulate-failed-check fail -c tmp/cucumber_cli/simulate-failed-check.yaml -t 0 -i 0.1 -e 'test' -k 'PING'`
|
28
|
+
Then the exit status should be 0
|
29
|
+
And the output should contain "sending failure event"
|
30
|
+
And the output should contain "stopping"
|
31
|
+
|
data/features/events.feature
CHANGED
@@ -60,13 +60,13 @@ Feature: events
|
|
60
60
|
Then a notification should be generated
|
61
61
|
|
62
62
|
@time
|
63
|
-
Scenario: Check critical and alerted to critical for
|
63
|
+
Scenario: Check critical and alerted to critical for 40 seconds
|
64
64
|
Given the check is in an ok state
|
65
65
|
When a critical event is received
|
66
66
|
And 1 minute passes
|
67
67
|
And a critical event is received
|
68
68
|
Then a notification should be generated
|
69
|
-
When
|
69
|
+
When 40 seconds passes
|
70
70
|
And a critical event is received
|
71
71
|
Then a notification should not be generated
|
72
72
|
|
@@ -234,10 +234,7 @@ Feature: events
|
|
234
234
|
When 10 seconds passes
|
235
235
|
And an unknown event is received
|
236
236
|
Then a notification should not be generated
|
237
|
-
When
|
238
|
-
And an unknown event is received
|
239
|
-
Then a notification should not be generated
|
240
|
-
When 5 minutes passes
|
237
|
+
When 1 minutes passes
|
241
238
|
And an unknown event is received
|
242
239
|
Then a notification should be generated
|
243
240
|
When 10 seconds passes
|
@@ -4,12 +4,12 @@ Feature: Packagability
|
|
4
4
|
|
5
5
|
Scenario: No rubygems references
|
6
6
|
When I run `grep require lib/* bin/* -R |grep rubygems`
|
7
|
-
Then the exit
|
7
|
+
Then the exit status should not be 0
|
8
8
|
And I should see 0 lines of output
|
9
9
|
|
10
10
|
Scenario: A shebang that works everywhere
|
11
11
|
When I run `find lib/ -type 'f' -name '*.rb'`
|
12
|
-
Then the exit
|
12
|
+
Then the exit status should be 0
|
13
13
|
And every file in the output should start with "#!/usr/bin/env ruby"
|
14
14
|
|
15
15
|
|
data/features/rollup.feature
CHANGED
@@ -172,10 +172,8 @@ Feature: Rollup on a per contact, per media basis
|
|
172
172
|
And 1 sms alerts should be queued for +61400000001
|
173
173
|
When 4 hours passes
|
174
174
|
And a critical event is received for check 'ping' on entity 'foo'
|
175
|
-
|
176
|
-
And
|
177
|
-
Then 1 sms alert of type problem and rollup problem should be queued for +61400000001
|
178
|
-
And 2 sms alerts should be queued for +61400000001
|
175
|
+
Then 2 sms alerts should be queued for +61400000001
|
176
|
+
And 1 sms alert of type problem and rollup problem should be queued for +61400000001
|
179
177
|
|
180
178
|
@time
|
181
179
|
Scenario: Contact ceases to be a contact on an entity that they were being alerted for
|
data/features/steps/cli_steps.rb
CHANGED
@@ -7,31 +7,48 @@ Given /^a file named "([^"]*)" with:$/ do |file_name, file_content|
|
|
7
7
|
write_file(file_name, file_content)
|
8
8
|
end
|
9
9
|
|
10
|
-
|
10
|
+
Given /^a fifo named "([^"]*)" exists$/ do |fifo_name|
|
11
|
+
create_fifo(fifo_name)
|
12
|
+
end
|
13
|
+
|
14
|
+
When /^I ((?:re)?start|stop) (\S+)( \(daemonised\))? with `(.+)`$/ do |start_stop_restart, exe, daemonise, cmd|
|
15
|
+
@daemons_output ||= []
|
16
|
+
@daemons_exit_status ||= []
|
17
|
+
|
11
18
|
@root = Pathname.new(File.dirname(__FILE__)).parent.parent.expand_path
|
12
19
|
command = "#{@root.join('bin')}/#{cmd}"
|
13
20
|
|
21
|
+
# enable debugging output from spawn_process etc
|
22
|
+
#@debug = true
|
23
|
+
|
14
24
|
case start_stop_restart
|
15
25
|
when 'start'
|
16
26
|
@process_h = spawn_process(command,
|
17
|
-
:daemon_pidfile => (daemonise.nil? || daemonise.empty?) ? nil :
|
27
|
+
:daemon_pidfile => (daemonise.nil? || daemonise.empty?) ? nil : "tmp/cucumber_cli/#{exe}_d.pid")
|
18
28
|
when 'stop', 'restart'
|
19
|
-
`#{command}`
|
29
|
+
@daemons_output << `#{command}`
|
30
|
+
@daemons_exit_status << $?
|
20
31
|
end
|
32
|
+
puts "output: #{@daemons_output.join(', ')}, exit statuses: #{@daemons_exit_status}" if @debug
|
21
33
|
end
|
22
34
|
|
23
|
-
When /^I send a SIG(\w+) to the
|
35
|
+
When /^I send a SIG(\w+) to the (?:\S+) process$/ do |signal|
|
24
36
|
process = @process_h[:process]
|
25
37
|
pid = process ? process.pid : @process_h[:pid]
|
26
38
|
Process.kill(signal, pid)
|
27
39
|
end
|
28
40
|
|
29
|
-
Then /^
|
41
|
+
Then /^(\S+) should ((?:re)?start|stop) within (\d+) seconds$/ do |exe, start_stop_restart, seconds|
|
30
42
|
process = @process_h[:process]
|
31
43
|
pid = process ? process.pid : @process_h[:pid]
|
32
44
|
running = nil
|
33
45
|
attempts = 0
|
34
|
-
max_attempts = seconds.to_i *
|
46
|
+
max_attempts = seconds.to_i * 10
|
47
|
+
|
48
|
+
if @debug
|
49
|
+
puts "should #{start_stop_restart} within #{seconds} seconds..."
|
50
|
+
puts "pid: #{pid}, max_attempts: #{max_attempts}"
|
51
|
+
end
|
35
52
|
|
36
53
|
case start_stop_restart
|
37
54
|
when 'start'
|
@@ -39,6 +56,7 @@ Then /^flapjack should ((?:re)?start|stop) within (\d+) seconds$/ do |start_stop
|
|
39
56
|
Process.kill(0, pid)
|
40
57
|
running = true
|
41
58
|
rescue Errno::EINVAL, Errno::ESRCH, RangeError, Errno::EPERM => e
|
59
|
+
puts "rescued error from kill: #{e.class} - #{e.message}" if @debug
|
42
60
|
attempts += 1; sleep 0.1; retry if attempts < max_attempts
|
43
61
|
running = false
|
44
62
|
end
|
@@ -70,7 +88,7 @@ Then /^flapjack should ((?:re)?start|stop) within (\d+) seconds$/ do |start_stop
|
|
70
88
|
when 'restart'
|
71
89
|
read_pid = nil
|
72
90
|
while attempts < max_attempts
|
73
|
-
time_and_pid = time_and_pid_from_file(
|
91
|
+
time_and_pid = time_and_pid_from_file("tmp/cucumber_cli/#{exe}_d.pid")
|
74
92
|
read_pid = time_and_pid.last
|
75
93
|
break if read_pid != pid
|
76
94
|
attempts += 1; sleep 0.1
|
@@ -13,15 +13,21 @@ Then /^every file in the output should start with "([^\"]*)"$/ do |string|
|
|
13
13
|
end
|
14
14
|
|
15
15
|
When /^I run `([^"]*)`$/ do |cmd|
|
16
|
-
|
17
|
-
#command = "#{bin_path}/#{cmd}"
|
18
|
-
|
19
|
-
#@output = `#{command}`
|
16
|
+
@cmd = cmd
|
20
17
|
@output = `#{cmd} 2>&1`
|
21
18
|
@exit_status = $?.exitstatus
|
19
|
+
puts "output: #{@output}" if @debug
|
20
|
+
puts "exit_status: #{@exit_status}" if @debug
|
22
21
|
end
|
23
22
|
|
24
|
-
Then /^the exit
|
25
|
-
|
23
|
+
Then /^the exit status should( not)? be (\d+)$/ do |negativity, number|
|
24
|
+
if negativity
|
25
|
+
@exit_status.should_not == number.to_i
|
26
|
+
else
|
27
|
+
@exit_status.should == number.to_i
|
28
|
+
end
|
26
29
|
end
|
27
30
|
|
31
|
+
Then /^the output should contain "([^"]*)"$/ do |matcher|
|
32
|
+
@output.should include(matcher)
|
33
|
+
end
|
data/features/support/daemons.rb
CHANGED
@@ -23,6 +23,12 @@ def write_file(file_name, file_content)
|
|
23
23
|
_create_file(file_name, file_content, false)
|
24
24
|
end
|
25
25
|
|
26
|
+
def create_fifo(fifo_name)
|
27
|
+
unless File.pipe?(fifo_name)
|
28
|
+
system("mkfifo #{fifo_name}")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
26
32
|
def _create_file(file_name, file_content, check_presence)
|
27
33
|
in_current_dir do
|
28
34
|
raise "expected #{file_name} to be present" if check_presence && !File.file?(file_name)
|
@@ -74,6 +80,9 @@ def time_and_pid_from_file(pid_file, cutoff_time = nil)
|
|
74
80
|
end
|
75
81
|
|
76
82
|
def spawn_process(command, opts={})
|
83
|
+
@daemons_output ||= []
|
84
|
+
@daemons_exit_status ||= []
|
85
|
+
|
77
86
|
puts yellow("Running: #{command}") if @debug
|
78
87
|
|
79
88
|
process_h = nil
|
@@ -84,7 +93,8 @@ def spawn_process(command, opts={})
|
|
84
93
|
time = Time.now
|
85
94
|
attempts = 0
|
86
95
|
|
87
|
-
`#{command}`
|
96
|
+
@daemons_output << `#{command}`
|
97
|
+
@daemons_exit_status << $?
|
88
98
|
|
89
99
|
while attempts < 50
|
90
100
|
time_and_pid = time_and_pid_from_file(file, time)
|
data/features/support/env.rb
CHANGED
@@ -19,6 +19,8 @@ if ENV['COVERAGE']
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
@debug = false
|
23
|
+
|
22
24
|
ENV["FLAPJACK_ENV"] = 'test'
|
23
25
|
FLAPJACK_ENV = 'test'
|
24
26
|
|
@@ -181,11 +183,21 @@ After('@time') do
|
|
181
183
|
end
|
182
184
|
|
183
185
|
After('@process') do
|
184
|
-
['tmp/cucumber_cli/flapjack_cfg.
|
185
|
-
'tmp/cucumber_cli/flapjack_cfg.
|
186
|
-
'tmp/cucumber_cli/flapjack_cfg_d.
|
186
|
+
['tmp/cucumber_cli/flapjack_cfg.yaml',
|
187
|
+
'tmp/cucumber_cli/flapjack_cfg.yaml.bak',
|
188
|
+
'tmp/cucumber_cli/flapjack_cfg_d.yaml',
|
187
189
|
'tmp/cucumber_cli/flapjack_d.log',
|
188
|
-
'tmp/cucumber_cli/flapjack_d.pid'
|
190
|
+
'tmp/cucumber_cli/flapjack_d.pid',
|
191
|
+
'tmp/cucumber_cli/nagios_perfdata.fifo',
|
192
|
+
'tmp/cucumber_cli/flapjack-nagios-receiver_d.pid',
|
193
|
+
'tmp/cucumber_cli/flapjack-nagios-receiver_d.log',
|
194
|
+
'tmp/cucumber_cli/flapjack-nagios-receiver_d.yaml',
|
195
|
+
'tmp/cucumber_cli/flapjack-nagios-receiver.yaml',
|
196
|
+
'tmp/cucumber_cli/flapper_d.pid',
|
197
|
+
'tmp/cucumber_cli/flapper_d.log',
|
198
|
+
'tmp/cucumber_cli/flapjack-populator.yaml',
|
199
|
+
'tmp/cucumber_cli/flapjack-populator-contacts.json',
|
200
|
+
].each do |file|
|
189
201
|
next unless File.exists?(file)
|
190
202
|
File.unlink(file)
|
191
203
|
end
|
data/lib/flapjack/coordinator.rb
CHANGED
@@ -54,7 +54,7 @@
|
|
54
54
|
<% if @alert.state_duration && @alert.state_duration > 40 %>
|
55
55
|
<tr>
|
56
56
|
<td><strong>Duration</strong></td>
|
57
|
-
<td><%= ChronicDuration.output(@alert.state_duration) %></td>
|
57
|
+
<td><%= ChronicDuration.output(@alert.state_duration, :keep_zero => true) || '0 secs' %></td>
|
58
58
|
</tr>
|
59
59
|
<% end %>
|
60
60
|
|
@@ -13,7 +13,7 @@ Details: <%= @alert.details %>
|
|
13
13
|
Time: <%= Time.at(@alert.time.to_i).to_s %>
|
14
14
|
<% end -%>
|
15
15
|
<% if @alert.state_duration && @alert.state_duration > 40 -%>
|
16
|
-
Duration: <%= ChronicDuration.output(@alert.state_duration) %>
|
16
|
+
Duration: <%= ChronicDuration.output(@alert.state_duration, :keep_zero => true) || '0 secs' %>
|
17
17
|
<% end -%>
|
18
18
|
<% if @alert.last_state -%>
|
19
19
|
Previous State: <%= @alert.last_state_title_case %>
|
@@ -26,7 +26,7 @@
|
|
26
26
|
<% @alert.rollup_alerts.sort_by {|entity_check, details| details['duration'] }.each do |rollup_alert| -%>
|
27
27
|
<% r_entity, r_check = rollup_alert[0].split(':', 2) -%>
|
28
28
|
<% state = rollup_alert[1]['state'] -%>
|
29
|
-
<% duration = ChronicDuration.output(rollup_alert[1]['duration']) -%>
|
29
|
+
<% duration = (ChronicDuration.output(rollup_alert[1]['duration'], :keep_zero => true) || '0 secs') -%>
|
30
30
|
<tr>
|
31
31
|
<td><%= r_check %></td>
|
32
32
|
<td><%= r_entity %></td>
|
@@ -5,7 +5,7 @@ You have <%= @alert.rollup_alerts.length %> alerting check<%= @alert.rollup_aler
|
|
5
5
|
<% @alert.rollup_alerts.sort_by {|entity_check, details| details['duration'] }.each do |rollup_alert| -%>
|
6
6
|
<% r_entity, r_check = rollup_alert[0].split(':', 2) -%>
|
7
7
|
<% state = rollup_alert[1]['state'] -%>
|
8
|
-
<% duration = ChronicDuration.output(rollup_alert[1]['duration'] ) -%>
|
8
|
+
<% duration = (ChronicDuration.output(rollup_alert[1]['duration'], :keep_zero => true) || '0 secs') -%>
|
9
9
|
* <%= r_check %> on <%= r_entity %> is <%= ['ok'].include?(state) ? state.upcase : state.titleize %> (<%= duration %>)
|
10
10
|
<% end -%>
|
11
11
|
|
@@ -109,7 +109,7 @@
|
|
109
109
|
<tr>
|
110
110
|
<td><%= h Time.at(start_time).to_s %></td>
|
111
111
|
<td><%= h Time.at(end_time).to_s %></td>
|
112
|
-
<td><%= h
|
112
|
+
<td><%= h(ChronicDuration.output(duration, :keep_zero => true) || '0 secs') %></td>
|
113
113
|
<td><%= h summary %></td>
|
114
114
|
<td>
|
115
115
|
<% if end_time > current_time.to_i %>
|