This repository has been archived by the owner on Sep 10, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
master script combines changes / mem / commands / connections / users
- Loading branch information
gilles
committed
Jan 5, 2011
1 parent
ffa8d95
commit 8584797
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|