pghero 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of pghero might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +13 -4
- data/app/controllers/pg_hero/home_controller.rb +6 -1
- data/app/views/layouts/pg_hero/application.html.erb +1 -0
- data/app/views/pg_hero/home/system_stats.html.erb +2 -2
- data/app/views/pg_hero/home/tune.html.erb +22 -0
- data/config/routes.rb +1 -0
- data/lib/pghero.rb +27 -1
- data/lib/pghero/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: a5dea912ab838c4fae3ac427223c11432f059eec
|
4
|
+
data.tar.gz: 8615bc4cc2913aa1c639f8e75235985b29f50c76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f333855160f97440da34cb9395c91139af6d125c7d8c12ef957691478fdbeb9318c403584af294ded8826956b99a63d79b8b6bc6fc62adda88c7fd19afabcca
|
7
|
+
data.tar.gz: fd3c203da38d5238d493c33eae218403597c21f8791c84edc61f74db9ed20d08b8980cc1c2029873b6ef50ad77e7136823c48e82ba7cee35165d57538a2718c6
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -210,14 +210,23 @@ Minimum calls for slow queries
|
|
210
210
|
PgHero.slow_query_calls = 100 # default
|
211
211
|
```
|
212
212
|
|
213
|
-
|
213
|
+
Minimum connections for high connections warning
|
214
214
|
|
215
|
-
|
215
|
+
```ruby
|
216
|
+
PgHero.total_connections_threshold = 100 # default
|
217
|
+
```
|
218
|
+
|
219
|
+
## Bonus Projects
|
220
|
+
|
221
|
+
- See where queries come from with [Marginalia](https://github.com/basecamp/marginalia) - comments appear on the Live Queries tab.
|
222
|
+
- Get weekly news and articles with [Postgres Weekly](http://postgresweekly.com)
|
223
|
+
- Optimize your configuration with [PgTune](http://pgtune.leopard.in.ua) and [pgBench](http://www.postgresql.org/docs/devel/static/pgbench.html)
|
216
224
|
|
217
225
|
## TODO
|
218
226
|
|
219
|
-
-
|
220
|
-
-
|
227
|
+
- suggest indexes
|
228
|
+
- suggest paramater values
|
229
|
+
- better explanations on dashboard
|
221
230
|
|
222
231
|
Know a bit about PostgreSQL? [Suggestions](https://github.com/ankane/pghero/issues) are greatly appreciated.
|
223
232
|
|
@@ -45,7 +45,7 @@ module PgHero
|
|
45
45
|
|
46
46
|
def system_stats
|
47
47
|
@title = "System Stats"
|
48
|
-
@cpu_usage = PgHero.cpu_usage
|
48
|
+
@cpu_usage = PgHero.cpu_usage.map{|k, v| [k, v.round] }
|
49
49
|
@connection_stats = PgHero.connection_stats
|
50
50
|
end
|
51
51
|
|
@@ -63,6 +63,11 @@ module PgHero
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
+
def tune
|
67
|
+
@title = "Tune"
|
68
|
+
@settings = PgHero.settings
|
69
|
+
end
|
70
|
+
|
66
71
|
def kill
|
67
72
|
if PgHero.kill(params[:pid])
|
68
73
|
redirect_to root_path, notice: "Query killed"
|
@@ -362,6 +362,7 @@
|
|
362
362
|
<li class="<%= controller.action_name == "space" ? "active" : "" %>"><%= link_to "Space", space_path %></li>
|
363
363
|
<li class="<%= controller.action_name == "explain" ? "active" : "" %>"><%= link_to "Explain", explain_path %></li>
|
364
364
|
<li class="<%= controller.action_name == "queries" ? "active" : "" %>"><%= link_to "Live Queries", queries_path %></li>
|
365
|
+
<li class="<%= controller.action_name == "tune" ? "active" : "" %>"><%= link_to "Tune", tune_path %></li>
|
365
366
|
</ul>
|
366
367
|
</div>
|
367
368
|
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
<div class="content">
|
4
4
|
<h1>CPU Usage</h1>
|
5
|
-
<div style="margin-bottom: 20px;"><%= line_chart @cpu_usage, max: 101 %></div>
|
5
|
+
<div style="margin-bottom: 20px;"><%= line_chart @cpu_usage, max: 101, colors: ["#5bc0de"], library: {pointSize: 0, lineWidth: 5} %></div>
|
6
6
|
|
7
7
|
<h1>Connections</h1>
|
8
|
-
<div style="margin-bottom: 20px;"><%= line_chart @connection_stats %></div>
|
8
|
+
<div style="margin-bottom: 20px;"><%= line_chart @connection_stats, colors: ["#5bc0de"], library: {pointSize: 0, lineWidth: 5} %></div>
|
9
9
|
</div>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<div class="content">
|
2
|
+
<h1>Tune</h1>
|
3
|
+
|
4
|
+
<table class="table">
|
5
|
+
<thead>
|
6
|
+
<tr>
|
7
|
+
<th>Setting</th>
|
8
|
+
<th style="width: 20%;">Value</th>
|
9
|
+
</tr>
|
10
|
+
</thead>
|
11
|
+
<tbody>
|
12
|
+
<% @settings.each do |setting, value| %>
|
13
|
+
<tr>
|
14
|
+
<td><%= setting %></td>
|
15
|
+
<td><%= value %></td>
|
16
|
+
</tr>
|
17
|
+
<% end %>
|
18
|
+
</tbody>
|
19
|
+
</table>
|
20
|
+
|
21
|
+
<p>Check out <%= link_to "PgTune", "http://pgtune.leopard.in.ua", target: "_blank" %> for recommendations.</p>
|
22
|
+
</div>
|
data/config/routes.rb
CHANGED
data/lib/pghero.rb
CHANGED
@@ -168,7 +168,6 @@ module PgHero
|
|
168
168
|
WHERE
|
169
169
|
NOT indisunique
|
170
170
|
AND idx_scan < 50
|
171
|
-
AND pg_relation_size(i.indexrelid) > 1024 * 1024
|
172
171
|
ORDER BY
|
173
172
|
pg_relation_size(i.indexrelid) DESC,
|
174
173
|
relname ASC
|
@@ -479,6 +478,33 @@ module PgHero
|
|
479
478
|
end
|
480
479
|
end
|
481
480
|
|
481
|
+
def settings
|
482
|
+
names = %w[
|
483
|
+
max_connections shared_buffers effective_cache_size work_mem
|
484
|
+
maintenance_work_mem checkpoint_segments checkpoint_completion_target
|
485
|
+
wal_buffers default_statistics_target
|
486
|
+
]
|
487
|
+
values = Hash[ select_all(Connection.send(:sanitize_sql_array, ["SELECT name, setting, unit FROM pg_settings WHERE name IN (?)", names])).sort_by{|row| names.index(row["name"]) }.map{|row| [row["name"], friendly_value(row["setting"], row["unit"])] } ]
|
488
|
+
Hash[ names.map{|name| [name, values[name]] } ]
|
489
|
+
end
|
490
|
+
|
491
|
+
def friendly_value(setting, unit)
|
492
|
+
if %w[kB 8kB].include?(unit)
|
493
|
+
value = setting.to_i
|
494
|
+
value *= 8 if unit == "8kB"
|
495
|
+
|
496
|
+
if value % (1024 * 1024) == 0
|
497
|
+
"#{value / (1024 * 1024)}GB"
|
498
|
+
elsif value % 1024 == 0
|
499
|
+
"#{value / 1024}MB"
|
500
|
+
else
|
501
|
+
"#{value}kB"
|
502
|
+
end
|
503
|
+
else
|
504
|
+
"#{setting}#{unit}".strip
|
505
|
+
end
|
506
|
+
end
|
507
|
+
|
482
508
|
def select_all(sql)
|
483
509
|
# squish for logs
|
484
510
|
connection.select_all(squish(sql)).to_a
|
data/lib/pghero/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pghero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- app/views/pg_hero/home/query_stats.html.erb
|
105
105
|
- app/views/pg_hero/home/space.html.erb
|
106
106
|
- app/views/pg_hero/home/system_stats.html.erb
|
107
|
+
- app/views/pg_hero/home/tune.html.erb
|
107
108
|
- config/routes.rb
|
108
109
|
- gemfiles/activerecord31.gemfile
|
109
110
|
- gemfiles/activerecord32.gemfile
|