• Stars
    star
    162
  • Rank 230,962 (Top 5 %)
  • Language
    Perl
  • License
    Other
  • Created over 10 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Redis query analyzer for counting, traffic stats by command

redis-traffic-stats

redis-traffic-stats is a query analyzer for Redis.

redis-traffic-stats shows following statistics:

  • Total network traffic and average of byte/sec
  • Total number of requests and average and peak of req/sec
  • Top commands of count, percentage, req/sec by count
  • Top commands of network traffic and byte/sec by amount of traffic
  • Top keys for each command show bytes, byte/sec, count, percentage, req/sec
  • Worst slow requests

redis-traffic-stats uses not MONITOR Redis command but pcap file (tcpdump -w) as data source, so:

SAMPLE USAGE

Capture TCP packets by tcpdump:

# tcpdump -s 65535 tcp port 6379 -w redis.pcap -i eth0
(wait for a while and stop by ^C)

and run redis-traffic-stats:

$ redis-traffic-stats -r redis.pcap

or redis-traffic-stats can capture packets internally (using tcpdump):

(Capture 5000 packets)
# redis-traffic-stats -i eth0 -c 5000
    
(Capture for 10 sec)
# redis-traffic-stats -i eth0 -t 10

The output looks as follows:

# redis-traffic-stats

## Summary

* Duration:
    * 2014-02-24 16:34:10 - 2014-02-24 16:34:13 (3s)
* Total Traffic:
    * 43311772 bytes (14437257.33 bytes/sec)
* Total Requests:
    * 110109 requests (Avg 36703.00 req/sec, Peak 47170.00 req/sec)

## Top Commands

### By count
Command          | Count  | Pct    | Req/sec 
-----------------|-------:|-------:|---------:
LRANGE           |  39423 |  35.80 | 13141.00
PING             |  18367 |  16.68 |  6122.33
LPUSH            |  12553 |  11.40 |  4184.33
...

### By traffic
Command          | Bytes     | Byte/sec    
-----------------|----------:|-------------:
LRANGE           |  43089000 |  14363000.00
PING             |     73468 |     24489.33
LPUSH            |     62765 |     20921.67
...

## Command Detail

### LRANGE
...

### LPUSH
...

### INCR
Key                       | Bytes     | Byte/sec     | Count  | Pct    | Req/sec 
--------------------------|----------:|-------------:|-------:|-------:|---------:
counter:rand:000000000061 |       327 |       109.00 |    109 |   1.28 |    36.33
counter:rand:000000000054 |       315 |       105.00 |    105 |   1.23 |    35.00
counter:rand:000000000096 |       309 |       103.00 |    103 |   1.21 |    34.33
...

### GET
Key                       | Bytes     | Byte/sec     | Count  | Pct    | Req/sec 
--------------------------|----------:|-------------:|-------:|-------:|---------:
foo:rand:000000000084     |       321 |       107.00 |    107 |   1.34 |    35.67
foo:rand:000000000004     |       303 |       101.00 |    101 |   1.26 |    33.67
foo:rand:000000000061     |       303 |       101.00 |    101 |   1.26 |    33.67
...

## Slow Commands

Time   | Command                                                               
------:|------------------------------------------------------------------------
 0.759 | LRANGE mylist 0 599                                                   
 0.759 | LRANGE mylist 0 599                                                   
 0.759 | LRANGE mylist 0 599                                                   
...

