rgshow.py 460 B

123456789101112
  1. #! /usr/bin/env python3
  2. from rediscluster import RedisCluster
  3. startup_nodes = [{"host": "127.0.0.1", "port": "19901"}]
  4. rc = RedisCluster(startup_nodes=startup_nodes, decode_responses=True)
  5. slots = rc.cluster_slots()
  6. print("%5s - %-5s %-15s %7s %s" %("start", "end", "IP", "Port", "Replicas"))
  7. for slot in sorted(slots):
  8. print("%5d - %5d %-15s %7d %d" %(slot[0], slot[1], slots[slot]['master'][0], slots[slot]['master'][1], len(slots[slot]['slaves'])))