bipbip 0.6.7 → 0.6.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 +5 -1
- data/bin/bipbip +5 -6
- data/lib/bipbip.rb +6 -2
- data/lib/bipbip/agent.rb +2 -5
- data/lib/bipbip/config.rb +4 -7
- data/lib/bipbip/helper.rb +1 -2
- data/lib/bipbip/plugin.rb +21 -29
- data/lib/bipbip/plugin/apache2.rb +4 -6
- data/lib/bipbip/plugin/command.rb +10 -13
- data/lib/bipbip/plugin/elasticsearch.rb +56 -59
- data/lib/bipbip/plugin/fastcgi_php_apc.rb +4 -6
- data/lib/bipbip/plugin/fastcgi_php_fpm.rb +5 -7
- data/lib/bipbip/plugin/fastcgi_php_opcache.rb +15 -17
- data/lib/bipbip/plugin/gearman.rb +4 -6
- data/lib/bipbip/plugin/log_parser.rb +11 -15
- data/lib/bipbip/plugin/memcached.rb +5 -7
- data/lib/bipbip/plugin/mongodb.rb +39 -37
- data/lib/bipbip/plugin/monit.rb +12 -13
- data/lib/bipbip/plugin/mysql.rb +21 -23
- data/lib/bipbip/plugin/network.rb +3 -5
- data/lib/bipbip/plugin/nginx.rb +11 -13
- data/lib/bipbip/plugin/php_apc.rb +4 -6
- data/lib/bipbip/plugin/postfix.rb +2 -4
- data/lib/bipbip/plugin/puppet.rb +16 -18
- data/lib/bipbip/plugin/redis.rb +9 -11
- data/lib/bipbip/plugin/resque.rb +9 -9
- data/lib/bipbip/plugin/socket_redis.rb +7 -8
- data/lib/bipbip/storage.rb +5 -8
- data/lib/bipbip/storage/copperegg.rb +8 -11
- data/lib/bipbip/version.rb +1 -1
- data/lib/interruptible_sleep.rb +1 -1
- metadata +17 -3
@@ -1,19 +1,17 @@
|
|
1
1
|
module Bipbip
|
2
|
-
|
3
2
|
class Plugin::Network < Plugin
|
4
|
-
|
5
3
|
def metrics_schema
|
6
4
|
[
|
7
|
-
|
5
|
+
{ name: 'connections_total', type: 'gauge', unit: 'Connections' }
|
8
6
|
]
|
9
7
|
end
|
10
8
|
|
11
9
|
def monitor
|
12
10
|
tcp_summary = `ss -s | grep '^TCP:'`
|
13
11
|
tcp_counters = /^TCP:\s+(\d+) \(estab (\d+), closed (\d+), orphaned (\d+), synrecv (\d+), timewait (\d+)\/(\d+)\), ports (\d+)$/.match(tcp_summary)
|
14
|
-
|
12
|
+
fail "Cannot match ss-output `#{tcp_summary}`" unless tcp_counters
|
15
13
|
|
16
|
-
{:
|
14
|
+
{ connections_total: tcp_counters[1].to_i }
|
17
15
|
end
|
18
16
|
end
|
19
17
|
end
|
data/lib/bipbip/plugin/nginx.rb
CHANGED
@@ -1,17 +1,15 @@
|
|
1
1
|
module Bipbip
|
2
|
-
|
3
2
|
class Plugin::Nginx < Plugin
|
4
|
-
|
5
3
|
def metrics_schema
|
6
4
|
[
|
7
|
-
{:
|
8
|
-
{:
|
9
|
-
{:
|
10
|
-
{:
|
11
|
-
{:
|
12
|
-
{:
|
13
|
-
{:
|
14
|
-
{:
|
5
|
+
{ name: 'connections_accepts', type: 'counter', unit: 'Connections' },
|
6
|
+
{ name: 'connections_handled', type: 'counter', unit: 'Connections' },
|
7
|
+
{ name: 'connections_dropped', type: 'counter', unit: 'Connections' },
|
8
|
+
{ name: 'connections_requests', type: 'counter', unit: 'Requests' },
|
9
|
+
{ name: 'active_total', type: 'gauge', unit: 'Connections' },
|
10
|
+
{ name: 'active_reading', type: 'gauge', unit: 'Connections' },
|
11
|
+
{ name: 'active_writing', type: 'gauge', unit: 'Connections' },
|
12
|
+
{ name: 'active_waiting', type: 'gauge', unit: 'Connections' }
|
15
13
|
]
|
16
14
|
end
|
17
15
|
|
@@ -19,10 +17,10 @@ module Bipbip
|
|
19
17
|
uri = URI.parse(config['url'])
|
20
18
|
response = Net::HTTP.get_response(uri)
|
21
19
|
|
22
|
-
|
20
|
+
fail "Invalid response from server at #{config['url']}" unless response.code == '200'
|
23
21
|
|
24
22
|
lines = response.body.split(/\r*\n/)
|
25
|
-
lines.map
|
23
|
+
lines.map(&:strip!)
|
26
24
|
|
27
25
|
data = {}
|
28
26
|
|
@@ -48,7 +46,7 @@ module Bipbip
|
|
48
46
|
def match_or_fail(string, regexp)
|
49
47
|
match_data = regexp.match(string)
|
50
48
|
if match_data.nil?
|
51
|
-
|
49
|
+
fail "Data `#{string}` doesn't match pattern `#{regexp}`."
|
52
50
|
end
|
53
51
|
match_data
|
54
52
|
end
|
@@ -1,11 +1,9 @@
|
|
1
1
|
module Bipbip
|
2
|
-
|
3
2
|
class Plugin::PhpApc < Plugin
|
4
|
-
|
5
3
|
def metrics_schema
|
6
4
|
[
|
7
|
-
|
8
|
-
|
5
|
+
{ name: 'opcode_mem_size', type: 'gauge', unit: 'b' },
|
6
|
+
{ name: 'user_mem_size', type: 'gauge', unit: 'b' }
|
9
7
|
]
|
10
8
|
end
|
11
9
|
|
@@ -13,11 +11,11 @@ module Bipbip
|
|
13
11
|
uri = URI.parse(config['url'])
|
14
12
|
response = Net::HTTP.get_response(uri)
|
15
13
|
|
16
|
-
|
14
|
+
fail "Invalid response from server at #{config['url']}" unless response.code == '200'
|
17
15
|
|
18
16
|
stats = JSON.parse(response.body)
|
19
17
|
|
20
|
-
{:
|
18
|
+
{ opcode_mem_size: stats['opcode_mem_size'].to_i, user_mem_size: stats['user_mem_size'].to_i }
|
21
19
|
end
|
22
20
|
end
|
23
21
|
end
|
@@ -1,17 +1,15 @@
|
|
1
1
|
module Bipbip
|
2
|
-
|
3
2
|
class Plugin::Postfix < Plugin
|
4
|
-
|
5
3
|
def metrics_schema
|
6
4
|
[
|
7
|
-
|
5
|
+
{ name: 'mails_queued_total', type: 'gauge', unit: 'Mails' }
|
8
6
|
]
|
9
7
|
end
|
10
8
|
|
11
9
|
def monitor
|
12
10
|
queue_counter = /(\d+) Request+s?\.$/.match(postqueue)
|
13
11
|
{
|
14
|
-
|
12
|
+
'mails_queued_total' => queue_counter.nil? ? 0 : queue_counter[1].to_i
|
15
13
|
}
|
16
14
|
end
|
17
15
|
|
data/lib/bipbip/plugin/puppet.rb
CHANGED
@@ -2,21 +2,19 @@ require 'pathname'
|
|
2
2
|
require 'yaml'
|
3
3
|
|
4
4
|
module Bipbip
|
5
|
-
|
6
5
|
class Plugin::Puppet < Plugin
|
7
|
-
|
8
6
|
def metrics_schema
|
9
7
|
[
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
8
|
+
{ name: 'report_ok', type: 'gauge', unit: 'Boolean' },
|
9
|
+
{ name: 'last_run_total_time', type: 'gauge', unit: 'Seconds' },
|
10
|
+
{ name: 'last_run_age', type: 'gauge', unit: 'Seconds' },
|
11
|
+
{ name: 'events_failure_count', type: 'gauge', unit: 'Events' },
|
12
|
+
{ name: 'events_success_count', type: 'gauge', unit: 'Events' },
|
13
|
+
{ name: 'events_total_count', type: 'gauge', unit: 'Events' },
|
14
|
+
{ name: 'resources_failed_count', type: 'gauge', unit: 'Resources' },
|
15
|
+
{ name: 'resources_skipped_count', type: 'gauge', unit: 'Resources' },
|
16
|
+
{ name: 'resources_total_count', type: 'gauge', unit: 'Resources' },
|
17
|
+
{ name: 'changes_total_count', type: 'gauge', unit: 'Changes' }
|
20
18
|
]
|
21
19
|
end
|
22
20
|
|
@@ -24,14 +22,14 @@ module Bipbip
|
|
24
22
|
puppet_report = last_run_summary
|
25
23
|
|
26
24
|
report_age = Time.new.to_i - puppet_report['time']['last_run'].to_i
|
27
|
-
has_events = puppet_report.
|
28
|
-
has_resources = puppet_report.
|
29
|
-
has_changes = puppet_report.
|
25
|
+
has_events = puppet_report.key?('events')
|
26
|
+
has_resources = puppet_report.key?('resources')
|
27
|
+
has_changes = puppet_report.key?('changes')
|
30
28
|
|
31
29
|
metrics = {
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
'report_ok' => ((has_events && has_changes && has_resources) ? 1 : 0),
|
31
|
+
'last_run_total_time' => puppet_report['time']['total'].to_i,
|
32
|
+
'last_run_age' => report_age
|
35
33
|
}
|
36
34
|
|
37
35
|
if has_events
|
data/lib/bipbip/plugin/redis.rb
CHANGED
@@ -3,30 +3,28 @@ class RedisClient < Redis
|
|
3
3
|
end
|
4
4
|
|
5
5
|
module Bipbip
|
6
|
-
|
7
6
|
class Plugin::Redis < Plugin
|
8
|
-
|
9
7
|
def metrics_schema
|
10
8
|
[
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
{ name: 'total_commands_processed', type: 'counter', unit: 'Commands' },
|
10
|
+
{ name: 'used_memory', type: 'gauge', unit: 'b' },
|
11
|
+
{ name: 'used_memory_rss', type: 'gauge', unit: 'b' },
|
12
|
+
{ name: 'mem_fragmentation_ratio', type: 'gauge', unit: 'Frag' },
|
13
|
+
{ name: 'connected_clients', type: 'gauge', unit: 'Clients' },
|
14
|
+
{ name: 'blocked_clients', type: 'gauge', unit: 'BlockedClients' }
|
17
15
|
]
|
18
16
|
end
|
19
17
|
|
20
18
|
def float_roundings
|
21
19
|
{
|
22
|
-
|
20
|
+
'mem_fragmentation_ratio' => 2
|
23
21
|
}
|
24
22
|
end
|
25
23
|
|
26
24
|
def monitor
|
27
25
|
redis = RedisClient.new(
|
28
|
-
|
29
|
-
|
26
|
+
host: config['hostname'],
|
27
|
+
port: config['port']
|
30
28
|
)
|
31
29
|
stats = redis.info
|
32
30
|
redis.quit
|
data/lib/bipbip/plugin/resque.rb
CHANGED
@@ -2,19 +2,18 @@ require 'redis'
|
|
2
2
|
require 'resque'
|
3
3
|
|
4
4
|
module Bipbip
|
5
|
-
|
6
5
|
class Plugin::Resque < Plugin
|
7
|
-
|
8
6
|
def metrics_schema
|
9
7
|
schema_list = [
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
{ name: 'num_workers', type: 'counter', unit: 'Workers' },
|
9
|
+
{ name: 'num_idle_workers', type: 'counter', unit: 'Workers' },
|
10
|
+
{ name: 'num_active_workers', type: 'counter', unit: 'Workers' },
|
11
|
+
{ name: 'num_failures', type: 'counter', unit: 'Jobs' }
|
13
12
|
]
|
14
13
|
|
15
14
|
with_resque_connection do
|
16
15
|
::Resque.queues.each do |queue|
|
17
|
-
schema_list << {:
|
16
|
+
schema_list << { name: "queue_size_#{sanitize_queue_name(queue)}", type: 'gauge', unit: 'Jobs' }
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
@@ -27,8 +26,8 @@ module Bipbip
|
|
27
26
|
|
28
27
|
def with_resque_connection
|
29
28
|
redis = ::Redis.new(
|
30
|
-
|
31
|
-
|
29
|
+
host: config['hostname'] || 'localhost',
|
30
|
+
port: config['port'] || 6369
|
32
31
|
)
|
33
32
|
redis.select config['database']
|
34
33
|
::Resque.redis = redis
|
@@ -43,8 +42,9 @@ module Bipbip
|
|
43
42
|
data = {}
|
44
43
|
with_resque_connection do
|
45
44
|
data['num_workers'] = ::Resque.workers.count
|
46
|
-
data['num_idle_workers'] = ::Resque.workers.
|
45
|
+
data['num_idle_workers'] = ::Resque.workers.count(&:idle?)
|
47
46
|
data['num_active_workers'] = data['num_workers'] - data['num_idle_workers']
|
47
|
+
data['num_failures'] = ::Resque::Failure.count
|
48
48
|
::Resque.queues.each do |queue|
|
49
49
|
data["queue_size_#{sanitize_queue_name(queue)}"] = ::Resque.size(queue).to_i
|
50
50
|
end
|
@@ -1,21 +1,19 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
|
3
3
|
module Bipbip
|
4
|
-
|
5
4
|
class Plugin::SocketRedis < Plugin
|
6
|
-
|
7
5
|
def metrics_schema
|
8
6
|
[
|
9
|
-
|
10
|
-
|
7
|
+
{ name: 'channels_count', type: 'gauge', unit: 'Channels' },
|
8
|
+
{ name: 'subscribers_count', type: 'gauge', unit: 'Subscribers' }
|
11
9
|
]
|
12
10
|
end
|
13
11
|
|
14
12
|
def monitor
|
15
13
|
stats = fetch_socket_redis_status
|
16
14
|
{
|
17
|
-
|
18
|
-
|
15
|
+
'channels_count' => stats.length,
|
16
|
+
'subscribers_count' => stats.values.reduce(0) { |memo, channel| memo += channel['subscribers'].length }
|
19
17
|
}
|
20
18
|
end
|
21
19
|
|
@@ -26,10 +24,11 @@ module Bipbip
|
|
26
24
|
uri = URI.parse(url)
|
27
25
|
|
28
26
|
response = Net::HTTP.get_response(uri)
|
29
|
-
|
27
|
+
unless response.code == '200'
|
28
|
+
fail "Invalid response from server at `#{url}`. Response code `#{response.code}`, message `#{response.message}`, body `#{response.body}`"
|
29
|
+
end
|
30
30
|
|
31
31
|
JSON.parse(response.body)
|
32
32
|
end
|
33
|
-
|
34
33
|
end
|
35
34
|
end
|
data/lib/bipbip/storage.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
module Bipbip
|
2
|
-
|
3
2
|
class Storage
|
4
|
-
|
5
3
|
attr_accessor :name
|
6
4
|
attr_accessor :config
|
7
5
|
|
8
6
|
def self.factory(name, config)
|
9
7
|
require "bipbip/storage/#{Bipbip::Helper.name_to_filename(name)}"
|
10
|
-
Storage
|
8
|
+
Storage.const_get(Bipbip::Helper.name_to_classname(name)).new(name, config)
|
11
9
|
end
|
12
10
|
|
13
11
|
def initialize(name, config)
|
@@ -15,12 +13,12 @@ module Bipbip
|
|
15
13
|
@config = config.to_hash
|
16
14
|
end
|
17
15
|
|
18
|
-
def setup_plugin(
|
19
|
-
|
16
|
+
def setup_plugin(_plugin)
|
17
|
+
fail 'Missing method setup_plugin'
|
20
18
|
end
|
21
19
|
|
22
|
-
def store_sample(
|
23
|
-
|
20
|
+
def store_sample(_plugin, _time, _data)
|
21
|
+
fail 'Missing method store_sample'
|
24
22
|
end
|
25
23
|
|
26
24
|
private
|
@@ -28,6 +26,5 @@ module Bipbip
|
|
28
26
|
def log(severity, message)
|
29
27
|
Bipbip.logger.add(severity, message, "#{name}")
|
30
28
|
end
|
31
|
-
|
32
29
|
end
|
33
30
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module Bipbip
|
2
|
-
|
3
2
|
class Storage::Copperegg < Storage
|
4
|
-
|
5
3
|
def initialize(name, config)
|
6
4
|
super(name, config)
|
7
5
|
::Copperegg::Revealmetrics::Api.apikey = config['api_key']
|
@@ -12,7 +10,7 @@ module Bipbip
|
|
12
10
|
@dashboards ||= _load_dashboards
|
13
11
|
@tags ||= _load_tags
|
14
12
|
|
15
|
-
|
13
|
+
unless [5, 15, 60, 300, 900, 3600, 21_600].include?(plugin.frequency)
|
16
14
|
log(Logger::FATAL, "Cannot use frequency #{plugin.frequency}")
|
17
15
|
exit 1
|
18
16
|
end
|
@@ -20,14 +18,14 @@ module Bipbip
|
|
20
18
|
metric_group = @metric_groups.detect { |m| m.name == plugin.metric_group }
|
21
19
|
if metric_group.nil? || !metric_group.is_a?(::Copperegg::Revealmetrics::MetricGroup)
|
22
20
|
log(Logger::INFO, "Creating metric group `#{plugin.metric_group}`")
|
23
|
-
metric_group = ::Copperegg::Revealmetrics::MetricGroup.new(:
|
21
|
+
metric_group = ::Copperegg::Revealmetrics::MetricGroup.new(name: plugin.metric_group, label: plugin.metric_group, frequency: plugin.frequency)
|
24
22
|
end
|
25
23
|
metric_group.frequency = plugin.frequency
|
26
24
|
metric_group.metrics = plugin.metrics_schema.map do |sample|
|
27
25
|
{
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
26
|
+
name: sample[:name],
|
27
|
+
type: 'ce_' + sample[:type],
|
28
|
+
unit: sample[:unit]
|
31
29
|
}
|
32
30
|
end
|
33
31
|
log(Logger::INFO, "Updating metric group `#{plugin.metric_group}`")
|
@@ -37,7 +35,7 @@ module Bipbip
|
|
37
35
|
tag = @tags.detect { |t| t.name == tag_name }
|
38
36
|
if tag.nil?
|
39
37
|
log(Logger::INFO, "Creating tag `#{tag_name}`")
|
40
|
-
tag = ::Copperegg::Revealmetrics::Tag.new(:
|
38
|
+
tag = ::Copperegg::Revealmetrics::Tag.new(name: tag_name)
|
41
39
|
end
|
42
40
|
object_identifier = plugin.source_identifier
|
43
41
|
unless tag.objects.include?(object_identifier)
|
@@ -53,14 +51,14 @@ module Bipbip
|
|
53
51
|
if dashboard.nil?
|
54
52
|
log(Logger::INFO, "Creating dashboard `#{plugin.metric_group}`")
|
55
53
|
metrics = metric_group.metrics || []
|
56
|
-
::Copperegg::Revealmetrics::CustomDashboard.create(metric_group, :
|
54
|
+
::Copperegg::Revealmetrics::CustomDashboard.create(metric_group, name: plugin.metric_group, identifiers: nil, metrics: metrics)
|
57
55
|
end
|
58
56
|
end
|
59
57
|
|
60
58
|
def store_sample(plugin, time, data)
|
61
59
|
response = ::Copperegg::Revealmetrics::MetricSample.save(plugin.metric_group, plugin.source_identifier, time.to_i, data)
|
62
60
|
if response.code != '200'
|
63
|
-
|
61
|
+
fail("Cannot store copperegg data `#{data}`. Response code `#{response.code}`, message `#{response.message}`, body `#{response.body}`")
|
64
62
|
end
|
65
63
|
end
|
66
64
|
|
@@ -94,6 +92,5 @@ module Bipbip
|
|
94
92
|
end
|
95
93
|
tags
|
96
94
|
end
|
97
|
-
|
98
95
|
end
|
99
96
|
end
|
data/lib/bipbip/version.rb
CHANGED
data/lib/interruptible_sleep.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.6.
|
4
|
+
version: 0.6.8
|
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: 2015-
|
13
|
+
date: 2015-12-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: copperegg-revealmetrics
|
@@ -208,6 +208,20 @@ dependencies:
|
|
208
208
|
- - "~>"
|
209
209
|
- !ruby/object:Gem::Version
|
210
210
|
version: '1.21'
|
211
|
+
- !ruby/object:Gem::Dependency
|
212
|
+
name: rubocop
|
213
|
+
requirement: !ruby/object:Gem::Requirement
|
214
|
+
requirements:
|
215
|
+
- - "~>"
|
216
|
+
- !ruby/object:Gem::Version
|
217
|
+
version: '0.35'
|
218
|
+
type: :development
|
219
|
+
prerelease: false
|
220
|
+
version_requirements: !ruby/object:Gem::Requirement
|
221
|
+
requirements:
|
222
|
+
- - "~>"
|
223
|
+
- !ruby/object:Gem::Version
|
224
|
+
version: '0.35'
|
211
225
|
description: Agent to collect data for common server programs and push them to CopperEgg
|
212
226
|
email: hello@cargomedia.ch
|
213
227
|
executables:
|
@@ -269,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
269
283
|
version: '0'
|
270
284
|
requirements: []
|
271
285
|
rubyforge_project:
|
272
|
-
rubygems_version: 2.
|
286
|
+
rubygems_version: 2.5.0
|
273
287
|
signing_key:
|
274
288
|
specification_version: 4
|
275
289
|
summary: Gather services data and store in CopperEgg
|