falcore 0.1.1 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba2b736dbebc64f028d7fccc61a1f7d964a1dc0b
4
- data.tar.gz: d072fc223b6ac83e19ca3570b73b95cad33b9067
3
+ metadata.gz: ebc83f332274914a6d13586077516e385a0699cf
4
+ data.tar.gz: 0bf7525e7a91aaa74a40cfc086abd2ef8db434e6
5
5
  SHA512:
6
- metadata.gz: 43086275160a917b36e946dfce95e420ff8b2ad2cb43800b9cf82cc68299ee883475538a3dd5dc1a7e605c6bbbb0e5a53bd4760aea0a959c32aad70c994aed64
7
- data.tar.gz: ab1392a98ecf7530419468979998abd107bd6134840ddc4d91c180db6d50821f9977183490b82b9616edd132378bbc2935a6171f15970834a0adc5c983faad4d
6
+ metadata.gz: c8c761b694a8207112f06e86a4511666b3bc3b155a0ebb5a2ff41c93b3ef7b31caff66110792c4073a686753db9bd02b53b066458d625921b82e295544dd938b
7
+ data.tar.gz: cc5304c2238066debecc98685e7e316e1983f8413ed6cc16765ff1ba8a613a00af30d03e574c4d3e9925076f27af5ca410d80a562ccc9e39119961214957ef67
@@ -1,6 +1,10 @@
1
1
  Falcore CHANGELOG
2
2
  =================
3
3
 
4
+ v0.2.0
5
+ ------
6
+ - Add a special dumper for DogStatsd
7
+
4
8
  v0.1.1
5
9
  ------
6
10
  - Convert `--sleep` values to floats
data/README.md CHANGED
@@ -76,6 +76,43 @@ varies by dumper, so consult the documentation accordingly:
76
76
  falcore --config /path/to/your/config.falcore --daemon
