App-redis_traffic_stats

 view release on metacpan or  search on metacpan

script/redis-traffic-stats  view on Meta::CPAN

}

sub escape_nonprintable {
    my $s = shift;
    $s =~ s/([^[:print:]])/sprintf('\x{%02X}', ord($1))/eg;
    return $s;
}

sub trim {
    my $s = shift;
    my $len = 70;
    if (length $s > $len) {
        return substr($s,0,$len).'...';
    } else {
        return $s;
    }
}

__END__

=head1 NAME

B<redis-traffic-stats> - Redis query analyzer for counting, traffic stats by command

=head1 SYNOPSIS

B<redis-traffic-stats> -r pcapfile [-n top_n] [-p port]

A) Analyze existing pcap file (RECOMMENDED WAY)

    # 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

B<redis-traffic-stats> [-n top_n] [-p port] [-i device] [-c count_capture] [-t time_capture]

B) Capture packets on demand and analyze it

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

B<redis-traffic-stats> B<-h> | B<--help> | B<-?>

Show detailed usage

=head1 DESCRIPTION

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

The output looks as follows:

=over 4

=item Total network traffic and average of bytes/sec

=item Total number of requests and average and peak of req/sec

=item Top commands of count, percentage, req/sec by count

=item Top commands of network traffic and byte/sec by amount of traffic

=item Top keys for each command show bytes, byte/sec, count, percentage, req/sec

=item Worst slow requests

=back

=head1 OPTIONS

=over 4

=item B<-r> pcapfile:Str, B<--pcapfile> pcapfile:Str

Read existing pcap file instead of on demand packet capturing.

    # tcpdump -s 65535 tcp port 6379 -w redis.pcap -i eth0

=item B<-p> port:Int, B<--port> port:Int

Target port of analyze. Default is 6379.

=item B<-n> top_n:Int, B<--top> top_n:Int

Show top N keys in "Command Detail" section. Default is 10.

=item B<-i> device:Str, B<--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.

=item B<-c> count:Int, B<--count> count:Int

tcpdump will exit after captured number of this option packets. Default is 10000.

=item B<-t> time:Int, B<--time> time:Int

tcpdump will exit after number of this option seconds.

=item B<-d>, B<--debug>

increase debug level.
-d -d more verbosely.

=back

=head1 SEE ALSO

L<https://github.com/hirose31/redis-traffic-stats>

=head1 AUTHOR

HIROSE Masaaki E<lt>hirose31@gmail.comE<gt>

=cut

# for Emacsen
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# cperl-close-paren-offset: -4
# cperl-indent-parens-as-block: t



( run in 2.050 seconds using v1.01-cache-2.11-cpan-99c4e6809bf )