static char *sccsid
= "@(#)sa.c 4.1 (Berkeley) %G%";
/* interpret command time accounting */
#define NC sizeof(acctbuf.ac_comm)
extern tcmp(), ncmp(), bcmp(), dcmp(), Dcmp(), kcmp(), Kcmp();
for(i
=1; argv
[0][i
]; i
++)
if(tab
[i
].name
[j
] == '?')
junkp
= enter("***other");
tab
[junkp
].count
+= tab
[i
].count
;
tab
[junkp
].realt
+= tab
[i
].realt
;
tab
[junkp
].cput
+= tab
[i
].cput
;
tab
[junkp
].syst
+= tab
[i
].syst
;
tab
[junkp
].imem
+= tab
[i
].imem
;
tab
[junkp
].io
+= tab
[i
].io
;
if ((ff
= fopen("/usr/adm/usracct", "w")) != NULL
) {
fwrite((char *)user
, sizeof(user
), 1, ff
);
if ((ff
= fopen("/usr/adm/savacct", "w")) == NULL
) {
fwrite((char *)tab
, sizeof(tab
[0]), k
, ff
);
creat("/usr/adm/acct", 0644);
qsort(tab
, k
, sizeof(tab
[0]), cmp
);
column(ncom
, treal
, tcpu
, tsys
, timem
, tio
);
column(ft
, tab
[i
].realt
, tab
[i
].cput
, tab
[i
].syst
, tab
[i
].imem
, tab
[i
].io
);
printf(" %.14s\n", tab
[i
].name
);
for (i
=0; i
<sizeof(user
)/sizeof(user
[0]); i
++) {
if (user
[i
].us_cnt
&& user
[i
].us_ctime
) {
printf("%7u %9.2fcpu %10.0ftio %12.0fk*sec\n",
user
[i
].us_cnt
, user
[i
].us_ctime
/60,
user
[i
].us_imem
/ (60 * 2));
printf("%8.2f%%", 100.*n
/ncom
);
col(n
, 3600*(b
/(b
+c
)), tcpu
+tsys
, "u/s");
col(n
, b
+c
, tcpu
+tsys
, "cp");
printf("%8.1f", a
/(b
+c
), "re/cp");
printf("%10.0favio", e
/(n
?n
:1));
printf("%10.0fk", d
/(2*((b
+c
)!=0.0?(b
+c
):1.0)));
printf("%10.0fk*sec", d
/(2*60));
printf("%11.2f%s", a
/(n
*60.), cp
); else
printf("%11.2f%s", a
/3600., cp
);
printf("%8.2f%%", 100.*a
/m
);
printf("Only 1 file with -s\n");
if ((ff
= fopen(f
, "r"))==NULL
) {
printf("Can't open %s\n", f
);
while (fread((char *)&fbuf
, sizeof(fbuf
), 1, ff
) == 1) {
if (fbuf
.ac_comm
[0]==0) {
for (cp
= fbuf
.ac_comm
; cp
< &fbuf
.ac_comm
[NC
]; cp
++) {
if (c
&& (c
< ' ' || c
>= 0200)) {
if (fbuf
.ac_flag
&AFORK
) {
for (cp
=fbuf
.ac_comm
; cp
< &fbuf
.ac_comm
[NC
]; cp
++)
x
= expand(fbuf
.ac_utime
) + expand(fbuf
.ac_stime
);
printf("%3d%6.1fcp %6dmem %6dio %.14s\n",
fbuf
.ac_uid
, x
/60.0, y
, z
,
user
[c
].us_ctime
+= x
/60.;
user
[c
].us_imem
+= x
* y
;
x
= expand(fbuf
.ac_etime
)*60;
x
= expand(fbuf
.ac_utime
);
x
= expand(fbuf
.ac_stime
);
if(p1
->count
== p2
->count
)
return(p1
->count
- p2
->count
);
return(p2
->count
- p1
->count
);
if (p1
->imem
< p2
->imem
) {
if (p1
->imem
> p2
->imem
) {
a1
= p1
->imem
/ ((p1
->cput
+p1
->syst
)?(p1
->cput
+p1
->syst
):1);
a2
= p2
->imem
/ ((p2
->cput
+p2
->syst
)?(p2
->cput
+p2
->syst
):1);
a1
= p1
->io
/ (p1
->count
?p1
->count
:1);
a2
= p2
->io
/ (p2
->count
?p2
->count
:1);
if ((f
= fopen("/usr/adm/savacct", "r")) == NULL
)
while (fread((char *)&tbuf
, sizeof(tbuf
), 1, f
) == 1) {
tab
[i
].count
= tbuf
.count
;
tab
[i
].realt
= tbuf
.realt
;
if ((f
= fopen("/usr/adm/usracct", "r")) == NULL
)
fread((char *)user
, sizeof(user
), 1, f
);
for (i
%=size
; tab
[i
].name
[0]; i
= (i
+1)%size
) {
if (tab
[i
].name
[j
]!=np
[j
])
for (i
= 0; i
<size
; i
++) {
if (tab
[i
].name
[0] && tab
[i
].count
<=thres
) {
printf("%.14s--", tab
[i
].name
);
if ((c
=getchar())=='y') {
tab
[j
].count
+= tab
[i
].count
;
tab
[j
].realt
+= tab
[i
].realt
;
tab
[j
].cput
+= tab
[i
].cput
;
tab
[j
].syst
+= tab
[i
].syst
;
#define NMAX sizeof (utmp.ut_name)
char names
[NUID
][NMAX
+1];
register struct passwd
*pw
;
struct passwd
*getpwent();
while (pw
= getpwent()) {
if (names
[pw
->pw_uid
][0])
strncpy(names
[pw
->pw_uid
], pw
->pw_name
, NMAX
);