chef-handler-riemann 0.1.3
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 +7 -0
- data/README.md +20 -0
- data/lib/chef-handler-riemann.rb +1 -0
- data/lib/chef/handler/riemann.rb +68 -0
- metadata +59 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7a66d3b1ce9b0176e8a14b881c13ada35abf952a
|
4
|
+
data.tar.gz: 8fddfd25866add5d7da3e3266c93bab034014829
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3f0115a248733f7723b07451b71e0103f052f9d11edd3a49de8b57492720fd268e15b962dafb660257aaf4a5fab7837ffb7e344b7bc8e1f43bb1e2c798916d8d
|
7
|
+
data.tar.gz: cf3293717e608225f18683771a0f4a35a7cf113c6543c9a1b475ff3dc06b8d32649ddadec2eb921fbe2b5ff65cd04fa9a97cdf387eb6c6c99842b3c2345353c1
|
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# chef-handler-riemann
|
2
|
+
Chef Handler that reports to Riemann.
|
3
|
+
|
4
|
+
It reports when the Chef run starts and finishes, and outputs associated events depending on outcome.
|
5
|
+
|
6
|
+
# Usage
|
7
|
+
|
8
|
+
TODO: Need to integrate into `chef_handler` cookbook for installation. It will need to install `riemann-client` via `chef_gem`
|
9
|
+
|
10
|
+
Editing client.rb works though:
|
11
|
+
|
12
|
+
```
|
13
|
+
require '/var/chef/handlers/riemann.rb'
|
14
|
+
|
15
|
+
riemann = DataSift::RiemannHandler.new host: '192.168.122.1', port: 5555, timeout: 5, ttl: 120
|
16
|
+
|
17
|
+
start_handlers << riemann
|
18
|
+
report_handlers << riemann
|
19
|
+
exception_handlers << rieman
|
20
|
+
```
|
@@ -0,0 +1 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/chef/handler/riemann"
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'chef/handler'
|
2
|
+
require 'riemann/client'
|
3
|
+
|
4
|
+
class Chef
|
5
|
+
class Handler
|
6
|
+
class Riemann < ::Chef::Handler
|
7
|
+
attr_writer :host, :port, :ttl, :timeout
|
8
|
+
|
9
|
+
def initialize(options={})
|
10
|
+
@host = options[:host] || 'localhost'
|
11
|
+
@port = options[:port] || 5555
|
12
|
+
@ttl = options[:ttl] || 3600 # seems reasonable given chef runs every 30 mins by default
|
13
|
+
@timeout = options[:timeout] || 5
|
14
|
+
end
|
15
|
+
|
16
|
+
def report
|
17
|
+
begin
|
18
|
+
# create TCP riemann client
|
19
|
+
riemann = ::Riemann::Client.new(host: @host, port: @port, timeout: @timeout).tcp
|
20
|
+
|
21
|
+
unless end_time
|
22
|
+
# chef run has started
|
23
|
+
riemann << {
|
24
|
+
:service => 'process:chef-client:state',
|
25
|
+
:state => 'running',
|
26
|
+
:description => "Chef run has started at #{start_time}"
|
27
|
+
}
|
28
|
+
else
|
29
|
+
# chef run has completed
|
30
|
+
|
31
|
+
# send summary, covers overall state and elapsed time
|
32
|
+
if run_status.success?
|
33
|
+
riemann << {
|
34
|
+
service: 'process:chef-client:state',
|
35
|
+
state: 'ok',
|
36
|
+
description: "Chef succeeded at #{end_time}",
|
37
|
+
metric: elapsed_time,
|
38
|
+
ttl: @ttl
|
39
|
+
}
|
40
|
+
|
41
|
+
riemann << {
|
42
|
+
service: "process:chef-client:updated_resources",
|
43
|
+
metric: run_status.updated_resources.length,
|
44
|
+
ttl: @ttl
|
45
|
+
}
|
46
|
+
|
47
|
+
riemann << {
|
48
|
+
service: "process:chef-client:all_resources",
|
49
|
+
metric: run_status.all_resources.length,
|
50
|
+
ttl: @ttl
|
51
|
+
}
|
52
|
+
else
|
53
|
+
riemann << {
|
54
|
+
service: 'process:chef-client:state',
|
55
|
+
state: 'critical',
|
56
|
+
description: "Chef failed at #{end_time}: " + run_status.formatted_exception,
|
57
|
+
metric: elapsed_time,
|
58
|
+
ttl: @ttl
|
59
|
+
}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
rescue Exception => e
|
63
|
+
Chef::Log.error "Failed to send report to Riemann: #{e.message}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chef-handler-riemann
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Forrow
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: riemann-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Provides insight into Chef status from within Riemann
|
28
|
+
email: alex.forrow@datasift.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- README.md
|
34
|
+
- lib/chef-handler-riemann.rb
|
35
|
+
- lib/chef/handler/riemann.rb
|
36
|
+
homepage: http://github.com/alexforrow/chef-handler-riemann
|
37
|
+
licenses: []
|
38
|
+
metadata: {}
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 2.4.5
|
56
|
+
signing_key:
|
57
|
+
specification_version: 4
|
58
|
+
summary: Chef start, exception & reporting handler for Riemann.
|
59
|
+
test_files: []
|