Yes! Output of redis-traffic-stats is GitHub Flavored Markdown! We can get more pretty visual by copy and paste to Gist (sample output: https://gist.github.com/hirose31/9207096) or something supports GFM.

SYNOPSIS

  • Analyze existing pcap file ( RECOMMENDED WAY )
    redis-traffic-stats -r pcapfile [-n top_n] [-p port]
    Example:
# tcpdump -s 65535 tcp port 6379 -w redis.pcap -i eth0
(wait for a while and stop by ^C)
$ redis-traffic-stats -r redis.pcap

NOTICE: You MUST NOT use -i any because Net::Pcap cannot parse that pcap data

  • Capture packets on demand and analyze it
    redis-traffic-stats [-n top_n] [-p port] [-i device] [-c count_capture] [-t time_capture]
    Example:
(Capture 5000 packets)
# redis-traffic-stats -i eth0 -c 5000

(Capture for 10 sec)
# redis-traffic-stats -i eth0 -t 10
  • Show detailed usage
    redis-traffic-stats -h | --help | -?

OPTIONS

  • -r pcapfile:Str, --pcapfile pcapfile:Str
    Read existing pcap file instead of on demand packet capturing.
# tcpdump -s 65535 tcp port 6379 -w redis.pcap -i eth0
  • -p port:Int, --port port:Int
    Target port of analyze. Default is 6379.

  • -n top_n:Int, --top top_n:Int
    Show top N keys in "Command Detail" section. Default is 10.

  • -i device:Str, --device device:Str
    Network interface name used by -i option of tcpdump. Default is no -i option (lowest numbered interface excluding loopback device).
    This option has a point only in on demand packet capture mode.

  • -c count:Int, --count count:Int
    tcpdump will exit after captured number of this option packets. Default is 10000.

  • -t time:Int, --time time:Int
    tcpdump will exit after number of this option seconds.

  • -d, --debug
    increase debug level. -d -d more verbosely.

  • -k, --key-normalize-regexp Replace parts of key to '*' with regexp.

INSTALLATION

QUICK TRIAL for CentOS 6

If you are on CentOS 6, you can try redis-traffic-stats downloading single binary file.

curl -o redis-traffic-stats https://dl.dropboxusercontent.com/u/9824/redis-traffic-stats/centos6
chmod +x redis-traffic-stats

This binary file is just for trial. I highly recommend to install following installation if you will use redis-traffic-stats on a daily basis.

RECOMMENDED INSTALLATION

Install from CPAN using cpanm command:

cpanm App::redis_traffic_stats

If you don't have cpanm command:

curl -L http://cpanmin.us | perl - App::redis_traffic_stats

or clone this repository and install:

git clone https://github.com/hirose31/redis-traffic-stats.git
cd redis-traffic-stats/
perl Build.PL
./Build
./Build test
./Build install

More Repositories

1

s3surfer

Go
82
star
2

pinger

Go
56
star
3

doumeki

photo uploader bridge for Eye-Fi that uploads into multi photo storage services
Perl
21
star
4

teeny-nagios

Teeny web interface for Nagios with smartphone(iPhone, Android)
PHP
20
star
5

inspect-perl-proc

get %INC and dump into file
Perl
17
star
6

AWS-CLIWrapper

Perl
16
star
7

ganglia-pymodule_skeleton

skeleton code for python module of Ganglia
Python
16
star
8

ap-mod_bumpy_life

mod_bumpy_life is Apache 2.2 module for setting randam value to MaxRequestsPerChild.
C
15
star
9

connexion-tiny-petstore

Python
15
star
10

vboxss

Utility tool for managing snapshot of VirtualBox easily
Go
13
star
11

cdbtoroute53

Convert a TinyDNS CDB, or the differences between two TinyDNS CDBs, to Amazon Route 53 ChangeResourceRecordSetsRequest XML.
Perl
13
star
12

send-dns-notify

send DNS NOTIFY message
Perl
12
star
13

munin-apcupsd

munin plugin to monitor APC UPS via apcupsd by apcaccess
Perl
12
star
14

chase-tail

Perl
11
star
15

shared-memory-size

display shared memory size by CoW
Perl
8
star
16

p5-InfluxDB

Perl client library for InfluxDB
Perl
8
star
17

monitor-aws-status

checks AWS service health dashboard periodically and notifies us a new problem by IRC
Perl
7
star
18

memcached-tiny-benchmark-suite

tiny benchmark suite for memcached
C
7
star
19

chef-provider-service-daemontools

Chef's provider to manage service under daemontools.
Ruby
7
star
20

p5-net-ip-match-trie

C++
7
star
21

www-cybozu-office6

Perl module for manipulating Cybozu Office 6
Perl
6
star
22

IO-File-AtomicChange

Perl
5
star
23

mod_hidek

double seijin-siki
C
5
star
24

observe-file

do arbitrary command when observed files have changed
Shell
5
star
25

Net-SSL-ExpireDate

Perl
5
star
26

ganglia-gmetric-xs

C
5
star
27

Sys-PageCache

Perl
5
star
28

ganglia-pymodule_traffic1

Python
5
star
29

nagios-check_memcached_paranoid

Nagios plugin for checking memcached; result of request sequentially: SET, GET, DELETE, GET
C
5
star
30

Plack-Middleware-MemoryUsage

Perl
4
star
31

monitor-latency

store result of ping command (% of packet loss and RTT) in rrd file
4
star
32

list-installed-perl-modules

list up installed Perl modules
Perl
4
star
33

socket-pooling

socket pooling daemon (PoC)
Perl
4
star
34

Plack-Middleware-Pictogram-MobileJp

Perl
4
star
35

p5-bot-ikcbot-pluggable

Perl
3
star
36

sandbox

test! test! test!
HTML
3
star
37

cidr-manager

3
star
38

Net-Google-Spreadsheets-V4

Perl
3
star
39

ganglia-pymodule_apache_status

sends metrics on Apache process status
Python
3
star
40

net-amazon-propertyext

added interface to retrieve BrowseNodes data
Perl
2
star
41

hirose31.github.com

2
star
42

lv

C
2
star
43

hatena-bookmark-display-others

fork http://d.hatena.ne.jp/Sybian/20071213/p1
JavaScript
2
star
44

nagios-check_snmp-regexwarn

add feature that returns WARNING state if matched regex to check_snmp. like -r(-R) option.
C
2
star
45

p5-Gallery-Remote2

Perl
1
star
46

check-mixed-charenc

Perl
1
star
47

xfusen

C
1
star
48

nagios-check_mailq_tooold

1
star
49

ringbuffer

Go
1
star
50

sandbox-py

Python
1
star
51

sar2graph

Perl
1
star
52

CPUTemperature

Display temperature of CPU on your Mac OS X's status bar
Ruby
1
star
53

perl-Text-LBSV

Text::LBSV - Labeled Bell Separated Value manipulator
Perl
1
star
54

nagios-check_memcached_connections

C
1
star
55

go-remove-slowly

Makefile
1
star
56

monitor-elb-address

Perl
1
star
57

MySQL-GrantParser

parse SHOW GRANTS and return as hash reference
Perl
1
star
58

monitor-ping

health check a large number of hosts by ping (ICMP) so quickly
1
star
59

galloc

galloc - Gachapin alloc
C
1
star
60

mysql-grantparser-python

Python
1
star