forked from fsvehla/redis-munin
-
Notifications
You must be signed in to change notification settings - Fork 17
/
redis_commands_
executable file
·49 lines (38 loc) · 1.22 KB
/
redis_commands_
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
41
42
43
44
45
46
47
48
49
#!/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_order commands hits misses"
puts "graph_title Redis Commands rate"
puts "graph_category redis"
puts "graph_vlabel commands/s"
puts "graph_info This graph monitors the commands rate"
puts "commands.label commands/s"
puts "commands.type COUNTER"
puts "commands.min 0"
puts "hits.label cache hits"
puts "hits.type COUNTER"
puts "hits.min 0"
puts "misses.label cache misses"
puts "misses.type COUNTER"
puts "misses.min 0"
else
redis = Redis.new(redis_constructor_info)
info = redis.info
puts "commands.value" + " " + info['total_commands_processed'].to_s
puts "hits.value #{info['keyspace_hits']}"
puts "misses.value #{info['keyspace_misses']}"
end