Skip to content

Commit

Permalink
Added real-time Redis analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
Hifumi committed Mar 30, 2022
1 parent ffbb611 commit 284b762
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

<img src="assets/redis.png">

RediSea is a Redis (in-memory database) communication framework used for viewing Redis keys, dumping Redis keys, dumping key information about the Redis server, and much more!
RediSea is a Redis (in-memory database) communication framework used for viewing Redis keys, dumping Redis keys, dumping key information about the Redis server, real-time Redis database analysis, and much more!

## Usage
```bash
python3 main.py
$ python3 main.py
```
46 changes: 44 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-

import redis, time, sys, os
import redis, time, sys, os, platform, argparse

from subprocess import getoutput
from prettytable import PrettyTable

r = redis.Redis()
version = '0.1.26'
version = '0.2.28'
author = 'Hifumi1337'

class RediSea:
Expand All @@ -26,6 +27,44 @@ def banner(self):
Start by typing "h" in the prompt below
""".format(author, version))

def real_time_render(self):

parser = argparse.ArgumentParser()
parser.add_argument('-s', '--start_server', help="Choose specific keys to investigate in real-time", action='store_true', default=True, required=False)
args = parser.parse_args()

def clear():
if platform.system() == "Windows":
os.system("cls")
else:
os.system("clear")

timer = 0

if args.start_server:

print("Example: key1 key2 key3")
user_keys = input("Enter Search Criteria (seperated by spaces): ")

key_list = user_keys.split()

while True:
time.sleep(0.1) # 100ms
clear()

state_header = PrettyTable(["Keys", "Values"])

for key_stuff in key_list:
state_value = r.mget(key_stuff)
state_header.add_row([key_stuff, state_value])

print(state_header.get_string(title="Real Time Redis Data"))

timer += 100

print("\nTime Elapsed: {0}ms".format(timer))
print("\nYou can exit out by pressing Ctrl + C")

def redis_comms(self):

Expand All @@ -51,6 +90,7 @@ def redis_comms(self):
print("b, banner Displays our cool banner!")
print("i, info Return general information about the Redis instance")
print("r, remote Remotely connect to a Redis instance")
print("rt, realtime View Redis data update in real-time")
elif command == "q" or command == "quit":
print("Disconnecting...")
time.sleep(0.5)
Expand Down Expand Up @@ -95,6 +135,8 @@ def redis_comms(self):
print("Exiting...")
else:
print("Please choose y/n")
elif command == "rt" or command == "realtime":
RediSea().real_time_render()
else:
print("? Unrecognized Command ?")

Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
redis
redis
prettytable

0 comments on commit 284b762

Please sign in to comment.