77
77
  ```
78
78
 
79
+ Dumpers
80
+ -------
81
+ ### Statsd
82
+ The Statsd dumper is a generic Statsd dumper that namespaces data by hostname.
83
+
84
+ ```text
85
+ [statsd]
86
+ host = 127.0.0.1
87
+ port = 8125
88
+ ```
89
+
90
+ This will dump information to a local Statsd on port 8125. The information is
91
+ namespaced by the Jenkins master, and slaves are nested under their appropiate
92
+ master. For example:
93
+
94
+ ```text
95
+ jenkins.master.disk_space
96
+ jenkins.master.slave-12345.disk_space
97
+ ```
98
+
99
+ ### DogStatsd
100
+ The DogStatsd dumper is a [DataDog](http://datadoghq.com)-specific dumper that
101
+ adds additional sugar when pushing the data to DataDog. The format for the
102
+ configuration is almost identical to Statsd, but with a different config header.
103
+
104
+ ```text
105
+ [dogstatsd]
106
+ host = 127.0.0.1
107
+ port = 8125
108
+ ```
109
+
110
+ This will dump information to a local DogStatsd server running on port 8125.
111
+ Unlike the Statsd dumper, the information is **not** namespaced. Instead, each
112
+ node (master or slave) is tagged with a `name` that corresponds to the Jenkins
113
+ `displayName` attribute. You can then filter or aggregate by `name` to separate
114
+ information on the graphs.
115
+
79
116
 
80
117
  License & Authors
81
118
  -----------------
@@ -74,5 +74,9 @@ loop do
74
74
  Falcore::Dumper::Statsd.new(config, master).run
75
75
  end
76
76
 
77
+ unless config.dogstatsd.nil?
78
+ Falcore::Dumper::DogStatsd.new(config, master).run
79
+ end
80
+
77
81
  sleep(options[:sleep]/1_000)
78
82
  end
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
25
  spec.require_paths = ['lib']
26
26
 
27
- spec.add_runtime_dependency 'statsd-ruby', '~> 1.2'
27
+ spec.add_runtime_dependency 'dogstatsd-ruby', '~> 1.3'
28
28
 
29
29
  spec.add_development_dependency 'bundler', '~> 1.5'
30
30
  spec.add_development_dependency 'rspec', '~> 2.14'
@@ -26,8 +26,9 @@ module Falcore
26
26
  autoload :Util, 'falcore/util'
27
27
 
28
28
  module Dumper
29
- autoload :Base, 'falcore/dumpers/base'
30
- autoload :Statsd, 'falcore/dumpers/statsd'
29
+ autoload :Base, 'falcore/dumpers/base'
30
+ autoload :DogStatsd, 'falcore/dumpers/dogstatsd'
31
+ autoload :Statsd, 'falcore/dumpers/statsd'
31
32
  end
32
33
 
33
34
  module Node
@@ -0,0 +1,80 @@
1
+ #
2
+ # Author: Seth Vargo <sethvargo@gmail.com>
3
+ #
4
+ # Copyright 2014 Chef Software, Inc.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'statsd'
20
+
21
+ module Falcore
22
+ class Dumper::DogStatsd < Dumper::Base
23
+ validate do
24
+ presence!('DogStatsd host') { config.dogstatsd.host }
25
+ presence!('DogStatsd port') { config.dogstatsd.port }
26
+ end
27
+
28
+ run do
29
+ stat(master)
30
+ master.slaves.each(&method(:stat))
31
+ end
32
+
33
+ private
34
+
35
+ def statsd
36
+ @statsd ||= Statsd.new(config.dogstatsd.host, config.dogstatsd.port)
37
+ end
38
+
39
+ #
40
+ # @private
41
+ #
42
+ # Push stats to statsd for this particular +node+.
43
+ #
44
+ # @param [Node::Base] node
45
+ # the node to examine
46
+ #
47
+ def stat(node)
48
+ options = {
49
+ tags: ["name:#{node.display_name}"]
50
+ }
51
+
52
+ # Up/down
53
+ statsd.gauge('jenkins.node.offline', node.offline? ? 1 : 0, options)
54
+
55
+ # Idle
56
+ statsd.gauge('jenkins.node.idle', node.idle? ? 1 : 0, options)
57
+
58
+ # Response time
59
+ statsd.timing('jenkins.node.response_time', node.response_time, options)
60
+
61
+ # Temporary space
62
+ statsd.gauge('jenkins.node.temporary_space', node.temporary_space, options)
63
+
64
+ # Disk space
65
+ statsd.gauge('jenkins.node.disk_space', node.disk_space, options)
66
+
67
+ # Free memory
68
+ statsd.gauge('jenkins.node.free_memory', node.free_memory, options)
69
+
70
+ # Total memory
71
+ statsd.gauge('jenkins.node.total_memory', node.total_memory, options)
72
+
73
+ # Free swap
74
+ statsd.gauge('jenkins.node.free_swap', node.free_swap, options)
75
+
76
+ # Total swap
77
+ statsd.gauge('jenkins.node.total_swap', node.total_swap, options)
78
+ end
79
+ end
80
+ end
@@ -17,5 +17,5 @@
17
17
  #
18
18
 
19
19
  module Falcore
20
- VERSION = '0.1.1'
20
+ VERSION = '0.2.0'
21
21
  end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ module Falcore
4
+ describe Dumper::DogStatsd, :integration do
5
+ let(:config) do
6
+ Config.parse <<-EOH.gsub(/^ {8}/, '')
7
+ [jenkins]
8
+ endpoint = http://master.jenkins.example.com
9
+
10
+ [dogstatsd]
11
+ host = 127.0.0.1
12
+ port = 12345
13
+ EOH
14
+ end
15
+
16
+ let(:aggregator) { Aggregator.new(config) }
17
+ let(:master) { aggregator.run }
18
+
19
+ subject { Dumper::DogStatsd.new(config, master) }
20
+
21
+ it 'validates config.dogstatsd.host is present' do
22
+ config.dogstatsd.host = nil
23
+
24
+ expect {
25
+ subject.run
26
+ }.to raise_error(RuntimeError, "Expected 'DogStatsd host' to be set!")
27
+ end
28
+
29
+ it 'validates config.dogstatsd.port is present' do
30
+ config.dogstatsd.port = nil
31
+
32
+ expect {
33
+ subject.run
34
+ }.to raise_error(RuntimeError, "Expected 'DogStatsd port' to be set!")
35
+ end
36
+ end
37
+ end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: falcore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Vargo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-08 00:00:00.000000000 Z
11
+ date: 2014-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: statsd-ruby
14
+ name: dogstatsd-ruby
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.2'
19
+ version: '1.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.2'
26
+ version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -117,6 +117,7 @@ files:
117
117
  - lib/falcore/aggregator.rb
118
118
  - lib/falcore/config.rb
119
119
  - lib/falcore/dumpers/base.rb
120
+ - lib/falcore/dumpers/dogstatsd.rb
120
121
  - lib/falcore/dumpers/statsd.rb
121
122
  - lib/falcore/fetcher.rb
122
123
  - lib/falcore/nodes/base.rb
@@ -126,6 +127,7 @@ files:
126
127
  - lib/falcore/util.rb
127
128
  - lib/falcore/version.rb
128
129
  - spec/fixtures/computer.json
130
+ - spec/functional/dumpers/dogstatsd_spec.rb
129
131
  - spec/functional/dumpers/statsd_spec.rb
130
132
  - spec/functional/fetcher_spec.rb
131
133
  - spec/spec_helper.rb
@@ -164,6 +166,7 @@ summary: A Ruby application for collecting Jenkins node slave status and aggrega
164
166
  to multiple output formats.
165
167
  test_files:
166
168
  - spec/fixtures/computer.json
169
+ - spec/functional/dumpers/dogstatsd_spec.rb
167
170
  - spec/functional/dumpers/statsd_spec.rb
168
171
  - spec/functional/fetcher_spec.rb
169
172
  - spec/spec_helper.rb