Răsfoiți Sursa

cmd_acc: added report for top dst

Daniel-Constantin Mierla 11 luni în urmă
părinte
comite
3cd4845835
1 a modificat fișierele cu 9 adăugiri și 3 ștergeri
  1. 9 3
      kamcli/commands/cmd_acc.py

+ 9 - 3
kamcli/commands/cmd_acc.py

@@ -524,12 +524,18 @@ def acc_report(ctx, oformat, ostyle, limit, interval, name):
 
     \b
     Parameters:
-        <name> - name of the report (top-src)
+        <name> - name of the report:
+            - top-src: most active callers
+            - top-dst: most active callees
     """
     e = create_engine(ctx.gconfig.get("db", "rwurl"))
     ctx.vlog("Showing accounting report: " + name)
 
-    query = "SELECT `src_user`, count(*) AS `count` FROM acc"
+    userfield = "src_user"
+    if name == "top-dst":
+        userfield = "dst_user"
+
+    query = "SELECT `" + userfield + "`, count(*) AS `count` FROM acc"
 
     if interval > 0:
         query = (
@@ -539,7 +545,7 @@ def acc_report(ctx, oformat, ostyle, limit, interval, name):
             )
         )
 
-    query = query + " GROUP BY `src_user` ORDER BY count DESC"
+    query = query + " GROUP BY `" + userfield + "` ORDER BY count DESC"
 
     if limit > 0:
         query = query + " LIMIT {0}".format(limit)