forked from fsvehla/redis-munin
-
Notifications
You must be signed in to change notification settings - Fork 17
/
redis_memory_
executable file
·40 lines (32 loc) · 1020 Bytes
/
redis_memory_
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env ruby
require 'rubygems'
require 'redis'
require 'yaml'
redis_contructor_info = {}
configFilePath = File.join(File::SEPARATOR,"etc","munin","plugin-conf.d","redis.conf")
if (File.exists?(configFilePath))
redis_constructor_info = YAML.load(File.open(configFilePath))
else
$0 =~ /_(\d+_\d+_\d+_\d+)_(\d+)$/
ip, port = $1, $2
ip = ip.nil? ? '127.0.0.1' : ip.gsub!(/_/, '.')
port = port.nil? ? 6379 : port
redis_constructor_info = { :host => ip, :port => port }
end
config = ARGV.any? { |a| a =~ /config/ }
if config
puts "graph_title Redis Memory"
puts "graph_category redis"
puts "graph_vlabel mem used"
puts "graph_info This graph monitors the commands rate"
puts "graph_args --base 1024 -l 0"
puts "memory.label memory"
puts "memory.info Amount of mem used by redis"
puts "memory.type GAUGE"
puts "memory.min 0"
puts "memory.draw AREA"
else
redis = Redis.new(redis_constructor_info)
info = redis.info
puts "memory.value" + " " + info['used_memory'].to_s
end