collective-metrics 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/collective.rb +1 -0
- data/lib/collective/collectors/postgres.rb +42 -0
- data/lib/collective/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16a6befd91bd072a768a156befa6a1aad8237b69
|
4
|
+
data.tar.gz: 8c1ae9faca49b5f44933a73f07972164c2fb6644
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b92b6d24fa654e26bf93e012d31be9266d84b291f78283e81b5705314fdaa610d64313fe604dece6ff5b070e937649a9fc22b739e2e9ca63c484de713a4da17
|
7
|
+
data.tar.gz: b765a52456d03ceb3a851b394613545dde710ca0ce0bd245cd277aecc3eacc6dcdba13abd3279d8087a8703d0f1422ee1b0c9ab3a28a2865c2ecf4aef294f000
|
data/README.md
CHANGED
data/lib/collective.rb
CHANGED
@@ -16,6 +16,7 @@ module Collective
|
|
16
16
|
autoload :Honeybadger, 'collective/collectors/honeybadger'
|
17
17
|
autoload :Newrelic, 'collective/collectors/newrelic'
|
18
18
|
autoload :PGBouncer, 'collective/collectors/pgbouncer'
|
19
|
+
autoload :Postgres, 'collective/collectors/postgres'
|
19
20
|
end
|
20
21
|
|
21
22
|
class << self
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Collective::Collectors
|
2
|
+
class Postgres < Collective::Collector
|
3
|
+
MEGABYTE = 1024 * 1024
|
4
|
+
|
5
|
+
requires :pg
|
6
|
+
|
7
|
+
resolution '600s'
|
8
|
+
|
9
|
+
collect do
|
10
|
+
group "postgres.#{connection_options[:dbname]}" do |group|
|
11
|
+
instrument_relation_size_data group
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def instrument_relation_size_data(group)
|
18
|
+
begin
|
19
|
+
conn = PG.connect(connection_options)
|
20
|
+
size_tuples = conn.exec(size_query)
|
21
|
+
size_tuples.each do |tuple|
|
22
|
+
group.instrument "#{tuple['relation']}.size", (tuple['total_size'].to_f / MEGABYTE).round(2), units: 'MB'
|
23
|
+
end
|
24
|
+
ensure
|
25
|
+
conn.close if conn != nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def size_query
|
30
|
+
"SELECT relname AS relation, pg_total_relation_size(C.oid) AS total_size
|
31
|
+
FROM pg_class C
|
32
|
+
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
|
33
|
+
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
|
34
|
+
AND C.relkind <> 'i'
|
35
|
+
AND nspname !~ '^pg_toast';"
|
36
|
+
end
|
37
|
+
|
38
|
+
def connection_options
|
39
|
+
options[:connection] || {}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/collective/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: collective-metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric J. Holmes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rufus-scheduler
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- lib/collective/collectors/mongodb.rb
|
156
156
|
- lib/collective/collectors/newrelic.rb
|
157
157
|
- lib/collective/collectors/pgbouncer.rb
|
158
|
+
- lib/collective/collectors/postgres.rb
|
158
159
|
- lib/collective/collectors/rabbitmq.rb
|
159
160
|
- lib/collective/collectors/redis.rb
|
160
161
|
- lib/collective/collectors/sidekiq.rb
|