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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e9922be6c95f3dd56d5b41844d239316ce99f8e
4
- data.tar.gz: 53c0c88d93f9794ecc698601659695e65bc05cb8
3
+ metadata.gz: a5dea912ab838c4fae3ac427223c11432f059eec
4
+ data.tar.gz: 8615bc4cc2913aa1c639f8e75235985b29f50c76
5
5
  SHA512:
6
- metadata.gz: d00b0e9a93e26343ee7418279778a0e7144af7eae862f4a17edcf3be93af28f2ff76c3cb20c2570422e93f98a430394029ab1f47c2b6b861bac75aec121812e5
7
- data.tar.gz: f0053ca3dc71a1de4bee814722033dae44ed4484fc07fb4f68aff4abeff929f90587668d5c91bd7fdd4c777e7929d4446d3510899b65f948ecc1c4f3f82f8795
6
+ metadata.gz: 9f333855160f97440da34cb9395c91139af6d125c7d8c12ef957691478fdbeb9318c403584af294ded8826956b99a63d79b8b6bc6fc62adda88c7fd19afabcca
7
+ data.tar.gz: fd3c203da38d5238d493c33eae218403597c21f8791c84edc61f74db9ed20d08b8980cc1c2029873b6ef50ad77e7136823c48e82ba7cee35165d57538a2718c6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.1.9
2
+
3
+ - Added tune page
4
+ - Removed minimum size for unused indexes
5
+
1
6
  ## 0.1.8
2
7
 
3
8
  - Added `total_percent` to `query_stats`
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
- ## Bonus
213
+ Minimum connections for high connections warning
214
214
 
215
- See where queries come from with [Marginalia](https://github.com/basecamp/marginalia) - comments appear on the Live Queries tab.
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
- - show exactly which indexes to add
220
- - more detailed explanations on dashboard
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
@@ -6,6 +6,7 @@ PgHero::Engine.routes.draw do
6
6
  get "query_stats", to: "home#query_stats"
7
7
  get "system_stats", to: "home#system_stats"
8
8
  get "explain", to: "home#explain"
9
+ get "tune", to: "home#tune"
9
10
 
10
11
  post "kill", to: "home#kill"
11
12
  post "kill_all", to: "home#kill_all"
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
@@ -1,3 +1,3 @@
1
1
  module PgHero
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
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.8
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-20 00:00:00.000000000 Z
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