chef-handler-riemann 0.1.3 → 0.1.4
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/README.md +13 -8
- data/lib/chef/handler/riemann.rb +9 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc3804398913092c87c0c48205ce742f2e46f09b
|
4
|
+
data.tar.gz: ca10b6bb28095a395871eaca3dfd6ce1bd49a8b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e01c327d8232ddee3816cd73946b05540f015aff9ff29d43fc43d1f36c5e2cd101a7dffd5177b1c34971e44a8bf66c3dff988121def6abb58ef9b13f69fb6ed3
|
7
|
+
data.tar.gz: cf80b8a484711e6218be5896a96a5497bc3ae547c73b25a36915545b8277944b0cd72c5504a46866a9544136e419f83748f426a8ac976ecb7fa60a48af7d2ac0
|
data/README.md
CHANGED
@@ -1,20 +1,25 @@
|
|
1
1
|
# chef-handler-riemann
|
2
|
+
|
2
3
|
Chef Handler that reports to Riemann.
|
3
4
|
|
4
5
|
It reports when the Chef run starts and finishes, and outputs associated events depending on outcome.
|
5
6
|
|
6
7
|
# Usage
|
7
8
|
|
8
|
-
|
9
|
+
This is available as a [gem](https://rubygems.org/gems/chef-handler-riemann)
|
9
10
|
|
10
|
-
|
11
|
+
Because this handler has support for start events, you can't use the `chef_handler` cookbook. Instead, it needs to be added to `client.rb`. The community [chef-client](https://github.com/opscode-cookbooks/chef-client) cookbook can help with this, as it provides easy methods for making `client.rb` load the gem and add the handler. Example usage:
|
11
12
|
|
12
13
|
```
|
13
|
-
|
14
|
-
|
15
|
-
riemann = DataSift::RiemannHandler.new host: '192.168.122.1', port: 5555, timeout: 5, ttl: 120
|
14
|
+
# Riemann handler
|
15
|
+
node.default['chef_client']['load_gems']['chef-handler-riemann'] = {}
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
[ 'start', 'report', 'exception' ].each do |type|
|
18
|
+
node.default['chef_client']['config']["#{type}_handlers"] = [
|
19
|
+
{
|
20
|
+
:class => "Chef::Handler::Riemann",
|
21
|
+
:arguments => [ { :host => "localhost" } ]
|
22
|
+
}
|
23
|
+
]
|
24
|
+
end
|
20
25
|
```
|
data/lib/chef/handler/riemann.rb
CHANGED
@@ -4,12 +4,13 @@ require 'riemann/client'
|
|
4
4
|
class Chef
|
5
5
|
class Handler
|
6
6
|
class Riemann < ::Chef::Handler
|
7
|
-
attr_writer :host, :port, :
|
7
|
+
attr_writer :host, :port, :ttl_running, :ttl_finished, :timeout
|
8
8
|
|
9
9
|
def initialize(options={})
|
10
10
|
@host = options[:host] || 'localhost'
|
11
11
|
@port = options[:port] || 5555
|
12
|
-
@
|
12
|
+
@ttl_running = options[:ttl] || 600
|
13
|
+
@ttl_finished = options[:ttl] || 3600 # seems reasonable given chef runs every 30 mins by default
|
13
14
|
@timeout = options[:timeout] || 5
|
14
15
|
end
|
15
16
|
|
@@ -23,7 +24,8 @@ class Chef
|
|
23
24
|
riemann << {
|
24
25
|
:service => 'process:chef-client:state',
|
25
26
|
:state => 'running',
|
26
|
-
:description => "Chef run has started at #{start_time}"
|
27
|
+
:description => "Chef run has started at #{start_time}",
|
28
|
+
:ttl => @ttl_running
|
27
29
|
}
|
28
30
|
else
|
29
31
|
# chef run has completed
|
@@ -35,19 +37,19 @@ class Chef
|
|
35
37
|
state: 'ok',
|
36
38
|
description: "Chef succeeded at #{end_time}",
|
37
39
|
metric: elapsed_time,
|
38
|
-
ttl: @
|
40
|
+
ttl: @ttl_finished
|
39
41
|
}
|
40
42
|
|
41
43
|
riemann << {
|
42
44
|
service: "process:chef-client:updated_resources",
|
43
45
|
metric: run_status.updated_resources.length,
|
44
|
-
ttl: @
|
46
|
+
ttl: @ttl_finished
|
45
47
|
}
|
46
48
|
|
47
49
|
riemann << {
|
48
50
|
service: "process:chef-client:all_resources",
|
49
51
|
metric: run_status.all_resources.length,
|
50
|
-
ttl: @
|
52
|
+
ttl: @ttl_finished
|
51
53
|
}
|
52
54
|
else
|
53
55
|
riemann << {
|
@@ -55,7 +57,7 @@ class Chef
|
|
55
57
|
state: 'critical',
|
56
58
|
description: "Chef failed at #{end_time}: " + run_status.formatted_exception,
|
57
59
|
metric: elapsed_time,
|
58
|
-
ttl: @
|
60
|
+
ttl: @ttl_finished
|
59
61
|
}
|
60
62
|
end
|
61
63
|
end
|