forked from fsvehla/redis-munin
-
Notifications
You must be signed in to change notification settings - Fork 17
/
redis_users_
executable file
·36 lines (29 loc) · 939 Bytes
/
redis_users_
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
#!/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 Clients"
puts "graph_category redis"
puts "graph_vlabel connections/s"
puts "graph_info This graph monitors the number of clients"
puts "clients.label clients"
puts "clients.type GAUGE"
puts "clients.min 0"
else
redis = Redis.new(redis_constructor_info)
info = redis.info
puts "clients.value" + " " + (info['connected_clients'].to_i - 1).to_s
end