amnesia 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/amnesia/helpers.rb +1 -1
- data/lib/amnesia/host.rb +8 -1
- data/lib/amnesia/public/css/application.css +1 -2
- data/lib/amnesia/routes.rb +21 -0
- data/lib/amnesia/views/host.haml +6 -6
- data/lib/amnesia/views/index.haml +6 -6
- data/lib/amnesia.rb +0 -1
- metadata +5 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38e6536f54a144f1ca9cfbbf47725f278176cb392ec7a3c7e6e8e1782631a9ce
|
4
|
+
data.tar.gz: f4d82c911b950cabfbd87d93e79df8d53a4d7fe938089a7416a331ff2544b22d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c4e0420c9dc06c9a5133b43ab5a8dee2b9557f5985970955a85e3e2d33da8752d25dc9b73819283abc0c82a72cb9b57d78e89bba67db6737202d786ef68192f
|
7
|
+
data.tar.gz: e05dbdfda49c7ba87c088fd63516c485b7e8271d3953b18951f83320d3c7e6b6b54faffef1f3d0c5206b26e11de6b3913e8f6018f18350a7a1f85a6e198dd382
|
data/lib/amnesia/helpers.rb
CHANGED
@@ -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
|
-
|
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?
|
data/lib/amnesia/routes.rb
CHANGED
@@ -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)
|
data/lib/amnesia/views/host.haml
CHANGED
@@ -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
|
13
|
-
\/
|
14
|
-
%p The cumulative amount of
|
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
|
8
|
-
\/
|
9
|
-
%p The cumulative amount of
|
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
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
|
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:
|
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: []
|