2
0
Эх сурвалжийг харах

initial version for command moni

- retrieve a list of statistics with a periodic refresh
Daniel-Constantin Mierla 8 жил өмнө
parent
commit
f8306f69a8

+ 37 - 0
kamcli/commands/cmd_moni.py

@@ -0,0 +1,37 @@
+import os
+import time
+import click
+from kamcli.cli import pass_context
+from kamcli.iorpc import command_ctl
+
+
+##
+#
+#
[email protected]('moni', short_help='Monitor relevant statistics')
[email protected]('norefresh', '--no-refresh', is_flag=True,
+            help='Do not refresh (execute once)')
+
+@pass_context
+def cli(ctx, norefresh):
+    """Monitor relevant statistics on display
+
+    \b
+    Parameters:
+        - --no-refresh - execute once
+    Monitored statistics:
+        tm, sl and usrloc
+    """
+
+    clear = lambda : os.system('tput reset')
+    count = 0
+    if norefresh is True:
+        command_ctl(ctx, 'stats.get_statistics', [ "tm:", "sl:", "usrloc:" ])
+    else:
+        while True:
+            count = count + 1
+            command_ctl(ctx, 'stats.get_statistics', [ "tmx:", "sl:", "usrloc:" ])
+            print "[cycle #: " + str(count) + "; if constant make sure server is running]"
+            time.sleep(2)
+            clear()
+