Class: RedisMemoryMonitor

Inherits:
Object
  • Object
show all
Defined in:
lib/slugly/redis_memory_monitor.rb

Constant Summary collapse

CMD_REDIS_MEM_CURRENT =
"/usr/local/bin/redis-cli -a $(grep requirepass /etc/redis.conf | cut -d ' ' -f 2) info | grep used_memory: | cut -d : -f 2"
CMD_REDIS_MEM_MAX =
"grep 'maxmemory ' /etc/redis.conf | cut -d ' ' -f 2"
CACHE_TIME =
15

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ RedisMemoryMonitor

Returns a new instance of RedisMemoryMonitor.



8
9
10
11
12
13
# File 'lib/slugly/redis_memory_monitor.rb', line 8

def initialize(options)
  @hostname = options['hostname']
  @username = options['username']
  @alert_percent = options['alert_percent'].to_f
  @last_update = Time.now - 2*CACHE_TIME
end

Instance Method Details

#redis_mem_alertObject



15
16
17
18
# File 'lib/slugly/redis_memory_monitor.rb', line 15

def redis_mem_alert
  update
  @_redis_mem_alert
end

#statusObject



20
21
22
# File 'lib/slugly/redis_memory_monitor.rb', line 20

def status
  redis_mem_alert ? "above" : "below"
end