Browse Source

add the rgshow command

Chris Mague 4 years ago
parent
commit
1e13de0cb4
2 changed files with 26 additions and 0 deletions
  1. 12 0
      ansible/files/rgshow.py
  2. 14 0
      ansible/nodes.yml

+ 12 - 0
ansible/files/rgshow.py

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

+ 14 - 0
ansible/nodes.yml

@@ -78,6 +78,11 @@
       pip:
         name: redis
         executable: pip3
+    - name: Install Redis Cluster Python pip
+      pip:
+        name: redis-py-cluster
+        executable: pip3
+
 
   tasks:
     - name: load vars
@@ -160,3 +165,12 @@
         enabled: yes
         state: started
       with_items: "{{ redis_ports }}"
+
+    - name: Show RG script
+      copy:
+        src: rgshow.py
+        dest: /usr/bin/rgshow
+        owner: root
+        group: root
+        mode: "0755"
+      tags: "yo"