BSD 3 development
[unix-history] / usr / src / cmd / sa.c
index a24e40c..0b0e05b 100644 (file)
@@ -5,7 +5,7 @@
 
 /* interpret command time accounting */
 
 
 /* interpret command time accounting */
 
-#define        size    1000
+#define        size    2500
 #define        NC      sizeof(acctbuf.ac_comm)
 struct acct acctbuf;
 int    lflg;
 #define        NC      sizeof(acctbuf.ac_comm)
 struct acct acctbuf;
 int    lflg;
@@ -28,7 +28,7 @@ struct        user {
        int     ncomm;
        int     fill;
        float   fctime;
        int     ncomm;
        int     fill;
        float   fctime;
-} user[256];
+} user[1000];
 
 struct tab {
        char    name[NC];
 
 struct tab {
        char    name[NC];
@@ -189,6 +189,7 @@ char **argv;
                }
                fwrite((char *)tab, sizeof(tab[0]), k, ff);
                fclose(ff);
                }
                fwrite((char *)tab, sizeof(tab[0]), k, ff);
                fclose(ff);
+               creat("/usr/adm/acct", 0644);
                signal(SIGINT, SIG_DFL);
        }
 /*
                signal(SIGINT, SIG_DFL);
        }
 /*
@@ -206,7 +207,7 @@ char **argv;
        if (tab[i].name[0]) {
                ft = tab[i].count;
                column(ft, tab[i].realt, tab[i].cput, tab[i].syst);
        if (tab[i].name[0]) {
                ft = tab[i].count;
                column(ft, tab[i].realt, tab[i].cput, tab[i].syst);
-               printf("   %.10s\n", tab[i].name);
+               printf("   %.14s\n", tab[i].name);
        }
 }
 
        }
 }
 
@@ -227,7 +228,7 @@ printmoney()
                                *cp = 0;
                                printf("%-8s", buf);
                        }
                                *cp = 0;
                                printf("%-8s", buf);
                        }
-                       printf("%5u %7.2f\n",
+                       printf("%7u %9.2f\n",
                            user[i].ncomm, user[i].fctime/60);
                }
        }
                            user[i].ncomm, user[i].fctime/60);
                }
        }
@@ -237,11 +238,11 @@ column(n, a, b, c)
 double n, a, b, c;
 {
 
 double n, a, b, c;
 {
 
-       printf("%6.0f", n);
+       printf("%8.0f", n);
        if(cflg) {
                if(n == ncom)
        if(cflg) {
                if(n == ncom)
-                       printf("%7s", ""); else
-                       printf("%6.2f%%", 100.*n/ncom);
+                       printf("%9s", ""); else
+                       printf("%8.2f%%", 100.*n/ncom);
        }
        col(n, a, treal);
        if (oflg)
        }
        col(n, a, treal);
        if (oflg)
@@ -252,7 +253,7 @@ double n, a, b, c;
        } else
                col(n, b+c, tcpu+tsys);
        if(tflg)
        } else
                col(n, b+c, tcpu+tsys);
        if(tflg)
-               printf("%6.1f", a/(b+c));
+               printf("%8.1f", a/(b+c));
 }
 
 col(n, a, m)
 }
 
 col(n, a, m)
@@ -260,12 +261,12 @@ double n, a, m;
 {
 
        if(jflg)
 {
 
        if(jflg)
-               printf("%9.2f", a/(n*60.)); else
-               printf("%9.2f", a/3600.);
+               printf("%11.2f", a/(n*60.)); else
+               printf("%11.2f", a/3600.);
        if(cflg) {
                if(a == m)
        if(cflg) {
                if(a == m)
-                       printf("%7s", ""); else
-                       printf("%6.2f%%", 100.*a/m);
+                       printf("%9s", ""); else
+                       printf("%8.2f%%", 100.*a/m);
        }
 }
 
        }
 }
 
@@ -308,7 +309,7 @@ char *f;
                }
                x = expand(fbuf.ac_utime) + expand(fbuf.ac_stime);
                if (uflg) {
                }
                x = expand(fbuf.ac_utime) + expand(fbuf.ac_stime);
                if (uflg) {
-                       printf("%3d%6.1f %.10s\n", fbuf.ac_uid&0377, x/60.0,
+                       printf("%3d%6.1f %.14s\n", fbuf.ac_uid&0377, x/60.0,
                           fbuf.ac_comm);
                        continue;
                }
                           fbuf.ac_comm);
                        continue;
                }
@@ -457,7 +458,7 @@ strip()
        j = enter("**junk**");
        for (i = 0; i<size; i++) {
                if (tab[i].name[0] && tab[i].count<=thres) {
        j = enter("**junk**");
        for (i = 0; i<size; i++) {
                if (tab[i].name[0] && tab[i].count<=thres) {
-                       printf("%.10s--", tab[i].name);
+                       printf("%.14s--", tab[i].name);
                        if ((c=getchar())=='y') {
                                tab[i].name[0] = '\0';
                                tab[j].count += tab[i].count;
                        if ((c=getchar())=='y') {
                                tab[i].name[0] = '\0';
                                tab[j].count += tab[i].count;