bipbip 0.4.2 → 0.4.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 +4 -4
- data/README.md +4 -2
- data/lib/bipbip/agent.rb +8 -7
- data/lib/bipbip/plugin.rb +9 -7
- data/lib/bipbip/storage/copperegg.rb +7 -7
- data/lib/bipbip/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe7f32a299c9d06b71d8599033430b810b91e365
|
4
|
+
data.tar.gz: 65275e6d51c12f947433bffd47d8b0fa915f9b2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81fcc4bbced95d1a6fa34739fec24e94a790937be7b3ac9c111dd82963003580e931d67b113dc757df9cbd6c54b9fafb9b89dbc00c6a9ce2c7ac739985660ee2
|
7
|
+
data.tar.gz: 381a7c4e18a31068c755fd64f43430d34dd647fca4682f2fb29f088e5e533a981fcb9d0c1dc5541f065d6641143e5e43eb3f001444fa79ff212355520906fd3c
|
data/README.md
CHANGED
@@ -106,6 +106,10 @@ services:
|
|
106
106
|
regexp: segfault
|
107
107
|
```
|
108
108
|
|
109
|
+
Optional configuration common to all plugins:
|
110
|
+
- `frequency`: Override global frequency per plugin
|
111
|
+
- `metric_group`: Use metric group name different from plugin name. Useful when using the same plugin twice.
|
112
|
+
|
109
113
|
Include configuration
|
110
114
|
---------------------
|
111
115
|
In your configuration you can specify a directory to include service configurations from:
|
@@ -121,8 +125,6 @@ hostname: localhost
|
|
121
125
|
port: 11211
|
122
126
|
```
|
123
127
|
|
124
|
-
You can also set an override frequency per service in the main config or in these included configs.
|
125
|
-
|
126
128
|
Plugins
|
127
129
|
-------
|
128
130
|
#### fastcgi-php-fpm
|
data/lib/bipbip/agent.rb
CHANGED
@@ -56,16 +56,17 @@ module Bipbip
|
|
56
56
|
services = config['services'].to_a
|
57
57
|
if config['include']
|
58
58
|
include_path = File.expand_path(config['include'].to_s, File.dirname(config_file))
|
59
|
-
|
59
|
+
|
60
60
|
files = Dir[include_path + '/**/*.yaml', include_path + '/**/*.yml']
|
61
61
|
services += files.map { |file| YAML.load(File.open(file)) }
|
62
|
-
end
|
63
|
-
|
62
|
+
end
|
63
|
+
|
64
64
|
@plugins = services.map do |service|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
plugin_name = service['plugin']
|
66
|
+
metric_group = service['metric_group']
|
67
|
+
frequency = service['frequency'].nil? ? config['frequency'] : service['frequency']
|
68
|
+
plugin_config = service.reject { |key, value| ['plugin', 'frequency', 'metric_group'].include?(key) }
|
69
|
+
Bipbip::Plugin.factory(plugin_name, plugin_config, frequency, metric_group)
|
69
70
|
end
|
70
71
|
|
71
72
|
storages = config['storages'].to_a
|
data/lib/bipbip/plugin.rb
CHANGED
@@ -5,16 +5,18 @@ module Bipbip
|
|
5
5
|
|
6
6
|
attr_accessor :name
|
7
7
|
attr_accessor :config
|
8
|
+
attr_accessor :metric_group
|
8
9
|
|
9
|
-
def self.factory(name, config, frequency)
|
10
|
+
def self.factory(name, config, frequency, metric_group = nil)
|
10
11
|
require "bipbip/plugin/#{Bipbip::Helper.name_to_filename(name)}"
|
11
|
-
Plugin::const_get(Bipbip::Helper.name_to_classname(name)).new(name, config, frequency)
|
12
|
+
Plugin::const_get(Bipbip::Helper.name_to_classname(name)).new(name, config, frequency, metric_group)
|
12
13
|
end
|
13
14
|
|
14
|
-
def initialize(name, config, frequency)
|
15
|
+
def initialize(name, config, frequency, metric_group = nil)
|
15
16
|
@name = name.to_s
|
16
17
|
@config = config.to_hash
|
17
18
|
@frequency = frequency.to_i
|
19
|
+
@metric_group = (metric_group || name).to_s
|
18
20
|
end
|
19
21
|
|
20
22
|
def run(storages)
|
@@ -29,9 +31,9 @@ module Bipbip
|
|
29
31
|
time = Time.now
|
30
32
|
data = monitor
|
31
33
|
if data.empty?
|
32
|
-
raise "#{name} #{
|
34
|
+
raise "#{name} #{source_identifier}: Empty data"
|
33
35
|
end
|
34
|
-
Bipbip.logger.debug "#{name} #{
|
36
|
+
Bipbip.logger.debug "#{name} #{source_identifier}: Data: #{data}"
|
35
37
|
storages.each do |storage|
|
36
38
|
storage.store_sample(self, time, data)
|
37
39
|
end
|
@@ -39,7 +41,7 @@ module Bipbip
|
|
39
41
|
interruptible_sleep (frequency - (Time.now - time))
|
40
42
|
end
|
41
43
|
rescue => e
|
42
|
-
Bipbip.logger.error "#{name} #{
|
44
|
+
Bipbip.logger.error "#{name} #{source_identifier}: Error getting data: #{e.message}"
|
43
45
|
interruptible_sleep retry_delay
|
44
46
|
retry_delay += frequency if retry_delay < frequency * 10
|
45
47
|
retry
|
@@ -61,7 +63,7 @@ module Bipbip
|
|
61
63
|
@frequency
|
62
64
|
end
|
63
65
|
|
64
|
-
def
|
66
|
+
def source_identifier
|
65
67
|
identifier = Bipbip.fqdn
|
66
68
|
unless config.empty?
|
67
69
|
identifier += '::' + config.values.first.to_s
|
@@ -16,10 +16,10 @@ module Bipbip
|
|
16
16
|
exit 1
|
17
17
|
end
|
18
18
|
|
19
|
-
metric_group = @metric_groups.detect { |m| m.name == plugin.
|
19
|
+
metric_group = @metric_groups.detect { |m| m.name == plugin.metric_group }
|
20
20
|
if metric_group.nil? || !metric_group.is_a?(CopperEgg::MetricGroup)
|
21
|
-
Bipbip.logger.info "Creating copperegg metric group `#{plugin.
|
22
|
-
metric_group = CopperEgg::MetricGroup.new(:name => plugin.
|
21
|
+
Bipbip.logger.info "Creating copperegg metric group `#{plugin.metric_group}`"
|
22
|
+
metric_group = CopperEgg::MetricGroup.new(:name => plugin.metric_group, :label => plugin.metric_group, :frequency => plugin.frequency)
|
23
23
|
end
|
24
24
|
metric_group.frequency = plugin.frequency
|
25
25
|
metric_group.metrics = plugin.metrics_schema.map do |sample|
|
@@ -31,16 +31,16 @@ module Bipbip
|
|
31
31
|
end
|
32
32
|
metric_group.save
|
33
33
|
|
34
|
-
dashboard = @dashboards.detect { |d| d.name == plugin.
|
34
|
+
dashboard = @dashboards.detect { |d| d.name == plugin.metric_group }
|
35
35
|
if dashboard.nil?
|
36
|
-
Bipbip.logger.info "Creating copperegg dashboard `#{plugin.
|
36
|
+
Bipbip.logger.info "Creating copperegg dashboard `#{plugin.metric_group}`"
|
37
37
|
metrics = metric_group.metrics || []
|
38
|
-
CopperEgg::CustomDashboard.create(metric_group, :name => plugin.
|
38
|
+
CopperEgg::CustomDashboard.create(metric_group, :name => plugin.metric_group, :identifiers => nil, :metrics => metrics)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
def store_sample(plugin, time, data)
|
43
|
-
CopperEgg::MetricSample.save(plugin.
|
43
|
+
CopperEgg::MetricSample.save(plugin.metric_group, plugin.source_identifier, time.to_i, data)
|
44
44
|
end
|
45
45
|
|
46
46
|
def _load_metric_groups
|
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.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cargo Media
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-10-
|
13
|
+
date: 2014-10-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: copperegg
|