pghero 1.4.1 → 1.4.2

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: 37b92864838cd5c201e6223ae5cf72b9b7f4c763
4
- data.tar.gz: e5b56c6c3798ff5fc735af5a5f721d7d9b850b97
3
+ metadata.gz: 9d9c1570453baf5503a063836e716a0ce38307a6
4
+ data.tar.gz: 5a46751a5c8d2e95a801f963104256fbecbcb892
5
5
  SHA512:
6
- metadata.gz: e9b5eba16f3d7a5da62987f35ec3fafbc62283bbd6bb079d07b2cf2836670c4cc0e41e5efe05b101a7f0af8c2aeac405dbcd71764da981c6bf04421fa00e091c
7
- data.tar.gz: 486223410c07162fd6149c2858d9ef7614188b290024da9047ce84a08a57cc992206241363c2aeb6c70f68de6304d3ea1c8024c82071ebe8fc39c4b322e54f7a
6
+ metadata.gz: c745ed76512b199321bb518c3e914c9e96e1f89c521e72bd3f357db1c566b032fa1ddc5cc05978e24352f7e8a613e3479ea81065508b66b32cbaeca70846b2b0
7
+ data.tar.gz: cdcd785bebe95c345c6152fa338fa617dad4f0efa7b287a2f692e2f5db5b8eba745ad4156612332784aa242c25cfcb139182aa71beb5fea0fb80959880bf80e8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 1.4.2
2
+
3
+ - Fixed `wrong constant name` error in development
4
+ - Added different periods for system stats
5
+
1
6
  ## 1.4.1
2
7
 
3
8
  - Removed external assets
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # PgHero
2
2
 
3
- The missing dashboard for Postgres
3
+ A performance dashboard for Postgres
4
4
 
5
5
  [See it in action](https://pghero.herokuapp.com/)
6
6
 
@@ -407,3 +407,11 @@ body {
407
407
  .noUi-origin {
408
408
  border-radius: 0;
409
409
  }
410
+
411
+ #periods {
412
+ text-align: center;
413
+ }
414
+
415
+ #periods a {
416
+ margin-right: 20px;
417
+ }
@@ -107,24 +107,30 @@ module PgHero
107
107
 
108
108
  def system
109
109
  @title = "System"
110
+ @periods = {
111
+ "1 hour" => {duration: 1.hour, period: 60.seconds},
112
+ "1 day" => {duration: 1.day, period: 10.minutes},
113
+ "1 week" => {duration: 1.week, period: 30.minutes},
114
+ "2 weeks" => {duration: 2.weeks, period: 1.hours}
115
+ }
110
116
  end
111
117
 
112
118
  def cpu_usage
113
- render json: PgHero.cpu_usage.map { |k, v| [k, v.round] }
119
+ render json: [{name: "CPU", data: PgHero.cpu_usage(system_params).map { |k, v| [k, v.round] }, library: chart_library_options}]
114
120
  end
115
121
 
116
122
  def connection_stats
117
- render json: PgHero.connection_stats
123
+ render json: [{name: "Connections", data: PgHero.connection_stats(system_params), library: chart_library_options}]
118
124
  end
119
125
 
120
126
  def replication_lag_stats
121
- render json: PgHero.replication_lag_stats
127
+ render json: [{name: "Lag", data: PgHero.replication_lag_stats(system_params), library: chart_library_options}]
122
128
  end
123
129
 
124
130
  def load_stats
125
131
  render json: [
126
- {name: "Read IOPS", data: PgHero.read_iops_stats.map { |k, v| [k, v.round] }},
127
- {name: "Write IOPS", data: PgHero.write_iops_stats.map { |k, v| [k, v.round] }}
132
+ {name: "Read IOPS", data: PgHero.read_iops_stats(system_params).map { |k, v| [k, v.round] }, library: chart_library_options},
133
+ {name: "Write IOPS", data: PgHero.write_iops_stats(system_params).map { |k, v| [k, v.round] }, library: chart_library_options}
128
134
  ]
129
135
  end
130
136
 
@@ -225,5 +231,13 @@ module PgHero
225
231
  @query_stats_by_query = @query_stats.index_by { |q| q["query"] }
226
232
  @debug = params[:debug] == "true"
227
233
  end
234
+
235
+ def system_params
236
+ params.slice(:duration, :period)
237
+ end
238
+
239
+ def chart_library_options
240
+ {pointRadius: 0, pointHitRadius: 5, borderWidth: 4}
241
+ end
228
242
  end
229
243
  end
@@ -1,15 +1,22 @@
1
1
  <div class="content">
2
+ <p id="periods">
3
+ <% @periods.each do |name, options| %>
4
+ <%= link_to name, system_path(options) %>
5
+ <% end %>
6
+ </p>
7
+ <% path_options = params.slice(:duration, :period) %>
8
+
2
9
  <h1>CPU</h1>
3
- <div style="margin-bottom: 20px;"><%= line_chart cpu_usage_path, max: 100, colors: ["#5bc0de"] %></div>
10
+ <div style="margin-bottom: 20px;"><%= line_chart cpu_usage_path(path_options), max: 100, colors: ["#5bc0de"] %></div>
4
11
 
5
12
  <h1>Load</h1>
6
- <div style="margin-bottom: 20px;"><%= line_chart load_stats_path, colors: ["#5bc0de", "#d9534f"] %></div>
13
+ <div style="margin-bottom: 20px;"><%= line_chart load_stats_path(path_options), colors: ["#5bc0de", "#d9534f"] %></div>
7
14
 
