bipbip 0.5.23 → 0.5.24
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 +4 -1
- data/lib/bipbip.rb +1 -1
- data/lib/bipbip/agent.rb +5 -3
- data/lib/bipbip/plugin.rb +5 -3
- data/lib/bipbip/storage.rb +6 -0
- data/lib/bipbip/storage/copperegg.rb +46 -17
- data/lib/bipbip/version.rb +1 -1
- 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: ebd236b49b6ae015737b235b91ccc37957c4e003
|
4
|
+
data.tar.gz: e11213f8f95ea6d62e4f074ae1a51d4926139f3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a299ac1d5dd426a73b07f32a68bed3035289347895b7902a41a7951017bebb0aa5bb37f237f5ca8e2f34cdd0e68b3db25225842b1e9bf4cd79383f41c0b9af92
|
7
|
+
data.tar.gz: a2f6f16f4e0bf25f49f195ef00ce794e9fb9f12b6a12050431a8752d4fae2f836395252577ec3070c3f8df7eab1a8181d218cad2c34ec754eaab61e9b86843cb
|
data/README.md
CHANGED
@@ -22,6 +22,7 @@ Example with CopperEgg as a storage and service plugins for *memcached* and *mys
|
|
22
22
|
logfile: /var/log/bipbip.log
|
23
23
|
loglevel: INFO
|
24
24
|
frequency: 15
|
25
|
+
tags: ['foo', 'bar']
|
25
26
|
include: services.d/
|
26
27
|
|
27
28
|
storages:
|
@@ -44,8 +45,9 @@ Configuration options:
|
|
44
45
|
- **logfile** (optional): Path to log file. If not provided will log to `STDOUT`.
|
45
46
|
- **loglevel** (optional): One of [Logger's levels](http://www.ruby-doc.org/stdlib-2.1.0/libdoc/logger/rdoc/Logger.html). Defaults to `INFO`.
|
46
47
|
- **frequency** (optional): How often to measure metrics (in seconds). Defaults to `60`.
|
48
|
+
- **tags** (optional): Tags for all service plugins.
|
47
49
|
- **include** (optional): Optional directory where to look for *service plugin configurations* (relative to config file).
|
48
|
-
- **
|
50
|
+
- **storages**: List of storages to send data to.
|
49
51
|
- **services**: List of service plugins from which to gather metrics.
|
50
52
|
|
51
53
|
The `include` directive allows to set a directory from which to load additional *service plugin* configurations. The above example could also be structured with multiple files:
|
@@ -66,6 +68,7 @@ port: 11211
|
|
66
68
|
The configuration for each *service plugin* is described further down.
|
67
69
|
The following options are available for all plugins:
|
68
70
|
- `frequency`: Override the global measurement frequency.
|
71
|
+
- `tags`: Additional tags for this specific service.
|
69
72
|
- `metric_group`: Use a metric group name different from the plugin's name. Useful when using the same plugin twice.
|
70
73
|
|
71
74
|
Storages
|
data/lib/bipbip.rb
CHANGED
data/lib/bipbip/agent.rb
CHANGED
@@ -44,6 +44,7 @@ module Bipbip
|
|
44
44
|
@interrupted = false
|
45
45
|
until @interrupted
|
46
46
|
pid = Process.wait(-1)
|
47
|
+
next if @interrupted
|
47
48
|
plugin = plugin_by_pid(pid)
|
48
49
|
Bipbip.logger.error "Plugin #{plugin.name} with config #{plugin.config} died. Respawning..."
|
49
50
|
sleep(PLUGIN_RESPAWN_DELAY)
|
@@ -59,7 +60,7 @@ module Bipbip
|
|
59
60
|
'frequency' => 60,
|
60
61
|
'include' => nil,
|
61
62
|
'services' => [],
|
62
|
-
'
|
63
|
+
'tags' => [],
|
63
64
|
}.merge(config)
|
64
65
|
|
65
66
|
Bipbip.logger = Logger.new(config['logfile'])
|
@@ -77,8 +78,9 @@ module Bipbip
|
|
77
78
|
plugin_name = service['plugin']
|
78
79
|
metric_group = service['metric_group']
|
79
80
|
frequency = service['frequency'].nil? ? config['frequency'] : service['frequency']
|
80
|
-
|
81
|
-
|
81
|
+
tags = config['tags'].to_a + service['tags'].to_a
|
82
|
+
plugin_config = service.reject { |key, value| ['plugin', 'frequency', 'tags', 'metric_group'].include?(key) }
|
83
|
+
Bipbip::Plugin.factory(plugin_name, plugin_config, frequency, tags, metric_group)
|
82
84
|
end
|
83
85
|
|
84
86
|
storages = config['storages'].to_a
|
data/lib/bipbip/plugin.rb
CHANGED
@@ -6,17 +6,19 @@ module Bipbip
|
|
6
6
|
attr_accessor :name
|
7
7
|
attr_accessor :config
|
8
8
|
attr_accessor :metric_group
|
9
|
+
attr_accessor :tags
|
9
10
|
attr_accessor :pid
|
10
11
|
|
11
|
-
def self.factory(name, config, frequency, metric_group = nil)
|
12
|
+
def self.factory(name, config, frequency, tags, metric_group = nil)
|
12
13
|
require "bipbip/plugin/#{Bipbip::Helper.name_to_filename(name)}"
|
13
|
-
Plugin::const_get(Bipbip::Helper.name_to_classname(name)).new(name, config, frequency, metric_group)
|
14
|
+
Plugin::const_get(Bipbip::Helper.name_to_classname(name)).new(name, config, frequency, tags, metric_group)
|
14
15
|
end
|
15
16
|
|
16
|
-
def initialize(name, config, frequency, metric_group = nil)
|
17
|
+
def initialize(name, config, frequency, tags = nil, metric_group = nil)
|
17
18
|
@name = name.to_s
|
18
19
|
@config = config.to_hash
|
19
20
|
@frequency = frequency.to_f
|
21
|
+
@tags = tags.to_a
|
20
22
|
@metric_group = (metric_group || name).to_s
|
21
23
|
end
|
22
24
|
|
data/lib/bipbip/storage.rb
CHANGED
@@ -4,67 +4,96 @@ module Bipbip
|
|
4
4
|
|
5
5
|
def initialize(name, config)
|
6
6
|
super(name, config)
|
7
|
-
|
7
|
+
::Copperegg::Revealmetrics::Api.apikey = config['api_key']
|
8
8
|
end
|
9
9
|
|
10
10
|
def setup_plugin(plugin)
|
11
11
|
@metric_groups ||= _load_metric_groups
|
12
12
|
@dashboards ||= _load_dashboards
|
13
|
+
@tags ||= _load_tags
|
13
14
|
|
14
15
|
if ![5, 15, 60, 300, 900, 3600, 21600].include?(plugin.frequency)
|
15
|
-
|
16
|
+
log(Logger::FATAL, "Cannot use frequency #{plugin.frequency}")
|
16
17
|
exit 1
|
17
18
|
end
|
18
19
|
|
19
20
|
metric_group = @metric_groups.detect { |m| m.name == plugin.metric_group }
|
20
|
-
if metric_group.nil? || !metric_group.is_a?(
|
21
|
-
|
22
|
-
metric_group =
|
21
|
+
if metric_group.nil? || !metric_group.is_a?(::Copperegg::Revealmetrics::MetricGroup)
|
22
|
+
log(Logger::INFO, "Creating metric group `#{plugin.metric_group}`")
|
23
|
+
metric_group = ::Copperegg::Revealmetrics::MetricGroup.new(:name => plugin.metric_group, :label => plugin.metric_group, :frequency => plugin.frequency)
|
23
24
|
end
|
24
25
|
metric_group.frequency = plugin.frequency
|
25
26
|
metric_group.metrics = plugin.metrics_schema.map do |sample|
|
26
27
|
{
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
:name => sample[:name],
|
29
|
+
:type => 'ce_' + sample[:type],
|
30
|
+
:unit => sample[:unit],
|
30
31
|
}
|
31
32
|
end
|
33
|
+
log(Logger::INFO, "Updating metric group `#{plugin.metric_group}`")
|
32
34
|
metric_group.save
|
33
35
|
|
36
|
+
plugin.tags.each do |tag_name|
|
37
|
+
tag = @tags.detect { |t| t.name == tag_name }
|
38
|
+
if tag.nil?
|
39
|
+
log(Logger::INFO, "Creating tag `#{tag_name}`")
|
40
|
+
tag = ::Copperegg::Revealmetrics::Tag.new(:name => tag_name)
|
41
|
+
end
|
42
|
+
object_identifier = plugin.source_identifier
|
43
|
+
unless tag.objects.include?(object_identifier)
|
44
|
+
log(Logger::INFO, "Attaching object to tag `#{tag_name}`")
|
45
|
+
tag.objects << object_identifier
|
46
|
+
store_sample(plugin, Time.now, {}) # Need to store a sample before we can tag a custom object
|
47
|
+
end
|
48
|
+
log(Logger::INFO, "Updating tag `#{tag_name}`")
|
49
|
+
tag.save
|
50
|
+
end
|
51
|
+
|
34
52
|
dashboard = @dashboards.detect { |d| d.name == plugin.metric_group }
|
35
53
|
if dashboard.nil?
|
36
|
-
|
54
|
+
log(Logger::INFO, "Creating dashboard `#{plugin.metric_group}`")
|
37
55
|
metrics = metric_group.metrics || []
|
38
|
-
|
56
|
+
::Copperegg::Revealmetrics::CustomDashboard.create(metric_group, :name => plugin.metric_group, :identifiers => nil, :metrics => metrics)
|
39
57
|
end
|
40
58
|
end
|
41
59
|
|
42
60
|
def store_sample(plugin, time, data)
|
43
|
-
response =
|
61
|
+
response = ::Copperegg::Revealmetrics::MetricSample.save(plugin.metric_group, plugin.source_identifier, time.to_i, data)
|
44
62
|
if response.code != '200'
|
45
63
|
raise("Cannot store copperegg data `#{data}`. Response code `#{response.code}`, message `#{response.message}`, body `#{response.body}`")
|
46
64
|
end
|
47
65
|
end
|
48
66
|
|
49
67
|
def _load_metric_groups
|
50
|
-
|
51
|
-
metric_groups =
|
68
|
+
log(Logger::INFO, 'Loading metric groups')
|
69
|
+
metric_groups = ::Copperegg::Revealmetrics::MetricGroup.find
|
52
70
|
if metric_groups.nil?
|
53
|
-
|
71
|
+
log(Logger::FATAL, 'Cannot load metric groups')
|
54
72
|
exit 1
|
55
73
|
end
|
56
74
|
metric_groups
|
57
75
|
end
|
58
76
|
|
59
77
|
def _load_dashboards
|
60
|
-
|
61
|
-
dashboards =
|
78
|
+
log(Logger::INFO, 'Loading dashboards')
|
79
|
+
dashboards = ::Copperegg::Revealmetrics::CustomDashboard.find
|
62
80
|
if dashboards.nil?
|
63
|
-
|
81
|
+
log(Logger::FATAL, 'Cannot load dashboards')
|
64
82
|
exit 1
|
65
83
|
end
|
66
84
|
dashboards
|
67
85
|
end
|
68
86
|
|
87
|
+
# @return [Copperegg::Revealmetrics::Tag[]]
|
88
|
+
def _load_tags
|
89
|
+
log(Logger::INFO, 'Loading tags')
|
90
|
+
tags = ::Copperegg::Revealmetrics::Tag.find
|
91
|
+
if tags.nil?
|
92
|
+
log(Logger::FATAL, 'Cannot load tags')
|
93
|
+
exit 1
|
94
|
+
end
|
95
|
+
tags
|
96
|
+
end
|
97
|
+
|
69
98
|
end
|
70
99
|
end
|
data/lib/bipbip/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bipbip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cargo Media
|
@@ -10,22 +10,22 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-03-
|
13
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name: copperegg
|
16
|
+
name: copperegg-revealmetrics
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
19
|
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.
|
21
|
+
version: 0.8.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 0.
|
28
|
+
version: 0.8.1
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: memcached
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|