bipbip 0.0.7 → 0.0.8
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 +15 -6
- data/bin/bipbip +1 -1
- data/lib/bipbip.rb +1 -1
- data/lib/bipbip/agent.rb +54 -32
- data/lib/bipbip/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8aa8df7e73d0d7c9d463fb6770ad5b3e59327375
|
4
|
+
data.tar.gz: 75973cff2c74e8eff315d6484b89628ec4d9e7be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a19418f1f7693d768ab30a6b14000d2dd50fcd24b4702c8ef307962f8f77369bab604ae21f73a1daeec26d31fe3c71fd2556569a38b6ebd9cdd12639543d701
|
7
|
+
data.tar.gz: c1453b8c39cb419f6c8d6ecd614d0105aa5bce98eaec83a0e5493c7d439e073a5d279c29d423aed7bfc30c6b60107595c551f4164198051763c9d830671bf88e
|
data/README.md
CHANGED
@@ -1,22 +1,31 @@
|
|
1
1
|
bipbip
|
2
2
|
======
|
3
3
|
Agent to collect server metrics and send them to the [CopperEgg RevealMetrics](http://copperegg.com/) platform.
|
4
|
-
Plugins for different metrics available
|
4
|
+
Plugins for different metrics available.
|
5
5
|
Will spawn a child process for every plugin and server you tell it to monitor.
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
Installation
|
8
|
+
------------
|
9
|
+
```
|
10
|
+
gem install bipbip
|
11
|
+
```
|
12
|
+
|
13
|
+
Configuration
|
14
|
+
-------------
|
9
15
|
Pass the path to your configuration file to `bipbip` using the `-c` command line argument.
|
10
16
|
```sh
|
11
|
-
bipbip -c /etc/bipbip/
|
17
|
+
bipbip -c /etc/bipbip/config.yml
|
12
18
|
```
|
13
19
|
|
14
|
-
The configuration file should list the services you want to collect
|
20
|
+
The configuration file should list the services you want to collect data for:
|
15
21
|
```yml
|
22
|
+
logfile: /var/log/bipbip.log
|
16
23
|
loglevel: INFO
|
24
|
+
frequency: 15
|
25
|
+
include: services.d/
|
26
|
+
|
17
27
|
copperegg:
|
18
28
|
apikey: YOUR_APIKEY
|
19
|
-
frequency: 15
|
20
29
|
|
21
30
|
services:
|
22
31
|
-
|
data/bin/bipbip
CHANGED
data/lib/bipbip.rb
CHANGED
data/lib/bipbip/agent.rb
CHANGED
@@ -2,49 +2,47 @@ module Bipbip
|
|
2
2
|
|
3
3
|
class Agent
|
4
4
|
|
5
|
-
def initialize
|
5
|
+
def initialize(config_file)
|
6
6
|
@plugin_pids = []
|
7
|
-
|
7
|
+
@logfile = STDOUT
|
8
|
+
@loglevel = 'INFO'
|
9
|
+
@frequency = 60
|
10
|
+
@services = []
|
11
|
+
@copperegg_api_key
|
8
12
|
|
9
|
-
|
10
|
-
|
13
|
+
load_config(config_file)
|
14
|
+
end
|
11
15
|
|
12
|
-
|
13
|
-
Bipbip.logger
|
16
|
+
def run
|
17
|
+
Bipbip.logger = Logger.new(@logfile)
|
18
|
+
Bipbip.logger.level = Logger::const_get(@loglevel)
|
14
19
|
Bipbip.logger.info 'Startup...'
|
15
20
|
|
16
|
-
|
17
|
-
CopperEgg::Api.
|
18
|
-
frequency = config['copperegg']['frequency'].to_i
|
21
|
+
Bipbip.logger.info "Using CopperEgg API key `#{@copperegg_api_key}`"
|
22
|
+
CopperEgg::Api.apikey = @copperegg_api_key
|
19
23
|
|
20
|
-
if ![5, 15, 60, 300, 900, 3600, 21600].include?(frequency)
|
21
|
-
Bipbip.logger.fatal "Invalid frequency: #{frequency}"
|
22
|
-
exit
|
24
|
+
if ![5, 15, 60, 300, 900, 3600, 21600].include?(@frequency)
|
25
|
+
Bipbip.logger.fatal "Invalid frequency: #{@frequency}"
|
26
|
+
exit 1
|
23
27
|
end
|
24
28
|
|
25
29
|
['INT', 'TERM'].each { |sig| trap(sig) {
|
26
30
|
Thread.new { interrupt }
|
27
31
|
} }
|
28
32
|
|
29
|
-
|
30
|
-
|
31
|
-
include_path = File.expand_path(config['include'], File.dirname(config_file))
|
32
|
-
services += load_include_configs(include_path)
|
33
|
-
end
|
34
|
-
|
35
|
-
metric_groups = load_metric_groups
|
36
|
-
dashboards = load_dashboards
|
33
|
+
metric_groups = get_copperegg_metric_groups
|
34
|
+
dashboards = get_copperegg_dashboards
|
37
35
|
|
38
|
-
plugin_names = services.map { |service| service['plugin'] }
|
36
|
+
plugin_names = @services.map { |service| service['plugin'] }
|
39
37
|
plugin_names.each do |plugin_name|
|
40
38
|
plugin = Plugin::const_get(plugin_name).new
|
41
39
|
|
42
40
|
metric_group = metric_groups.detect { |m| m.name == plugin_name }
|
43
41
|
if metric_group.nil? || !metric_group.is_a?(CopperEgg::MetricGroup)
|
44
42
|
Bipbip.logger.info "Creating metric group `#{plugin_name}`"
|
45
|
-
metric_group = CopperEgg::MetricGroup.new(:name => plugin_name, :label => plugin_name, :frequency => frequency)
|
43
|
+
metric_group = CopperEgg::MetricGroup.new(:name => plugin_name, :label => plugin_name, :frequency => @frequency)
|
46
44
|
end
|
47
|
-
metric_group.frequency = frequency
|
45
|
+
metric_group.frequency = @frequency
|
48
46
|
metric_group.metrics = plugin.metrics_schema
|
49
47
|
metric_group.save
|
50
48
|
|
@@ -56,37 +54,61 @@ module Bipbip
|
|
56
54
|
end
|
57
55
|
end
|
58
56
|
|
59
|
-
services.each do |service|
|
57
|
+
@services.each do |service|
|
60
58
|
plugin_name = service['plugin']
|
61
59
|
Bipbip.logger.info "Starting plugin #{plugin_name}"
|
62
60
|
plugin = Plugin::const_get(plugin_name).new
|
63
|
-
@plugin_pids.push plugin.run(service, frequency)
|
61
|
+
@plugin_pids.push plugin.run(service, @frequency)
|
64
62
|
end
|
65
63
|
|
66
64
|
p Process.waitall
|
67
65
|
end
|
68
66
|
|
69
|
-
def
|
67
|
+
def get_copperegg_metric_groups
|
70
68
|
Bipbip.logger.info 'Loading metric groups'
|
71
69
|
metric_groups = CopperEgg::MetricGroup.find
|
72
70
|
if metric_groups.nil?
|
73
|
-
|
71
|
+
Bipbip.logger.fatal 'Cannot load metric groups'
|
72
|
+
exit 1
|
74
73
|
end
|
75
74
|
metric_groups
|
76
75
|
end
|
77
76
|
|
78
|
-
def
|
77
|
+
def get_copperegg_dashboards
|
79
78
|
Bipbip.logger.info 'Loading dashboards'
|
80
79
|
dashboards = CopperEgg::CustomDashboard.find
|
81
80
|
if dashboards.nil?
|
82
|
-
|
81
|
+
Bipbip.logger.fatal 'Cannot load dashboards'
|
82
|
+
exit 1
|
83
83
|
end
|
84
84
|
dashboards
|
85
85
|
end
|
86
86
|
|
87
|
-
def
|
88
|
-
|
89
|
-
|
87
|
+
def load_config(config_file)
|
88
|
+
config = YAML.load(File.open(config_file))
|
89
|
+
if config.has_key?('logfile')
|
90
|
+
@logfile = config['logfile'].to_s
|
91
|
+
end
|
92
|
+
if config.has_key?('loglevel')
|
93
|
+
@loglevel = config['loglevel'].to_s
|
94
|
+
end
|
95
|
+
if config.has_key?('frequency')
|
96
|
+
@frequency = config['frequency'].to_i
|
97
|
+
end
|
98
|
+
if config.has_key?('services')
|
99
|
+
@services = config['services'].to_a
|
100
|
+
end
|
101
|
+
if config.has_key?('include')
|
102
|
+
include_path = File.expand_path(config['include'].to_s, File.dirname(config_file))
|
103
|
+
files = Dir[include_path + '/**/*.yaml', include_path + '/**/*.yml']
|
104
|
+
@services += files.map {|file| YAML.load(File.open(file))}
|
105
|
+
end
|
106
|
+
if config.has_key?('copperegg')
|
107
|
+
config_copperegg = config['copperegg']
|
108
|
+
if config_copperegg.has_key?('apikey')
|
109
|
+
@copperegg_api_key = config_copperegg['apikey']
|
110
|
+
end
|
111
|
+
end
|
90
112
|
end
|
91
113
|
|
92
114
|
def interrupt
|
data/lib/bipbip/version.rb
CHANGED