serverlog: capture request count in repo-totals scripts
authorGregory Szorc <gps@mozilla.com>
Thu, 19 Mar 2015 18:11:29 -0700
changeset 360618 672c05c1db2db77d87eb52eff53cd6cc05b0a08b
parent 360617 4cf797566c54b52d8d6f363a8b333fc1bfe2bcba
child 360619 916cedf97b59d26c8078a0628eab51549ed54aa6
push id16998
push userrwood@mozilla.com
push dateMon, 02 May 2016 19:42:03 +0000
serverlog: capture request count in repo-totals scripts
hgext/serverlog/scripts/aggregate-repo-totals-by-day.py
hgext/serverlog/scripts/repo-totals-by-day.py
hgext/serverlog/scripts/repo-totals-by-hour.py
--- a/hgext/serverlog/scripts/aggregate-repo-totals-by-day.py
+++ b/hgext/serverlog/scripts/aggregate-repo-totals-by-day.py
@@ -7,31 +7,34 @@ from optparse import OptionParser
 import sys
 
 def aggregate(fh, min_size=0):
     entries = {}
 
     for line in fh:
         parts = line.rstrip().split()
 
-        when, repo, size, t_wall, t_cpu = parts
+        when, repo, count, size, t_wall, t_cpu = parts
+        count = int(count)
         size = int(size)
         t_wall = float(t_wall)
         t_cpu = float(t_cpu)
 
-        totals = entries.setdefault((when, repo), [0, 0.0, 0.0])
-        totals[0] += size
-        totals[1] += t_wall
-        totals[2] += t_cpu
+        totals = entries.setdefault((when, repo), [0, 0, 0.0, 0.0])
+        totals[0] += count
+        totals[1] += size
+        totals[2] += t_wall
+        totals[3] += t_cpu
 
     for (date, repo), totals in sorted(entries.items()):
-        if min_size and totals[0] < min_size:
+        if min_size and totals[1] < min_size:
             continue
 
-        print('%s\t%s\t%d\t%d\t%d' % (date, repo, totals[0], totals[1], totals[2]))
+        print('%s\t%s\t%d\t%d\t%d\t%d' % (date, repo, totals[0], totals[1],
+                                          totals[2], totals[3]))
 
 if __name__ == '__main__':
     parser = OptionParser()
     parser.add_option('--min-size', type=int, default=0,
             help='Filter entries with transfer size less than this amount')
 
     options, args = parser.parse_args()
 
--- a/hgext/serverlog/scripts/repo-totals-by-day.py
+++ b/hgext/serverlog/scripts/repo-totals-by-day.py
@@ -20,20 +20,22 @@ def totals_by_day(fh):
 
         size = int(size)
         t_wall = float(t_wall)
         t_cpu = float(t_cpu)
 
         date = when.date()
 
         repos = days.setdefault(date, {})
-        totals = repos.setdefault(repo, [0, 0.0, 0.0])
-        totals[0] += size
-        totals[1] += t_wall
-        totals[2] += t_cpu
+        totals = repos.setdefault(repo, [0, 0, 0.0, 0.0])
+        totals[0] += 1
+        totals[1] += size
+        totals[2] += t_wall
+        totals[3] += t_cpu
 
     for date, repos in sorted(days.items()):
         for repo, totals in sorted(repos.items()):
-            print('%s\t%s\t%d\t%d\t%d' % (
-                date.isoformat(), repo, totals[0], totals[1], totals[2]))
+            print('%s\t%s\t%d\t%d\t%d\t%d' % (date.isoformat(), repo,
+                                              totals[0], totals[1], totals[2],
+                                              totals[3]))
 
 if __name__ == '__main__':
     totals_by_day(sys.stdin)
--- a/hgext/serverlog/scripts/repo-totals-by-hour.py
+++ b/hgext/serverlog/scripts/repo-totals-by-hour.py
@@ -21,20 +21,21 @@ def totals_by_hour(fh):
         size = int(size)
         t_wall = float(t_wall)
         t_cpu = float(t_cpu)
 
         t = when.time().replace(minute=0, second=0, microsecond=0)
         when = when.combine(when.date(), t)
 
         repos = hours.setdefault(when, {})
-        totals = repos.setdefault(repo, [0, 0.0, 0.0])
-        totals[0] += size
-        totals[1] += t_wall
-        totals[2] += t_cpu
+        totals = repos.setdefault(repo, [0, 0, 0.0, 0.0])
+        totals[0] += 1
+        totals[1] += size
+        totals[2] += t_wall
+        totals[3] += t_cpu
 
     for date, repos in sorted(hours.items()):
         for repo, totals in sorted(repos.items()):
-            print('%s\t%s\t%d\t%d\t%d' % (
-                date.isoformat(), repo, totals[0], totals[1], totals[2]))
+            print('%s\t%s\t%d\t%d\t%d\t%d' % (date.isoformat(), repo, totals[0],
+                                              totals[1], totals[2], totals[3]))
 
 if __name__ == '__main__':
     totals_by_hour(sys.stdin)