redis_dashboard 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7368d883f06fd1e645b36e38eda3265344e4e79
4
- data.tar.gz: fd50890c3609ce804ff203eea14a0ebc85455572
3
+ metadata.gz: 77f7bba022a91fd2ecc4e3a04bc6e681941ae6e6
4
+ data.tar.gz: 9c8356bfc9dc1ed4f1c86f7d538062bfd0a3474e
5
5
  SHA512:
6
- metadata.gz: 35aaf7042c058433465f2aa74615bec63c44d08e66906da4fef874522dd106bddea978ec68f24c779f15b88b6825667777b0d33ff058f81008e42f8d187a7415
7
- data.tar.gz: f6a728c21d83ca3f6cb31fde65b49ae0da1371a2a0db0c1416e0db8522f77d66be6feecb769aaedcf022b364c300ec002eff992fd95a0b4b9be7c588bc94f1cf
6
+ metadata.gz: 519dcddb89f59ac645ab7f194cdc7f31564d40bf69879a4fda2d955a608ecf3a15d21307d046827c5a47e8cea57b047eb95e033a6bdf005d0822bdb6a0f69cbd
7
+ data.tar.gz: 46b0949f00f5dcf0cf192b44b3efd1ddd59fa78720f099a2eb469244ec746b3073018119f322ecba4ca412e445bf7dc6c223ef4badf9efd8135855cb10bf8767
@@ -3,6 +3,9 @@ require "redis"
3
3
  require "uri"
4
4
 
5
5
  class RedisDashboard::Application < Sinatra::Base
6
+ require "erubis"
7
+ set :erb, escape_html: true
8
+
6
9
  after { close_clients }
7
10
 
8
11
  get "/" do
@@ -74,8 +77,10 @@ class RedisDashboard::Application < Sinatra::Base
74
77
  end
75
78
 
76
79
  def compute_cache_hit_ratio(info)
77
- if (total = info["keyspace_hits"].to_i + info["keyspace_misses"].to_i) > 0
78
- info["keyspace_hits"].to_f * 100
80
+ hits = info["keyspace_hits"].to_i
81
+ misses = info["keyspace_misses"].to_i
82
+ if (total = hits + misses) > 0
83
+ hits * 100.0 / total
79
84
  else
80
85
  0
81
86
  end
@@ -83,7 +88,7 @@ class RedisDashboard::Application < Sinatra::Base
83
88
 
84
89
  def clients_column_description(col)
85
90
  # https://redis.io/commands/client-list
86
- {
91
+ @clients_column_description ||= {
87
92
  id: "an unique 64-bit client ID (introduced in Redis 2.8.12).",
88
93
  addr: "address/port of the client",
89
94
  fd: "file descriptor corresponding to the socket",
@@ -101,12 +106,13 @@ class RedisDashboard::Application < Sinatra::Base
101
106
  omem: "output buffer memory usage",
102
107
  events: "file descriptor events (see below)",
103
108
  cmd: "last command played",
104
- }[col.to_sym]
109
+ }
110
+ @clients_column_description[col.to_sym]
105
111
  end
106
112
 
107
113
  def client_event_description(event)
108
114
  # https://redis.io/commands/client-list
109
- {
115
+ @client_event_description ||= {
110
116
  O: "the client is a slave in MONITOR mode",
111
117
  S: "the client is a normal slave server",
112
118
  M: "the client is a master",
@@ -120,7 +126,8 @@ class RedisDashboard::Application < Sinatra::Base
120
126
  r: "the client is in readonly mode against a cluster node",
121
127
  A: "connection to be closed ASAP",
122
128
  N: "no specific flag set",
123
- }[event.to_sym]
129
+ }
130
+ @client_event_description[event.to_sym]
124
131
  end
125
132
  end
126
133
  end
@@ -20,7 +20,7 @@
20
20
  </div>
21
21
  <div>
22
22
  <span class="label">Cache hit ratio</span>
23
- <span><%= format_impact_percentage compute_cache_hit_ratio(info) %></span>
23
+ <span><%== format_impact_percentage compute_cache_hit_ratio(info) %></span>
24
24
  </div>
25
25
  </div>
26
26
  </div>
@@ -24,7 +24,7 @@
24
24
  </div>
25
25
  <% end %>
26
26
  </div>
27
- <%= yield %>
27
+ <%== yield %>
28
28
  <div class="page-footer">
29
29
  Made by <a href="https://basesecrete.com/en/">Base Secrète</a>. MIT License. <a href="https://github.com/BaseSecrete/redis_dashboard">Fork on GitHub</a>.
30
30
  <div class="rorvswild">
@@ -1,5 +1,5 @@
1
1
  <p>
2
- List up to <%= client.config["slowlog-max-len"] %> commands slower than <%= format_usec client.config["slowlog-log-slower-than"] %>.
2
+ List up to <%= client.config["slowlog-max-len"] %> commands slower than <%== format_usec client.config["slowlog-log-slower-than"] %>.
3
3
  It is defined in your config by <em>slowlog-max-len</em> and <em>slowlog-log-slower-than</em>.
4
4
  </p>
5
5
 
@@ -16,7 +16,7 @@
16
16
  <tr>
17
17
  <td><%= cmd.id %></td>
18
18
  <td class="date"><%= epoch_to_short_date_time cmd.timestamp %></td>
19
- <td class="number"><%= format_usec cmd.microseconds %></td>
19
+ <td class="number"><%== format_usec cmd.microseconds %></td>
20
20
  <td><%= cmd.command.join(" ") %></td>
21
21
  </tr>
22
22
  <% end %>
@@ -10,10 +10,10 @@
10
10
  <% for (key,hash) in stats %>
11
11
  <tr>
12
12
  <td class="key"><%= key %></td>
13
- <td class="number"><%= format_usec hash["usec"] %></td>
13
+ <td class="number"><%== format_usec hash["usec"] %></td>
14
14
  <td class="number"><%= hash["calls"] %></td>
15
- <td class="number"><%= format_usec hash["usec_per_call"] %></td>
16
- <td class="number"><%= format_impact_percentage hash["impact"] %></td>
15
+ <td class="number"><%== format_usec hash["usec_per_call"] %></td>
16
+ <td class="number"><%== format_impact_percentage hash["impact"] %></td>
17
17
  </tr>
18
18
  <% end %>
19
19
  </table>
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "redis_dashboard"
6
- spec.version = "0.1.4"
6
+ spec.version = "0.1.5"
7
7
  spec.authors = ["Alexis Bernard"]
8
8
  spec.email = ["alexis@bernard.io"]
9
9
  spec.summary = "Sinatra app to monitor Redis servers."
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_dashboard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis Bernard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-01 00:00:00.000000000 Z
11
+ date: 2019-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra