Class: Riemann::Tools::Valkey
- Inherits:
-
Object
- Object
- Riemann::Tools::Valkey
- Includes:
- Riemann::Tools
- Defined in:
- lib/riemann/tools/valkey.rb,
lib/riemann/tools/valkey/version.rb
Constant Summary collapse
- VERSION =
"1.0.0"
Instance Attribute Summary collapse
-
#redis ⇒ Object
readonly
Returns the value of attribute redis.
Instance Method Summary collapse
-
#initialize ⇒ Valkey
constructor
A new instance of Valkey.
- #memory_state(metric) ⇒ Object
- #tick ⇒ Object
Constructor Details
#initialize ⇒ Valkey
Returns a new instance of Valkey.
14 15 16 |
# File 'lib/riemann/tools/valkey.rb', line 14 def initialize @redis = Redis.new end |
Instance Attribute Details
#redis ⇒ Object (readonly)
Returns the value of attribute redis.
12 13 14 |
# File 'lib/riemann/tools/valkey.rb', line 12 def redis @redis end |
Instance Method Details
#memory_state(metric) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/riemann/tools/valkey.rb', line 33 def memory_state(metric) if metric > 0.95 "critical" elsif metric > 0.8 "warning" else "ok" end end |
#tick ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/riemann/tools/valkey.rb', line 18 def tick redis = Redis.new memory_info = redis.info("MEMORY") used_memory = memory_info["used_memory"].to_i maxmemory = memory_info["maxmemory"].to_i memory_usage = used_memory.to_f / maxmemory report({ service: "valkey memory", metric: memory_usage, state: memory_state(memory_usage), description: format("%.2f %%", memory_usage * 100) }) end |