amnesia 1.0.2 → 1.1.0

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
  SHA256:
3
- metadata.gz: 62ac67cfa06f569559611449d4f3a10cbd05c6683283b8fcbb6299dfcb78481e
4
- data.tar.gz: a2cc20ea0a933faf55cb6562d3759c3b6d0a6e87661a0452382a330a7dded612
3
+ metadata.gz: 38e6536f54a144f1ca9cfbbf47725f278176cb392ec7a3c7e6e8e1782631a9ce
4
+ data.tar.gz: f4d82c911b950cabfbd87d93e79df8d53a4d7fe938089a7416a331ff2544b22d
5
5
  SHA512:
6
- metadata.gz: f3fe2fe59c757c58dfb8c64a2a14f19eec9b0e6028e5140bc32fdbe22def7f09701da13e4413e5e29d078df03c5e39f4132efd4fc52aeecc84290c3a3a801764
7
- data.tar.gz: f1e46efebdbf69f3ecc098b81ebb8f1a00cf5f213515c1024c142d2bd7c6e10a4cecd2fb7cfdac799ae845a6e23ecfdd9199ed96d7257a46b414636e0f5fb910
6
+ metadata.gz: 5c4e0420c9dc06c9a5133b43ab5a8dee2b9557f5985970955a85e3e2d33da8752d25dc9b73819283abc0c82a72cb9b57d78e89bba67db6737202d786ef68192f
7
+ data.tar.gz: e05dbdfda49c7ba87c088fd63516c485b7e8271d3953b18951f83320d3c7e6b6b54faffef1f3d0c5206b26e11de6b3913e8f6018f18350a7a1f85a6e198dd382
@@ -10,7 +10,7 @@ module Amnesia
10
10
  SIZE_UNITS = %w[ Bytes KB MB GB TB PB EB ]
11
11
 
12
12
  def graph_url(*data)
13
- Gchart.pie(data: data, size: '115x115', bg: 'ffffff00')
13
+ url "/pie?d="+data.join(',')
14
14
  end
15
15
 
16
16
  # https://github.com/rails/rails/blob/fbe335cfe09bf0949edfdf0c4b251f4d081bd5d7/activesupport/lib/active_support/number_helper/number_to_human_size_converter.rb
data/lib/amnesia/host.rb CHANGED
@@ -4,9 +4,16 @@ module Amnesia
4
4
  class Host
5
5
  FLOAT_STATS = %w[ rusage_user rusage_system ]
6
6
  STRING_STATS = %w[ version libevent ]
7
+ DEFAULT_PORT = 11_211
8
+
9
+ def self.normalize_address address
10
+ return "#{address}:#{DEFAULT_PORT}" unless address.include? ":"
11
+
12
+ address
13
+ end
7
14
 
8
15
  def initialize(address)
9
- @address = address
16
+ @address = self.class.normalize_address address
10
17
  end
11
18
 
12
19
  def alive?
@@ -47,10 +47,9 @@ header { margin: 1em 0; }
47
47
  align-items: center;
48
48
  margin: 2em 0;
49
49
  }
50
- .stats-graph img { margin-left: -10px; }
51
50
  .stats-text {
52
51
  flex: 1 1;
53
- margin-left: 1em;
52
+ margin-left: 1.5em;
54
53
  }
55
54
 
56
55
  .graph-indicator { color: #ff9900; }
@@ -6,6 +6,27 @@ module Amnesia
6
6
  haml :index
7
7
  end
8
8
 
9
+ get '/pie' do
10
+ data = params[:d].to_s.split(",").map(&:to_i)
11
+
12
+ r = 25
13
+ c = (2*Math::PI*r).ceil
14
+ v = data.first.to_f / data.last * 100 * c / 100
15
+ v = v.nan? ? 0 : v.ceil
16
+
17
+ content_type "image/svg+xml"
18
+ <<~BODY
19
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"
20
+ style="transform:rotate(-90deg);">
21
+ <circle r="#{r*2}" cx="50" cy="50" fill="#FFEBCC" />
22
+ <circle r="#{r}" cx="50" cy="50"
23
+ fill="transparent" stroke="#FF9901"
24
+ stroke-width="#{r*2}" stroke-dasharray="#{v} #{c}"
25
+ />
26
+ </svg>
27
+ BODY
28
+ end
29
+
9
30
  get '/:address' do
10
31
  @host = find_host params[:address]
11
32
  @host ? haml(:host) : halt(404)
@@ -6,16 +6,16 @@
6
6
 
7
7
  %article.stats
8
8
  %section.stats-graph
9
- %img{src: graph_url(@host.bytes, @host.limit_maxbytes) }
9
+ %img{src: graph_url(@host.bytes, @host.limit_maxbytes), width: 90}
10
10
  %section.stats-text
11
11
  %h3
12
- %span.graph-indicator Used Memory (#{number_to_human_size(@host.bytes)})
13
- \/ Free Memory (#{number_to_human_size(@host.limit_maxbytes)})
14
- %p The cumulative amount of free memory and total memory across all active hosts.
12
+ %span.graph-indicator Used (#{number_to_human_size(@host.bytes)})
13
+ \/ Available Memory (#{number_to_human_size(@host.limit_maxbytes)})
14
+ %p The cumulative amount of available memory across all active hosts.
15
15
 
16
16
  %article.stats
17
17
  %section.stats-graph
18
- %img{src: graph_url(@host.get_hits, @host.get_misses) }
18
+ %img{src: graph_url(@host.get_hits, @host.get_misses), width: 90}
19
19
  %section.stats-text
20
20
  %h3
21
21
  %span.graph-indicator Hit (#{@host.get_hits})
@@ -24,7 +24,7 @@
24
24
 
25
25
  %section.stats
26
26
  %section.stats-graph
27
- %img{src: graph_url(@host.cmd_get, @host.cmd_set) }
27
+ %img{src: graph_url(@host.cmd_get, @host.cmd_set), width: 90}
28
28
  %section.stats-text
29
29
  %h3
30
30
  %span.graph-indicator Read (#{@host.cmd_get})
@@ -1,16 +1,16 @@
1
1
  - if alive_hosts.any?
2
2
  %article.stats
3
3
  %section.stats-graph
4
- %img{src: graph_url(bytes_sum, limit_maxbytes_sum)}
4
+ %img{src: graph_url(bytes_sum, limit_maxbytes_sum), width: 90}
5
5
  %section.stats-text
6
6
  %h3
7
- %span.graph-indicator Used Memory (#{number_to_human_size(bytes_sum)})
8
- \/ Free Memory (#{number_to_human_size(limit_maxbytes_sum)})
9
- %p The cumulative amount of free memory and total memory across all active hosts.
7
+ %span.graph-indicator Used (#{number_to_human_size(bytes_sum)})
8
+ \/ Available Memory (#{number_to_human_size(limit_maxbytes_sum)})
9
+ %p The cumulative amount of available memory across all active hosts.
10
10
 
11
11
  %article.stats
12
12
  %section.stats-graph
13
- %img{src: graph_url(get_hits_sum, get_misses_sum)}
13
+ %img{src: graph_url(get_hits_sum, get_misses_sum), width: 90}
14
14
  %section.stats-text
15
15
  %h3
16
16
  %span.graph-indicator Hit (#{get_hits_sum})
@@ -19,7 +19,7 @@
19
19
 
20
20
  %article.stats
21
21
  %section.stats-graph
22
- %img{src: graph_url(cmd_get_sum, cmd_set_sum)}
22
+ %img{src: graph_url(cmd_get_sum, cmd_set_sum), width: 90}
23
23
  %section.stats-text
24
24
  %h3
25
25
  %span.graph-indicator Read (#{cmd_get_sum})
data/lib/amnesia.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'sinatra/base'
2
- require 'googlecharts'
3
2
  require 'haml'
4
3
  require 'amnesia/authentication'
5
4
  require 'amnesia/helpers'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amnesia
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Schwarz
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-15 00:00:00.000000000 Z
11
+ date: 2022-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: googlecharts
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 1.6.8
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 1.6.8
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: haml
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -116,7 +102,7 @@ files:
116
102
  homepage: http://github.com/benschwarz/amnesia
117
103
  licenses: []
118
104
  metadata: {}
119
- post_install_message:
105
+ post_install_message:
120
106
  rdoc_options: []
121
107
  require_paths:
122
108
  - lib
@@ -132,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
118
  version: '0'
133
119
  requirements: []
134
120
  rubygems_version: 3.0.3
135
- signing_key:
121
+ signing_key:
136
122
  specification_version: 4
137
123
  summary: Amnesia is what you get when you lose your memory
138
124
  test_files: []