newrelic_postgres_plugin 0.1.1 → 0.1.2
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/Gemfile.lock +4 -10
- data/lib/newrelic_postgres_plugin.rb +1 -1
- data/lib/newrelic_postgres_plugin/agent.rb +12 -16
- data/newrelic_postgres_plugin.gemspec +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: e6beba3e07419260f3b4c6c1f6b57330fdca6458
|
4
|
+
data.tar.gz: 8a7cf2a2f411e3b3033a0ec0f41acc1c5b4d7731
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c21b206678c70f7ec299539e3aa40d92a56615eaf40ca4f1604960a39ca66242ca643c51d77e66d12d770855495e601b1d3a22bfc6c6cc3cc492929539dd53bb
|
7
|
+
data.tar.gz: 4b92762c91c318069f6c4c510667db3200daeff9446c9bd2771d4ba5fdd01aefcee775e51897237885d8122161477a8141fb4a440a571e4d7c3a469e94206016
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,3 @@
|
|
1
|
-
GIT
|
2
|
-
remote: git@github.com:newrelic-platform/newrelic_plugin.git
|
3
|
-
revision: 913177005ae53883c73395833f3be0e9c6644eae
|
4
|
-
branch: release
|
5
|
-
specs:
|
6
|
-
newrelic_plugin (1.0.1)
|
7
|
-
faraday (>= 0.8.1)
|
8
|
-
json
|
9
|
-
|
10
1
|
GEM
|
11
2
|
remote: http://rubygems.org/
|
12
3
|
specs:
|
@@ -14,11 +5,14 @@ GEM
|
|
14
5
|
multipart-post (~> 1.1)
|
15
6
|
json (1.8.0)
|
16
7
|
multipart-post (1.2.0)
|
8
|
+
newrelic_plugin (1.0.2)
|
9
|
+
faraday (>= 0.8.1)
|
10
|
+
json
|
17
11
|
pg (0.15.1)
|
18
12
|
|
19
13
|
PLATFORMS
|
20
14
|
ruby
|
21
15
|
|
22
16
|
DEPENDENCIES
|
23
|
-
newrelic_plugin
|
17
|
+
newrelic_plugin (~> 1.0.2)
|
24
18
|
pg
|
@@ -53,7 +53,7 @@ module NewRelic::PostgresPlugin
|
|
53
53
|
# Returns true if we're talking to Postgres version >= 9.2
|
54
54
|
#
|
55
55
|
def nine_two?
|
56
|
-
@connection.
|
56
|
+
@connection.server_version >= 90200
|
57
57
|
end
|
58
58
|
|
59
59
|
|
@@ -83,8 +83,8 @@ module NewRelic::PostgresPlugin
|
|
83
83
|
|
84
84
|
def report_backend_metrics
|
85
85
|
@connection.exec(backend_query) do |result|
|
86
|
-
report_metric "Backends/Active", '
|
87
|
-
report_metric "Backends/Idle",
|
86
|
+
report_metric "Backends/Active", 'connections', result[0]['backends_active']
|
87
|
+
report_metric "Backends/Idle", 'connections', result[0]['backends_idle']
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -116,21 +116,20 @@ module NewRelic::PostgresPlugin
|
|
116
116
|
|
117
117
|
def report_index_metrics
|
118
118
|
@connection.exec(index_count_query) do |result|
|
119
|
-
report_metric "Indexes/
|
120
|
-
report_metric "Indexes/Disk Utilization", 'bytes', result[0]['size_indexes'].to_f
|
119
|
+
report_metric "Indexes/Number of Indexes", 'indexes', result[0]['indexes'].to_i
|
121
120
|
end
|
122
121
|
@connection.exec(index_hit_rate_query) do |result|
|
123
|
-
report_metric "Indexes/Hit Rate",
|
124
|
-
report_metric "Indexes/Cache Hit Rate", '%', result[1]['ratio'].to_f
|
122
|
+
report_metric "Indexes/Index Hit Rate", '%', result[0]['ratio'].to_f * 100.0
|
123
|
+
report_metric "Indexes/Cache Hit Rate", '%', result[1]['ratio'].to_f * 100.0
|
125
124
|
end
|
126
125
|
@connection.exec(index_size_query) do |result|
|
127
|
-
report_metric "Indexes/Size", 'bytes', result[0]['size'].to_f
|
126
|
+
report_metric "Indexes/Size on Disk", 'bytes', result[0]['size'].to_f
|
128
127
|
end
|
129
128
|
end
|
130
129
|
|
131
130
|
def backend_query
|
132
131
|
%Q(
|
133
|
-
SELECT
|
132
|
+
SELECT ( SELECT count(*) FROM pg_stat_activity WHERE
|
134
133
|
#{
|
135
134
|
if nine_two?
|
136
135
|
"state <> 'idle'"
|
@@ -141,9 +140,9 @@ module NewRelic::PostgresPlugin
|
|
141
140
|
) AS backends_active, ( SELECT count(*) FROM pg_stat_activity WHERE
|
142
141
|
#{
|
143
142
|
if nine_two?
|
144
|
-
"
|
143
|
+
"state = 'idle'"
|
145
144
|
else
|
146
|
-
"
|
145
|
+
"current_query = '<IDLE>'"
|
147
146
|
end
|
148
147
|
}
|
149
148
|
) AS backends_idle FROM pg_stat_activity;
|
@@ -160,6 +159,7 @@ module NewRelic::PostgresPlugin
|
|
160
159
|
|
161
160
|
def index_count_query
|
162
161
|
"SELECT count(1) as indexes FROM pg_class WHERE relkind = 'i';"
|
162
|
+
end
|
163
163
|
|
164
164
|
def index_hit_rate_query
|
165
165
|
%Q(
|
@@ -176,11 +176,7 @@ module NewRelic::PostgresPlugin
|
|
176
176
|
end
|
177
177
|
|
178
178
|
def index_size_query
|
179
|
-
|
180
|
-
SELECT pg_size_pretty(sum(relpages*8192)) AS size
|
181
|
-
FROM pg_class
|
182
|
-
WHERE reltype = 0;
|
183
|
-
)
|
179
|
+
"SELECT sum(relpages*8192) AS size FROM pg_class WHERE reltype = 0;"
|
184
180
|
end
|
185
181
|
|
186
182
|
end
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'newrelic_postgres_plugin'
|
16
|
-
s.version = '0.1.
|
16
|
+
s.version = '0.1.2'
|
17
17
|
s.date = '2013-06-20'
|
18
18
|
s.rubyforge_project = 'newrelic_postgres_plugin'
|
19
19
|
|