chef-handler-splunk 1.1.0 → 2.0.0
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/CHANGELOG.md +6 -0
- data/{LICENSE → LICENSE.txt} +0 -0
- data/README.md +17 -9
- data/lib/chef/handler/splunk.rb +13 -9
- metadata +8 -7
data/CHANGELOG.md
ADDED
data/{LICENSE → LICENSE.txt}
RENAMED
File without changes
|
data/README.md
CHANGED
@@ -6,18 +6,24 @@ A Chef Exception & Reporting Handler for [Splunk](http://www.splunk.com).
|
|
6
6
|
Usage
|
7
7
|
=====
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
Via Cookbook (preferred)
|
10
|
+
------------------------
|
11
|
+
See the [splunk_handler](https://github.com/ampledata/splunk_handler)
|
11
12
|
Cookbook.
|
12
|
-
|
13
|
-
|
13
|
+
|
14
|
+
Via Recipe (old, non-preferred)
|
15
|
+
-------------------------------
|
16
|
+
1. Add the [chef_handler](http://community.opscode.com/cookbooks/chef_handler)
|
17
|
+
Cookbook to a Node's Run List.
|
18
|
+
2. Given a Splunk username as USER, password as PASS, and
|
19
|
+
host name as HOST, create a Recipe similar to the one below:
|
14
20
|
|
15
21
|
```ruby
|
16
22
|
include_recipe 'chef_handler'
|
17
23
|
|
18
24
|
gem_package('chef-handler-splunk'){action :nothing}.run_action(:install)
|
19
25
|
|
20
|
-
chef_handler 'Chef::Handler::
|
26
|
+
chef_handler 'Chef::Handler::SplunkHandler' do
|
21
27
|
action :enable
|
22
28
|
arguments ['username', 'password', 'host']
|
23
29
|
source File.join(Gem.all_load_paths.grep(/chef-handler-splunk/).first,
|
@@ -25,12 +31,14 @@ chef_handler 'Chef::Handler::Splunk' do
|
|
25
31
|
end
|
26
32
|
```
|
27
33
|
|
28
|
-
|
34
|
+
Source
|
35
|
+
======
|
36
|
+
* [chef-handler-splunk gem](https://github.com/ampledata/chef-handler-splunk)
|
37
|
+
* [handler_splunk Cookbook](https://github.com/ampledata/handler_splunk)
|
29
38
|
|
30
39
|
Author
|
31
40
|
======
|
32
|
-
Greg Albrecht <gba@splunk.com>
|
33
|
-
|
41
|
+
Greg Albrecht <mailto:gba@splunk.com>
|
34
42
|
|
35
43
|
Copyright
|
36
44
|
=========
|
@@ -38,4 +46,4 @@ Copyright 2012 Splunk Inc.
|
|
38
46
|
|
39
47
|
License
|
40
48
|
=======
|
41
|
-
Apache License 2.0.
|
49
|
+
Apache License 2.0. See LICENSE.txt
|
data/lib/chef/handler/splunk.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# Chef Exception & Reporting Handler for Splunk.
|
3
3
|
#
|
4
|
-
# https://github.com/ampledata/chef-handler-splunk
|
5
|
-
#
|
4
|
+
# Source:: https://github.com/ampledata/chef-handler-splunk
|
6
5
|
# Author:: Greg Albrecht <mailto:gba@splunk.com>
|
7
6
|
# Copyright:: Copyright 2012 Splunk, Inc.
|
8
7
|
# License:: Apache License 2.0.
|
@@ -17,8 +16,8 @@ require 'rest-client'
|
|
17
16
|
|
18
17
|
class Chef
|
19
18
|
class Handler
|
20
|
-
class
|
21
|
-
VERSION = '
|
19
|
+
class SplunkHandler < Chef::Handler
|
20
|
+
VERSION = '2.0.0'
|
22
21
|
API_ENDPOINT = 'services/receivers/simple'
|
23
22
|
|
24
23
|
# * *Args*:
|
@@ -33,7 +32,8 @@ class Chef
|
|
33
32
|
scheme='https')
|
34
33
|
@username = username
|
35
34
|
@password = password
|
36
|
-
@splunk_url =
|
35
|
+
@splunk_url = URI::HTTP.new(
|
36
|
+
scheme, nil, host, port, nil, nil, nil, nil, nil).to_s
|
37
37
|
@index = index
|
38
38
|
end
|
39
39
|
|
@@ -43,7 +43,8 @@ class Chef
|
|
43
43
|
:sourcetype => 'json',
|
44
44
|
:source => 'chef-handler',
|
45
45
|
:host => node.hostname,
|
46
|
-
:index => @index
|
46
|
+
:index => @index
|
47
|
+
}
|
47
48
|
|
48
49
|
# We're creating a new Hash b/c 'node' and 'all_resources' in run_status
|
49
50
|
# are just TOO large.
|
@@ -52,7 +53,8 @@ class Chef
|
|
52
53
|
:start_time => run_status.start_time,
|
53
54
|
:end_time => run_status.end_time,
|
54
55
|
:elapsed_time => run_status.elapsed_time,
|
55
|
-
:exception => run_status.formatted_exception
|
56
|
+
:exception => run_status.formatted_exception
|
57
|
+
}.to_json
|
56
58
|
|
57
59
|
splunk_post(event, metadata)
|
58
60
|
end
|
@@ -63,7 +65,8 @@ class Chef
|
|
63
65
|
:sourcetype => 'json_chef-resources',
|
64
66
|
:source => 'chef-handler',
|
65
67
|
:host => node.hostname,
|
66
|
-
:index => @index
|
68
|
+
:index => @index
|
69
|
+
}
|
67
70
|
event = run_status.updated_resources.to_json
|
68
71
|
|
69
72
|
splunk_post(event, metadata)
|
@@ -75,7 +78,8 @@ class Chef
|
|
75
78
|
:sourcetype => 'chef-handler-backtrace',
|
76
79
|
:source => 'chef-handler',
|
77
80
|
:host => node.hostname,
|
78
|
-
:index => @index
|
81
|
+
:index => @index
|
82
|
+
}
|
79
83
|
event = Array(run_status.backtrace).join("\n")
|
80
84
|
|
81
85
|
splunk_post(event, metadata)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-handler-splunk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
|
-
-
|
8
|
-
- 1
|
7
|
+
- 2
|
9
8
|
- 0
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 2.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Greg Albrecht
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-09-05 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: json
|
@@ -54,10 +54,11 @@ extensions: []
|
|
54
54
|
extra_rdoc_files: []
|
55
55
|
|
56
56
|
files:
|
57
|
-
- LICENSE
|
57
|
+
- LICENSE.txt
|
58
58
|
- README.md
|
59
|
+
- CHANGELOG.md
|
59
60
|
- lib/chef/handler/splunk.rb
|
60
|
-
homepage:
|
61
|
+
homepage: https://github.com/ampledata/chef-handler-splunk
|
61
62
|
licenses: []
|
62
63
|
|
63
64
|
post_install_message:
|