--- acct-6.6.1/uid_hash.h	2011-03-17 00:50:13.000000000 +0200
+++ acct-6.6.1_patched/uid_hash.h	2013-03-26 13:26:13.383928636 +0200
@@ -29,5 +29,6 @@ MA 02139, USA.
 #define UID_HASH_H
 
 char *uid_name (int);
+char *gid_name (int);
 
 #endif /* UID_HASH_H */

--- acct-6.6.1/uid_hash.c	2011-03-17 00:50:13.000000000 +0200
+++ acct-6.6.1_patched/uid_hash.c	2013-03-26 13:25:43.367833050 +0200
@@ -8,6 +8,7 @@
 
 #include <stdio.h>
 #include <pwd.h>
+#include <grp.h>
 
 #ifdef HAVE_STRING_H
 #include <string.h>
@@ -21,12 +22,18 @@
 /* globals */
 
 struct hashtab *uid_table = NULL;
+struct hashtab *gid_table = NULL;
 
 struct uid_data
 {
   char *name;			/* name of the user */
 };
 
+struct gid_data
+{
+  char *name;			/* name of the user */
+};
+
 
 /* code */
 
@@ -73,3 +80,44 @@ char *uid_name(int uid)
   struct uid_data *ud = hashtab_get_value(he);
   return ud->name;
 }
+
+char *gid_name(int gid)
+{
+  struct hashtab_elem *he;
+
+  if (gid_table == NULL)
+    gid_table = hashtab_init(sizeof(int));
+
+  he = hashtab_find(gid_table, (void *) &gid, sizeof(gid));
+
+  if (he == NULL)
+    {
+      /* It wasn't there, so add it. */
+      struct group *grp;
+      struct gid_data gd;
+
+      if ((grp = getgrgid(gid)) != NULL)
+      {
+          gd.name = (char *) xmalloc(sizeof (char)* (strlen (grp->gr_name) + 1));
+          (void)strcpy(gd.name, grp->gr_name);
+      }
+      else
+        {
+          int digits = 2, gid_copy = gid;
+
+          /* Count the number of digits we'll need. */
+          for (; gid_copy; digits++, gid_copy /= 10);
+
+          gd.name = (char *) xmalloc (sizeof (char) * digits);
+          (void)sprintf(gd.name, "%d", gid);
+        }
+
+      he = hashtab_create(gid_table, (void *) &gid, sizeof (gid));
+      hashtab_set_value(he, &gd, sizeof (gd));
+    }
+
+  struct gid_data *gd = hashtab_get_value(he);
+  return gd->name;
+}
+
+

--- acct-6.6.1/sa.c	2011-03-17 00:50:13.000000000 +0200
+++ acct-6.6.1_patched/sa.c	2013-03-26 13:44:32.244084603 +0200
@@ -189,6 +189,7 @@ int dont_read_summary_files = 0;
 int print_users = 0;
 int percentages = 0;		/* include percentages in printout */
 int user_summary_flag = 0;	/* are we printing a user summary? */
+int group_summary_flag = 0;	/* are we printing a group summary? */
 int ahz = AHZ;			/* for viewing logs from another system */
 
 
@@ -316,6 +317,7 @@ int main(int argc, char *argv[])
         { "percentages", no_argument, NULL, 14 },
         { "not-interactive", no_argument, NULL, 19 },
         { "user-summary", no_argument, NULL, 20 },
+        { "group-summary", no_argument, NULL, 30 },
         { "reverse-sort", no_argument, NULL, 21 },
         { "merge", no_argument, NULL, 22 },
         { "threshold", required_argument, NULL, 23 },
@@ -501,6 +503,10 @@ int main(int argc, char *argv[])
         case 20:
           user_summary_flag = 1;
           break;
+        case 30:
+          user_summary_flag = 1;
+          group_summary_flag = 1;
+          break;
         case 'r':
         case 21:
           reverse_sort = 1;
@@ -563,13 +569,13 @@ int main(int argc, char *argv[])
 
   if (print_users && (merge_files || user_summary_flag))
     {
-      (void)printf("%s: can't specify `--merge' or `--user-summary' with `--print-users'\n", program_name);
+      (void)printf("%s: can't specify `--merge' or `--user-summary' or `--group-summary' with `--print-users'\n", program_name);
       exit(EXIT_FAILURE);
     }
 
   if (merge_files && user_summary_flag)
     {
-      (void)printf("%s: can't specify `--user-summary' with `--merge'\n",
+      (void)printf("%s: can't specify `--user-summary' or `--group-summary' with `--merge'\n",
                    program_name);
       exit(EXIT_FAILURE);
     }
@@ -701,7 +707,7 @@ give_usage (void)
 #if defined(HAVE_ACUTIME) && defined(HAVE_ACSTIME) && defined(HAVE_ACETIME)
                " [--print-ratio]"
 #endif
-               " [--print-users] [--merge] [--user-summary]\n\
+               " [--print-users] [--merge] [--user-summary] [--group-summary]\n\
                 [--list-all-names] [--not-interactive] [--threshold <num>]\n\
                 "
 #if defined(HAVE_ACSTIME) && defined(HAVE_ACUTIME) && defined(HAVE_ACMEM)
@@ -1211,7 +1217,7 @@ void parse_acct_entries (void)
                   " %6.0f io"
 #endif
                   " %-*.*s%s\n",
-                  uid_name (rec->ac_uid),
+                  (!group_summary_flag) ? uid_name (rec->ac_uid) : gid_name (rec->ac_gid),
 #if defined(HAVE_ACUTIME) && defined(HAVE_ACSTIME)
                   ut + st,
 #endif
@@ -1254,7 +1260,7 @@ void parse_acct_entries (void)
             update_command_list (rec->ac_comm, &s, (rec->ac_flag & AFORK));
 
           if (NEED_USRACCT_INFO)
-            update_user_list (uid_name (rec->ac_uid), &s);
+            update_user_list ((!group_summary_flag) ? uid_name (rec->ac_uid) : gid_name (rec->ac_gid), &s);
 
           update_totals (&s);
         }
