redisniffer
Version, currently 0.5.04 versions
- 0.5.0latestMar 30, 2017
- 0.4.0not indexedMay 22, 2020
- 0.3.4not indexedMay 22, 2020
- 0.3.3not indexedMay 22, 2020
github.com/maiha/redisniffer
Sniff redis packets and summarize count of commands
3 stars
0 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
redisniffer:
github: maiha/redisniffer
version: ~> 0.5.0Then run:
shards installshard.yml
- Crystal
- no constraint declared
- License
- MIT
- Author
- maiha
- Target
redisnifferfrom src/redisniffer.cr
Dependencies
Runtime Dependencies
- app0.3.6github: maiha/app.cr
- pcap0.2.7github: maiha/pcap.cr
- similar_logs0.1.0github: maiha/similar_logs.cr
- redis-cluster0.7.6github: maiha/redis-cluster.cr
README
redisniffer 
Sniff redis packets and summarize count of commands.
- x86_64 binary: https://github.com/maiha/redisniffer/releases
Usage
Needs root user or privilege to the device.
% redisniffer
listening on lo about '(tcp port 6379)' (snaplen: 1500, timeout: 1000)
output: Stdout
[6379, {"PING" => 1}, nil]
[6379, {"GET" => 1}, nil]
Options
-p 6379,7001,7002: capture port--deny MONITOR,PING: these cmds are not stored in stats--include-ip: stores client ip addresses too-o redis://localhost:6379: write stats into redis-o file://cmds.log: write stats into file
See redisniffer --help for more options
Redis output
-o option enables you to store stats in redis.
% redisniffer -i eth0 -p 6379 -o redis://localhost:6000 --out-interval 60
This watches 6379 port on eth0 and writes stats into redis(port=6000) as ZSET every minute.
redis:6000
Three ZSET entries related to the time will be updated.
- "6379/20170322"
- "6379/2017032217"
- "6379/201703221737"
Thus, we can easily get cmd stats by ZRANGE about three kind of time-series.
# want to know top 3 commands at 20170322 on port 6379
% redis-cli -p 6000 ZREVRANGE "6379/20170322" 0 2 WITHSCORES
1) "DEL"
2) "174"
3) "SET"
4) "86"
5) "SADD"
6) "68"
NOTES
- time-series are hard-coded. (daily, hourly, every minute)
- ttl is hard-coded. (4.weeks, 3.days, 3.hours)
- key format is "{PORT}/{TIME}" in default. (
--out-cmd-keyoption overrides it)- where
{PORT}and{TIME}are reserved words those will be replaced with runtime values.
- where
see: src/data/redis_flusher.cr
Roadmap
- [x] file output
- [x] use pipeline in storing into redis
- [x] store client ip address into redis
- [x] write tests
Development
- crystal: 0.21.1
- needs
libpcap - type
make
Contributing
- Fork it ( https://github.com/maiha/redisniffer.cr/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- maiha maiha - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.5.0- Tagged
- Mar 30, 2017
- Commit
90ca902f321b- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/maiha/redisniffer
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 4