Skip to content
This repository has been archived by the owner on Sep 10, 2019. It is now read-only.

Commit

Permalink
master script combines changes / mem / commands / connections / users
Browse files Browse the repository at this point in the history
  • Loading branch information
gilles committed Jan 5, 2011
1 parent ffa8d95 commit 8584797
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions redis_
@@ -0,0 +1,47 @@
#! /bin/env ruby

#one script to rule them all

require 'rubygems'
require 'redis'

commands = {'changes_since_last_save' => {:title => 'Redis Total Connections',
:label => 'connections',
:value => 'total_connections_received'},
'memory' => {:title => 'Redis Memory',
:label => 'memory',
:key => 'used_memory'},
'total_commands' => {:title => 'Redis Total Commands',
:label => 'commands',
:key => 'total_connections_received'},
'total_connections' => {:title => 'Redis Total Connections',
:label => 'connections',
:key => 'total_commands_processed'},
'total_users' => {:title => 'Redis Clients',
:label => 'clients',
:key => 'connected_clients'}}

#valid link name, note the ending '_' when no ip or port:
#redis_some_command_
#redis_some_command_1_2_3_4_
#redis_some_command_1_2_3_4_port

$0 =~ /^redis_([^\d]*)_(?:(\d+_\d+_\d+_\d+)_(\d+)?)?$/
cmd, ip, port = $1, $2, $3

ip = ip.nil? ? '127.0.0.1' : ip.gsub!(/_/, '.')
port = port.nil? ? 6379 : port

config = ARGV.any? { |a| a =~ /config/ }
options = commands[cmd]

if config
puts "graph_title #{options[:title]}"
puts "graph_category redis"
puts "connections.label #{options[:label]}"
else
redis = Redis.new(:host => ip, :port => port)
info = redis.info
puts "connections.value" + " " + info[options[:key]].to_s
end

0 comments on commit 8584797

Please sign in to comment.