8
15
  <h1>Connections</h1>
9
- <div style="margin-bottom: 20px;"><%= line_chart connection_stats_path, colors: ["#5bc0de"] %></div>
16
+ <div style="margin-bottom: 20px;"><%= line_chart connection_stats_path(path_options), colors: ["#5bc0de"] %></div>
10
17
 
11
18
  <% if PgHero.replica? %>
12
19
  <h1>Replication Lag</h1>
13
- <div style="margin-bottom: 20px;"><%= line_chart replication_lag_stats_path, colors: ["#5bc0de"] %></div>
20
+ <div style="margin-bottom: 20px;"><%= line_chart replication_lag_stats_path(path_options), colors: ["#5bc0de"] %></div>
14
21
  <% end %>
15
22
  </div>
@@ -12,7 +12,7 @@ module PgHero
12
12
  url = config["url"]
13
13
  Class.new(PgHero::Connection) do
14
14
  def self.name
15
- "PgHero::Connection::#{object_id}"
15
+ "PgHero::Connection::Database#{object_id}"
16
16
  end
17
17
  establish_connection(url) if url
18
18
  end
@@ -1,27 +1,27 @@
1
1
  module PgHero
2
2
  module Methods
3
3
  module System
4
- def cpu_usage
5
- rds_stats("CPUUtilization")
4
+ def cpu_usage(options = {})
5
+ rds_stats("CPUUtilization", options)
6
6
  end
7
7
 
8
- def connection_stats
9
- rds_stats("DatabaseConnections")
8
+ def connection_stats(options = {})
9
+ rds_stats("DatabaseConnections", options)
10
10
  end
11
11
 
12
- def replication_lag_stats
13
- rds_stats("ReplicaLag")
12
+ def replication_lag_stats(options = {})
13
+ rds_stats("ReplicaLag", options)
14
14
  end
15
15
 
16
- def read_iops_stats
17
- rds_stats("ReadIOPS")
16
+ def read_iops_stats(options = {})
17
+ rds_stats("ReadIOPS", options)
18
18
  end
19
19
 
20
- def write_iops_stats
21
- rds_stats("WriteIOPS")
20
+ def write_iops_stats(options = {})
21
+ rds_stats("WriteIOPS", options)
22
22
  end
23
23
 
24
- def rds_stats(metric_name)
24
+ def rds_stats(metric_name, options = {})
25
25
  if system_stats_enabled?
26
26
  client =
27
27
  if defined?(Aws)
@@ -30,14 +30,21 @@ module PgHero
30
30
  AWS::CloudWatch.new(access_key_id: access_key_id, secret_access_key: secret_access_key, region: region).client
31
31
  end
32
32
 
33
- now = Time.now
33
+ duration = (options[:duration] || 1.hour).to_i
34
+ period = (options[:period] || 1.minute).to_i
35
+ offset = (options[:offset] || 0).to_i
36
+
37
+ end_time = (Time.now - offset)
38
+ # ceil period
39
+ end_time = Time.at((end_time.to_f / period).ceil * period)
40
+
34
41
  resp = client.get_metric_statistics(
35
42
  namespace: "AWS/RDS",
36
43
  metric_name: metric_name,
37
44
  dimensions: [{name: "DBInstanceIdentifier", value: db_instance_identifier}],
38
- start_time: (now - 1 * 3600).iso8601,
39
- end_time: now.iso8601,
40
- period: 60,
45
+ start_time: (end_time - duration).iso8601,
46
+ end_time: end_time.iso8601,
47
+ period: period,
41
48
  statistics: ["Average"]
42
49
  )
43
50
  data = {}
@@ -1,3 +1,3 @@
1
1
  module PgHero
2
- VERSION = "1.4.1"
2
+ VERSION = "1.4.2"
3
3
  end
data/pghero.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
8
8
  spec.version = PgHero::VERSION
9
9
  spec.authors = ["Andrew Kane"]
10
10
  spec.email = ["andrew@chartkick.com"]
11
- spec.summary = "The missing dashboard for Postgres"
12
- spec.description = "The missing dashboard for Postgres"
11
+ spec.summary = "A performance dashboard for Postgres"
12
+ spec.description = "A performance dashboard for Postgres"
13
13
  spec.homepage = "https://github.com/ankane/pghero"
14
14
  spec.license = "MIT"
15
15
 
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: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-26 00:00:00.000000000 Z
11
+ date: 2016-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -108,7 +108,7 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- description: The missing dashboard for Postgres
111
+ description: A performance dashboard for Postgres
112
112
  email:
113
113
  - andrew@chartkick.com
114
114
  executables: []
@@ -205,10 +205,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
205
  version: '0'
206
206
  requirements: []
207
207
  rubyforge_project:
208
- rubygems_version: 2.6.1
208
+ rubygems_version: 2.5.1
209
209
  signing_key:
210
210
  specification_version: 4
211
- summary: The missing dashboard for Postgres
211
+ summary: A performance dashboard for Postgres
212
212
  test_files:
213
213
  - guides/Docker.md
214
214
  - guides/Heroku.md
@@ -222,4 +222,3 @@ test_files:
222
222
  - test/gemfiles/activerecord42.gemfile
223
223
  - test/suggested_indexes_test.rb
224
224
  - test/test_helper.rb
225
- has_rdoc: