alerty 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +3 -3
- data/alerty.gemspec +1 -1
- data/lib/alerty/command.rb +3 -3
- data/lib/alerty/config.rb +1 -1
- data/lib/alerty/version.rb +1 -1
- data/spec/command_spec.rb +12 -6
- data/spec/config_spec.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ae60fa6de1c6a296b2aaefc0429cf84d716a9f8
|
4
|
+
data.tar.gz: b499e6edb6b41470af44ffad38c07f21ea5daff4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f88a28b14ce75957b38708936969d8e77fa1f2a8b2789ddbb838fb23ca1af0a9efb3e0cba9b06b92a107f783908727389822c8988f036591f26dee7e03935ddf
|
7
|
+
data.tar.gz: 3bd9c34db9e0140f0e096e284dea90dc23fdee11d3a43772bd0f57c363c2a4e47034d0ffeec197bd75437f97932f8bfee3bc6e0aa9584503ff01359e76140eba
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -77,14 +77,14 @@ Following plugins are available:
|
|
77
77
|
|
78
78
|
### Naming Convention
|
79
79
|
|
80
|
-
You must follow
|
80
|
+
You must follow following naming conventions:
|
81
81
|
|
82
82
|
* gem name: alerty-plugin-xxx (xxx_yyy)
|
83
83
|
* file name: lib/alerty/plugin/xxx.rb (xxx_yyy.rb)
|
84
84
|
* class name: Alerty::Plugin:Xxx (XxxYyy)
|
85
85
|
|
86
86
|
### Interface
|
87
|
-
|
87
|
+
u
|
88
88
|
What you have to implement is `#initialize` and `#alert` methods. Here is an example of `file` plugin:
|
89
89
|
|
90
90
|
```ruby
|
@@ -123,7 +123,7 @@ plugins:
|
|
123
123
|
|
124
124
|
### record
|
125
125
|
|
126
|
-
`record` is a hash whose keys are
|
126
|
+
`record` is a hash whose keys are symbols of followings:
|
127
127
|
|
128
128
|
* hostname: hostname
|
129
129
|
* command: the executed command
|
data/alerty.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
|
18
18
|
gem.add_runtime_dependency 'hashie'
|
19
19
|
gem.add_runtime_dependency 'oneline_log_formatter'
|
20
|
-
gem.add_runtime_dependency 'frontkick', '>= 0.
|
20
|
+
gem.add_runtime_dependency 'frontkick', '>= 0.5.5'
|
21
21
|
gem.add_runtime_dependency 'dotenv'
|
22
22
|
|
23
23
|
gem.add_development_dependency 'rspec'
|
data/lib/alerty/command.rb
CHANGED
@@ -6,7 +6,7 @@ class Alerty
|
|
6
6
|
class Command
|
7
7
|
def initialize(command:)
|
8
8
|
@command = command
|
9
|
-
@opts = { timeout: Config.timeout, exclusive: Config.lock_path }
|
9
|
+
@opts = { timeout: Config.timeout, exclusive: Config.lock_path, popen2e: true }
|
10
10
|
@hostname = Socket.gethostname
|
11
11
|
end
|
12
12
|
|
@@ -15,7 +15,7 @@ class Alerty
|
|
15
15
|
with_retry do |retries|
|
16
16
|
started_at = Time.now
|
17
17
|
begin
|
18
|
-
result = with_clean_env { Frontkick.exec(
|
18
|
+
result = with_clean_env { Frontkick.exec(@command, @opts) }
|
19
19
|
rescue Frontkick::Timeout => e
|
20
20
|
record = {
|
21
21
|
hostname: @hostname,
|
@@ -41,7 +41,7 @@ class Alerty
|
|
41
41
|
hostname: @hostname,
|
42
42
|
command: @command,
|
43
43
|
exitstatus: result.exitstatus,
|
44
|
-
output: result.
|
44
|
+
output: result.output,
|
45
45
|
started_at: started_at.to_f,
|
46
46
|
duration: result.duration,
|
47
47
|
retries: retries,
|
data/lib/alerty/config.rb
CHANGED
data/lib/alerty/version.rb
CHANGED
data/spec/command_spec.rb
CHANGED
@@ -9,15 +9,17 @@ describe Alerty::Command do
|
|
9
9
|
log_level: 'fatal',
|
10
10
|
timeout: 20,
|
11
11
|
lock_path: '/tmp/lock',
|
12
|
+
config_path: File.join(ROOT, 'spec/cli_spec.yml'),
|
12
13
|
)
|
13
14
|
end
|
14
15
|
|
15
16
|
let(:command) { Alerty::Command.new(command: 'ls') }
|
16
17
|
|
17
18
|
it do
|
18
|
-
expect(Frontkick).to receive(:exec).with("ls
|
19
|
+
expect(Frontkick).to receive(:exec).with("ls", {
|
19
20
|
timeout: 20,
|
20
21
|
exclusive: '/tmp/lock',
|
22
|
+
popen2e: true,
|
21
23
|
}).and_return(Frontkick::Result.new(exit_code: 0))
|
22
24
|
expect { command.run! }.not_to raise_error
|
23
25
|
end
|
@@ -41,9 +43,10 @@ describe Alerty::Command do
|
|
41
43
|
let(:command) { Alerty::Command.new(command: 'echo foo') }
|
42
44
|
|
43
45
|
it do
|
44
|
-
expect(Frontkick).to receive(:exec).with("echo foo
|
46
|
+
expect(Frontkick).to receive(:exec).with("echo foo", {
|
45
47
|
timeout: nil,
|
46
48
|
exclusive: nil,
|
49
|
+
popen2e: true,
|
47
50
|
}).and_return(Frontkick::Result.new(stdout: 'foo', exit_code: 1))
|
48
51
|
stdout = capture_stdout { expect { command.run! }.to raise_error(SystemExit) }
|
49
52
|
expect(JSON.parse(stdout)["output"]).to eql("foo")
|
@@ -68,10 +71,11 @@ describe Alerty::Command do
|
|
68
71
|
let(:command) { Alerty::Command.new(command: 'sleep 1') }
|
69
72
|
|
70
73
|
it do
|
71
|
-
expect(Frontkick).to receive(:exec).with("sleep 1
|
74
|
+
expect(Frontkick).to receive(:exec).with("sleep 1", {
|
72
75
|
timeout: 0.1,
|
73
76
|
exclusive: '/tmp/lock',
|
74
|
-
|
77
|
+
popen2e: true,
|
78
|
+
}).and_raise(Frontkick::Timeout.new(111, 'sleep 1', true))
|
75
79
|
stdout = capture_stdout { expect { command.run! }.to raise_error(SystemExit) }
|
76
80
|
expect(JSON.parse(stdout)["output"]).to include("timeout")
|
77
81
|
end
|
@@ -95,9 +99,10 @@ describe Alerty::Command do
|
|
95
99
|
let(:command) { Alerty::Command.new(command: 'sleep 1') }
|
96
100
|
|
97
101
|
it do
|
98
|
-
expect(Frontkick).to receive(:exec).with("sleep 1
|
102
|
+
expect(Frontkick).to receive(:exec).with("sleep 1", {
|
99
103
|
timeout: 20,
|
100
104
|
exclusive: '/tmp/lock',
|
105
|
+
popen2e: true,
|
101
106
|
}).and_raise(Frontkick::Locked)
|
102
107
|
stdout = capture_stdout { expect { command.run! }.to raise_error(SystemExit) }
|
103
108
|
expect(JSON.parse(stdout)["output"]).to include("lock")
|
@@ -121,9 +126,10 @@ describe Alerty::Command do
|
|
121
126
|
let(:command) { Alerty::Command.new(command: 'echo foo') }
|
122
127
|
|
123
128
|
it do
|
124
|
-
expect(Frontkick).to receive(:exec).twice.with("echo foo
|
129
|
+
expect(Frontkick).to receive(:exec).twice.with("echo foo", {
|
125
130
|
timeout: nil,
|
126
131
|
exclusive: nil,
|
132
|
+
popen2e: true,
|
127
133
|
}).and_return(Frontkick::Result.new(stdout: 'foo', exit_code: 1))
|
128
134
|
stdout = capture_stdout { expect { command.run! }.to raise_error(SystemExit) }
|
129
135
|
expect(JSON.parse(stdout)["retries"]).to eql(1)
|
data/spec/config_spec.rb
CHANGED
@@ -76,8 +76,8 @@ describe Alerty::Config do
|
|
76
76
|
end
|
77
77
|
|
78
78
|
it do
|
79
|
-
expect(Alerty::Config.plugins[0]).to
|
80
|
-
expect(Alerty::Config.plugins[1]).to
|
79
|
+
expect(Alerty::Config.plugins[0]['type']).to eql('stdout')
|
80
|
+
expect(Alerty::Config.plugins[1]['type']).to eql('file')
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alerty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.5.5
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.5.5
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: dotenv
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
191
|
version: '0'
|
192
192
|
requirements: []
|
193
193
|
rubyforge_project:
|
194
|
-
rubygems_version: 2.5.
|
194
|
+
rubygems_version: 2.5.1
|
195
195
|
signing_key:
|
196
196
|
specification_version: 4
|
197
197
|
summary: Send an alert if a given command failed
|