17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate * with the License.
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate * and limitations under the License.
137c478bd9Sstevel@tonic-gate *
147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate *
207c478bd9Sstevel@tonic-gate * CDDL HEADER END
217c478bd9Sstevel@tonic-gate */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
287c478bd9Sstevel@tonic-gate /* All Rights Reserved */
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate
31*414388d7Ssl108498 #pragma ident "%Z%%M% %I% %E% SMI"
327c478bd9Sstevel@tonic-gate
337c478bd9Sstevel@tonic-gate #include <time.h>
347c478bd9Sstevel@tonic-gate #include <string.h>
357c478bd9Sstevel@tonic-gate #include <stdio.h>
367c478bd9Sstevel@tonic-gate #include <sys/types.h>
377c478bd9Sstevel@tonic-gate #include <sys/param.h>
387c478bd9Sstevel@tonic-gate #include "acctdef.h"
397c478bd9Sstevel@tonic-gate #include <grp.h>
407c478bd9Sstevel@tonic-gate #include <sys/acct.h>
417c478bd9Sstevel@tonic-gate #include <pwd.h>
427c478bd9Sstevel@tonic-gate #include <sys/stat.h>
437c478bd9Sstevel@tonic-gate #include <locale.h>
44*414388d7Ssl108498 #include <stdlib.h>
45*414388d7Ssl108498 #include <libgen.h>
467c478bd9Sstevel@tonic-gate
477c478bd9Sstevel@tonic-gate struct acct ab;
487c478bd9Sstevel@tonic-gate char command_name[16];
497c478bd9Sstevel@tonic-gate char obuf[BUFSIZ];
507c478bd9Sstevel@tonic-gate static char time_buf[50];
517c478bd9Sstevel@tonic-gate
527c478bd9Sstevel@tonic-gate double cpucut,
537c478bd9Sstevel@tonic-gate syscut,
547c478bd9Sstevel@tonic-gate hogcut,
557c478bd9Sstevel@tonic-gate iocut,
567c478bd9Sstevel@tonic-gate realtot,
577c478bd9Sstevel@tonic-gate cputot,
587c478bd9Sstevel@tonic-gate usertot,
597c478bd9Sstevel@tonic-gate systot,
607c478bd9Sstevel@tonic-gate kcoretot,
617c478bd9Sstevel@tonic-gate iotot,
627c478bd9Sstevel@tonic-gate rwtot;
637c478bd9Sstevel@tonic-gate extern long timezone;
647c478bd9Sstevel@tonic-gate extern int daylight; /* daylight savings time if set */
657c478bd9Sstevel@tonic-gate long daydiff,
667c478bd9Sstevel@tonic-gate offset = -2,
677c478bd9Sstevel@tonic-gate cmdcount;
687c478bd9Sstevel@tonic-gate ulong_t elapsed,
697c478bd9Sstevel@tonic-gate sys,
707c478bd9Sstevel@tonic-gate user,
717c478bd9Sstevel@tonic-gate cpu,
727c478bd9Sstevel@tonic-gate io,
737c478bd9Sstevel@tonic-gate rw,
747c478bd9Sstevel@tonic-gate mem,
757c478bd9Sstevel@tonic-gate etime;
767c478bd9Sstevel@tonic-gate time_t tstrt_b,
777c478bd9Sstevel@tonic-gate tstrt_a,
787c478bd9Sstevel@tonic-gate tend_b,
797c478bd9Sstevel@tonic-gate tend_a;
807c478bd9Sstevel@tonic-gate int backward,
817c478bd9Sstevel@tonic-gate flag_field,
827c478bd9Sstevel@tonic-gate average,
837c478bd9Sstevel@tonic-gate quiet,
847c478bd9Sstevel@tonic-gate option,
857c478bd9Sstevel@tonic-gate verbose = 1,
867c478bd9Sstevel@tonic-gate uidflag,
877c478bd9Sstevel@tonic-gate gidflag,
887c478bd9Sstevel@tonic-gate unkid, /*user doesn't have login on this machine*/
897c478bd9Sstevel@tonic-gate errflg,
907c478bd9Sstevel@tonic-gate su_user,
917c478bd9Sstevel@tonic-gate fileout = 0,
927c478bd9Sstevel@tonic-gate stdinflg,
937c478bd9Sstevel@tonic-gate nfiles;
947c478bd9Sstevel@tonic-gate static int eflg = 0,
957c478bd9Sstevel@tonic-gate Eflg = 0,
967c478bd9Sstevel@tonic-gate sflg = 0,
977c478bd9Sstevel@tonic-gate Sflg = 0;
987c478bd9Sstevel@tonic-gate #ifdef uts
997c478bd9Sstevel@tonic-gate dev_t linedev = 0xffff; /* changed from -1, as dev_t is now ushort */
1007c478bd9Sstevel@tonic-gate #else
1017c478bd9Sstevel@tonic-gate dev_t linedev = (dev_t)-1;
1027c478bd9Sstevel@tonic-gate #endif
1037c478bd9Sstevel@tonic-gate uid_t uidval;
1047c478bd9Sstevel@tonic-gate gid_t gidval;
1057c478bd9Sstevel@tonic-gate char *cname = NULL; /* command name pattern to match*/
1067c478bd9Sstevel@tonic-gate
1077c478bd9Sstevel@tonic-gate struct passwd *getpwnam(), *getpwuid(), *pw;
1087c478bd9Sstevel@tonic-gate struct group *getgrnam(),*grp;
1097c478bd9Sstevel@tonic-gate long convtime();
1107c478bd9Sstevel@tonic-gate
1117c478bd9Sstevel@tonic-gate #ifdef uts
1127c478bd9Sstevel@tonic-gate float expand();
1137c478bd9Sstevel@tonic-gate #else
1147c478bd9Sstevel@tonic-gate ulong_t expand();
1157c478bd9Sstevel@tonic-gate #endif
1167c478bd9Sstevel@tonic-gate
1177c478bd9Sstevel@tonic-gate char *ofile,
1187c478bd9Sstevel@tonic-gate *devtolin(),
1197c478bd9Sstevel@tonic-gate *uidtonam();
1207c478bd9Sstevel@tonic-gate dev_t lintodev();
121*414388d7Ssl108498
122*414388d7Ssl108498 void dofile(char *);
123*414388d7Ssl108498 void doexit(int) __NORETURN;
124*414388d7Ssl108498 void usage(void);
125*414388d7Ssl108498 void fatal(char *, char *);
126*414388d7Ssl108498 void println(void);
127*414388d7Ssl108498 void printhd(void);
128*414388d7Ssl108498 char *cmset(char *);
129*414388d7Ssl108498
1307c478bd9Sstevel@tonic-gate FILE *ostrm;
1317c478bd9Sstevel@tonic-gate
132*414388d7Ssl108498 int
main(int argc,char ** argv)133*414388d7Ssl108498 main(int argc, char **argv)
1347c478bd9Sstevel@tonic-gate {
135*414388d7Ssl108498 int c;
1367c478bd9Sstevel@tonic-gate
1377c478bd9Sstevel@tonic-gate (void)setlocale(LC_ALL, "");
1387c478bd9Sstevel@tonic-gate setbuf(stdout,obuf);
1397c478bd9Sstevel@tonic-gate while((c = getopt(argc, argv,
1407c478bd9Sstevel@tonic-gate "C:E:H:I:O:S:abe:fg:hikl:mn:o:qrs:tu:v")) != EOF) {
1417c478bd9Sstevel@tonic-gate switch(c) {
1427c478bd9Sstevel@tonic-gate case 'C':
1437c478bd9Sstevel@tonic-gate sscanf(optarg,"%lf",&cpucut);
1447c478bd9Sstevel@tonic-gate continue;
1457c478bd9Sstevel@tonic-gate case 'O':
1467c478bd9Sstevel@tonic-gate sscanf(optarg,"%lf",&syscut);
1477c478bd9Sstevel@tonic-gate continue;
1487c478bd9Sstevel@tonic-gate case 'H':
1497c478bd9Sstevel@tonic-gate sscanf(optarg,"%lf",&hogcut);
1507c478bd9Sstevel@tonic-gate continue;
1517c478bd9Sstevel@tonic-gate case 'I':
1527c478bd9Sstevel@tonic-gate sscanf(optarg,"%lf",&iocut);
1537c478bd9Sstevel@tonic-gate continue;
1547c478bd9Sstevel@tonic-gate case 'a':
1557c478bd9Sstevel@tonic-gate average++;
1567c478bd9Sstevel@tonic-gate continue;
1577c478bd9Sstevel@tonic-gate case 'b':
1587c478bd9Sstevel@tonic-gate backward++;
1597c478bd9Sstevel@tonic-gate continue;
1607c478bd9Sstevel@tonic-gate case 'g':
1617c478bd9Sstevel@tonic-gate if(sscanf(optarg,"%ld",&gidval) == 1) {
1627c478bd9Sstevel@tonic-gate if (getgrgid(gidval) == NULL)
1637c478bd9Sstevel@tonic-gate fatal("Unknown group", optarg);
1647c478bd9Sstevel@tonic-gate } else if((grp=getgrnam(optarg)) == NULL)
1657c478bd9Sstevel@tonic-gate fatal("Unknown group", optarg);
1667c478bd9Sstevel@tonic-gate else
1677c478bd9Sstevel@tonic-gate gidval=grp->gr_gid;
1687c478bd9Sstevel@tonic-gate gidflag++;
1697c478bd9Sstevel@tonic-gate continue;
1707c478bd9Sstevel@tonic-gate case 'h':
1717c478bd9Sstevel@tonic-gate option |= HOGFACTOR;
1727c478bd9Sstevel@tonic-gate continue;
1737c478bd9Sstevel@tonic-gate case 'i':
1747c478bd9Sstevel@tonic-gate option |= IORW;
1757c478bd9Sstevel@tonic-gate continue;
1767c478bd9Sstevel@tonic-gate case 'k':
1777c478bd9Sstevel@tonic-gate option |= KCOREMIN;
1787c478bd9Sstevel@tonic-gate continue;
1797c478bd9Sstevel@tonic-gate case 'm':
1807c478bd9Sstevel@tonic-gate option |= MEANSIZE;
1817c478bd9Sstevel@tonic-gate continue;
1827c478bd9Sstevel@tonic-gate case 'n':
183*414388d7Ssl108498 cname=cmset(optarg);
1847c478bd9Sstevel@tonic-gate continue;
1857c478bd9Sstevel@tonic-gate case 't':
1867c478bd9Sstevel@tonic-gate option |= SEPTIME;
1877c478bd9Sstevel@tonic-gate continue;
1887c478bd9Sstevel@tonic-gate case 'r':
1897c478bd9Sstevel@tonic-gate option |= CPUFACTOR;
1907c478bd9Sstevel@tonic-gate continue;
1917c478bd9Sstevel@tonic-gate case 'v':
1927c478bd9Sstevel@tonic-gate verbose=0;
1937c478bd9Sstevel@tonic-gate continue;
1947c478bd9Sstevel@tonic-gate case 'l':
1957c478bd9Sstevel@tonic-gate linedev = lintodev(optarg);
1967c478bd9Sstevel@tonic-gate continue;
1977c478bd9Sstevel@tonic-gate case 'u':
1987c478bd9Sstevel@tonic-gate if(*optarg == '?') {
1997c478bd9Sstevel@tonic-gate unkid++;
2007c478bd9Sstevel@tonic-gate continue;
2017c478bd9Sstevel@tonic-gate }
2027c478bd9Sstevel@tonic-gate if(*optarg == '#') {
2037c478bd9Sstevel@tonic-gate su_user++;
2047c478bd9Sstevel@tonic-gate uidval = 0;
2057c478bd9Sstevel@tonic-gate uidflag++;
2067c478bd9Sstevel@tonic-gate continue;
2077c478bd9Sstevel@tonic-gate }
2087c478bd9Sstevel@tonic-gate if((pw = getpwnam(optarg)) == NULL) {
2097c478bd9Sstevel@tonic-gate uidval = (uid_t)atoi(optarg);
2107c478bd9Sstevel@tonic-gate /* atoi will return 0 in abnormal situation */
2117c478bd9Sstevel@tonic-gate if (uidval == 0 && strcmp(optarg, "0") != 0) {
2127c478bd9Sstevel@tonic-gate fprintf(stderr, "%s: Unknown user %s\n", argv[0], optarg);
2137c478bd9Sstevel@tonic-gate exit(1);
2147c478bd9Sstevel@tonic-gate }
2157c478bd9Sstevel@tonic-gate if ((pw = getpwuid(uidval)) == NULL) {
2167c478bd9Sstevel@tonic-gate fprintf(stderr, "%s: Unknown user %s\n", argv[0], optarg);
2177c478bd9Sstevel@tonic-gate exit(1);
2187c478bd9Sstevel@tonic-gate }
2197c478bd9Sstevel@tonic-gate uidflag++;
2207c478bd9Sstevel@tonic-gate } else {
2217c478bd9Sstevel@tonic-gate uidval = pw->pw_uid;
2227c478bd9Sstevel@tonic-gate uidflag++;
2237c478bd9Sstevel@tonic-gate }
2247c478bd9Sstevel@tonic-gate continue;
2257c478bd9Sstevel@tonic-gate case 'q':
2267c478bd9Sstevel@tonic-gate quiet++;
2277c478bd9Sstevel@tonic-gate verbose=0;
2287c478bd9Sstevel@tonic-gate average++;
2297c478bd9Sstevel@tonic-gate continue;
2307c478bd9Sstevel@tonic-gate case 's':
2317c478bd9Sstevel@tonic-gate sflg = 1;
2327c478bd9Sstevel@tonic-gate tend_a = convtime(optarg);
2337c478bd9Sstevel@tonic-gate continue;
2347c478bd9Sstevel@tonic-gate case 'S':
2357c478bd9Sstevel@tonic-gate Sflg = 1;
2367c478bd9Sstevel@tonic-gate tstrt_a = convtime(optarg);
2377c478bd9Sstevel@tonic-gate continue;
2387c478bd9Sstevel@tonic-gate case 'f':
2397c478bd9Sstevel@tonic-gate flag_field++;
2407c478bd9Sstevel@tonic-gate continue;
2417c478bd9Sstevel@tonic-gate case 'e':
2427c478bd9Sstevel@tonic-gate eflg = 1;
2437c478bd9Sstevel@tonic-gate tstrt_b = convtime(optarg);
2447c478bd9Sstevel@tonic-gate continue;
2457c478bd9Sstevel@tonic-gate case 'E':
2467c478bd9Sstevel@tonic-gate Eflg = 1;
2477c478bd9Sstevel@tonic-gate tend_b = convtime(optarg);
2487c478bd9Sstevel@tonic-gate continue;
2497c478bd9Sstevel@tonic-gate case 'o':
2507c478bd9Sstevel@tonic-gate ofile = optarg;
2517c478bd9Sstevel@tonic-gate fileout++;
2527c478bd9Sstevel@tonic-gate if((ostrm = fopen(ofile, "w")) == NULL) {
2537c478bd9Sstevel@tonic-gate perror("open error on output file");
2547c478bd9Sstevel@tonic-gate errflg++;
2557c478bd9Sstevel@tonic-gate }
2567c478bd9Sstevel@tonic-gate continue;
2577c478bd9Sstevel@tonic-gate case '?':
2587c478bd9Sstevel@tonic-gate errflg++;
2597c478bd9Sstevel@tonic-gate continue;
2607c478bd9Sstevel@tonic-gate }
2617c478bd9Sstevel@tonic-gate }
2627c478bd9Sstevel@tonic-gate
2637c478bd9Sstevel@tonic-gate if(errflg) {
2647c478bd9Sstevel@tonic-gate usage();
2657c478bd9Sstevel@tonic-gate exit(1);
2667c478bd9Sstevel@tonic-gate }
2677c478bd9Sstevel@tonic-gate
2687c478bd9Sstevel@tonic-gate
2697c478bd9Sstevel@tonic-gate argv = &argv[optind];
2707c478bd9Sstevel@tonic-gate while(optind++ < argc) {
2717c478bd9Sstevel@tonic-gate dofile(*argv++); /* change from *argv */
2727c478bd9Sstevel@tonic-gate nfiles++;
2737c478bd9Sstevel@tonic-gate }
2747c478bd9Sstevel@tonic-gate
2757c478bd9Sstevel@tonic-gate if(nfiles==0) {
2767c478bd9Sstevel@tonic-gate if(isatty(0) || isdevnull())
2777c478bd9Sstevel@tonic-gate dofile(PACCT);
2787c478bd9Sstevel@tonic-gate else {
2797c478bd9Sstevel@tonic-gate stdinflg = 1;
2807c478bd9Sstevel@tonic-gate backward = offset = 0;
2817c478bd9Sstevel@tonic-gate dofile(NULL);
2827c478bd9Sstevel@tonic-gate }
2837c478bd9Sstevel@tonic-gate }
2847c478bd9Sstevel@tonic-gate doexit(0);
285*414388d7Ssl108498 /* NOTREACHED */
2867c478bd9Sstevel@tonic-gate }
2877c478bd9Sstevel@tonic-gate
288*414388d7Ssl108498 void
dofile(char * fname)289*414388d7Ssl108498 dofile(char *fname)
2907c478bd9Sstevel@tonic-gate {
291*414388d7Ssl108498 struct acct *a = &ab;
2927c478bd9Sstevel@tonic-gate struct tm *t;
2937c478bd9Sstevel@tonic-gate time_t curtime;
2947c478bd9Sstevel@tonic-gate time_t ts_a = 0,
2957c478bd9Sstevel@tonic-gate ts_b = 0,
2967c478bd9Sstevel@tonic-gate te_a = 0,
2977c478bd9Sstevel@tonic-gate te_b = 0;
2987c478bd9Sstevel@tonic-gate long daystart;
2997c478bd9Sstevel@tonic-gate long nsize;
3007c478bd9Sstevel@tonic-gate int ver; /* version of acct structure */
3017c478bd9Sstevel@tonic-gate int dst_secs; /* number of seconds to adjust
3027c478bd9Sstevel@tonic-gate for daylight savings time */
3037c478bd9Sstevel@tonic-gate
3047c478bd9Sstevel@tonic-gate if(fname != NULL)
3057c478bd9Sstevel@tonic-gate if(freopen(fname, "r", stdin) == NULL) {
3067c478bd9Sstevel@tonic-gate fprintf(stderr, "acctcom: cannot open %s\n", fname);
3077c478bd9Sstevel@tonic-gate return;
3087c478bd9Sstevel@tonic-gate }
3097c478bd9Sstevel@tonic-gate
3107c478bd9Sstevel@tonic-gate if (fread((char *)&ab, sizeof(struct acct), 1, stdin) != 1)
3117c478bd9Sstevel@tonic-gate return;
3127c478bd9Sstevel@tonic-gate else if (ab.ac_flag & AEXPND)
3137c478bd9Sstevel@tonic-gate ver = 2; /* 4.0 acct structure */
3147c478bd9Sstevel@tonic-gate else
3157c478bd9Sstevel@tonic-gate ver = 1; /* 3.x acct structure */
3167c478bd9Sstevel@tonic-gate
3177c478bd9Sstevel@tonic-gate rewind(stdin);
3187c478bd9Sstevel@tonic-gate
3197c478bd9Sstevel@tonic-gate
3207c478bd9Sstevel@tonic-gate if(backward) {
3217c478bd9Sstevel@tonic-gate if (ver == 2)
3227c478bd9Sstevel@tonic-gate nsize = sizeof(struct acct); /* make sure offset is signed */
3237c478bd9Sstevel@tonic-gate else
3247c478bd9Sstevel@tonic-gate nsize = sizeof(struct o_acct); /* make sure offset is signed */
3257c478bd9Sstevel@tonic-gate fseek(stdin, (long)(-nsize), 2);
3267c478bd9Sstevel@tonic-gate }
3277c478bd9Sstevel@tonic-gate tzset();
3287c478bd9Sstevel@tonic-gate daydiff = a->ac_btime - (a->ac_btime % SECSINDAY);
3297c478bd9Sstevel@tonic-gate time(&curtime);
3307c478bd9Sstevel@tonic-gate t = localtime(&curtime);
3317c478bd9Sstevel@tonic-gate if (daydiff < (curtime - (curtime % SECSINDAY))) {
3327c478bd9Sstevel@tonic-gate time_t t;
3337c478bd9Sstevel@tonic-gate /*
3347c478bd9Sstevel@tonic-gate * it is older than today
3357c478bd9Sstevel@tonic-gate */
3367c478bd9Sstevel@tonic-gate t = (time_t)a->ac_btime;
3377c478bd9Sstevel@tonic-gate cftime(time_buf, DATE_FMT, &t);
3387c478bd9Sstevel@tonic-gate fprintf(stdout, "\nACCOUNTING RECORDS FROM: %s", time_buf);
3397c478bd9Sstevel@tonic-gate }
3407c478bd9Sstevel@tonic-gate
3417c478bd9Sstevel@tonic-gate /* adjust time by one hour for daylight savings time */
3427c478bd9Sstevel@tonic-gate if (daylight && t->tm_isdst != 0)
3437c478bd9Sstevel@tonic-gate dst_secs = 3600;
3447c478bd9Sstevel@tonic-gate else
3457c478bd9Sstevel@tonic-gate dst_secs = 0;
3467c478bd9Sstevel@tonic-gate daystart = (a->ac_btime - timezone + dst_secs) -
3477c478bd9Sstevel@tonic-gate ((a->ac_btime - timezone + dst_secs) % SECSINDAY);
3487c478bd9Sstevel@tonic-gate if (Sflg) {
3497c478bd9Sstevel@tonic-gate ts_a = tstrt_a + daystart - dst_secs;
3507c478bd9Sstevel@tonic-gate cftime(time_buf, DATE_FMT, &ts_a);
3517c478bd9Sstevel@tonic-gate fprintf(stdout, "START AFT: %s", time_buf);
3527c478bd9Sstevel@tonic-gate }
3537c478bd9Sstevel@tonic-gate if (eflg) {
3547c478bd9Sstevel@tonic-gate ts_b = tstrt_b + daystart - dst_secs;
3557c478bd9Sstevel@tonic-gate cftime(time_buf, DATE_FMT, &ts_b);
3567c478bd9Sstevel@tonic-gate fprintf(stdout, "START BEF: %s", time_buf);
3577c478bd9Sstevel@tonic-gate }
3587c478bd9Sstevel@tonic-gate if (sflg) {
3597c478bd9Sstevel@tonic-gate te_a = tend_a + daystart - dst_secs;
3607c478bd9Sstevel@tonic-gate cftime(time_buf, DATE_FMT, &te_a);
3617c478bd9Sstevel@tonic-gate fprintf(stdout, "END AFTER: %s", time_buf);
3627c478bd9Sstevel@tonic-gate }
3637c478bd9Sstevel@tonic-gate if (Eflg) {
3647c478bd9Sstevel@tonic-gate te_b = tend_b + daystart - dst_secs;
3657c478bd9Sstevel@tonic-gate cftime(time_buf, DATE_FMT, &te_b);
3667c478bd9Sstevel@tonic-gate fprintf(stdout, "END BEFOR: %s", time_buf);
3677c478bd9Sstevel@tonic-gate }
3687c478bd9Sstevel@tonic-gate if(ts_a) {
3697c478bd9Sstevel@tonic-gate if (te_b && ts_a > te_b) te_b += SECSINDAY;
3707c478bd9Sstevel@tonic-gate }
3717c478bd9Sstevel@tonic-gate
3727c478bd9Sstevel@tonic-gate while(aread(ver) != 0) {
3737c478bd9Sstevel@tonic-gate elapsed = expand(a->ac_etime);
3747c478bd9Sstevel@tonic-gate etime = (ulong_t)a->ac_btime + (ulong_t)SECS(elapsed);
3757c478bd9Sstevel@tonic-gate if(ts_a || ts_b || te_a || te_b) {
3767c478bd9Sstevel@tonic-gate
3777c478bd9Sstevel@tonic-gate if(te_a && (etime < te_a)) {
3787c478bd9Sstevel@tonic-gate if(backward) return;
3797c478bd9Sstevel@tonic-gate else continue;
3807c478bd9Sstevel@tonic-gate }
3817c478bd9Sstevel@tonic-gate if(te_b && (etime > te_b)) {
3827c478bd9Sstevel@tonic-gate if(backward) continue;
3837c478bd9Sstevel@tonic-gate else return;
3847c478bd9Sstevel@tonic-gate }
3857c478bd9Sstevel@tonic-gate if(ts_a && (a->ac_btime < ts_a))
3867c478bd9Sstevel@tonic-gate continue;
3877c478bd9Sstevel@tonic-gate if(ts_b && (a->ac_btime > ts_b))
3887c478bd9Sstevel@tonic-gate continue;
3897c478bd9Sstevel@tonic-gate }
3907c478bd9Sstevel@tonic-gate if(!MYKIND(a->ac_flag))
3917c478bd9Sstevel@tonic-gate continue;
3927c478bd9Sstevel@tonic-gate if(su_user && !SU(a->ac_flag))
3937c478bd9Sstevel@tonic-gate continue;
3947c478bd9Sstevel@tonic-gate sys = expand(a->ac_stime);
3957c478bd9Sstevel@tonic-gate user = expand(a->ac_utime);
3967c478bd9Sstevel@tonic-gate cpu = sys + user;
3977c478bd9Sstevel@tonic-gate if(cpu == 0)
3987c478bd9Sstevel@tonic-gate cpu = 1;
3997c478bd9Sstevel@tonic-gate mem = expand(a->ac_mem);
4007c478bd9Sstevel@tonic-gate (void) strncpy(command_name, a->ac_comm, 8);
4017c478bd9Sstevel@tonic-gate io=expand(a->ac_io);
4027c478bd9Sstevel@tonic-gate rw=expand(a->ac_rw);
4037c478bd9Sstevel@tonic-gate if(cpucut && cpucut >= SECS(cpu))
4047c478bd9Sstevel@tonic-gate continue;
4057c478bd9Sstevel@tonic-gate if(syscut && syscut >= SECS(sys))
4067c478bd9Sstevel@tonic-gate continue;
4077c478bd9Sstevel@tonic-gate #ifdef uts
4087c478bd9Sstevel@tonic-gate if(linedev != 0xffff && a->ac_tty != linedev)
4097c478bd9Sstevel@tonic-gate continue;
4107c478bd9Sstevel@tonic-gate #else
4117c478bd9Sstevel@tonic-gate if(linedev != (dev_t)-1 && a->ac_tty != linedev)
4127c478bd9Sstevel@tonic-gate continue;
4137c478bd9Sstevel@tonic-gate #endif
4147c478bd9Sstevel@tonic-gate if(uidflag && a->ac_uid != uidval)
4157c478bd9Sstevel@tonic-gate continue;
4167c478bd9Sstevel@tonic-gate if(gidflag && a->ac_gid != gidval)
4177c478bd9Sstevel@tonic-gate continue;
4187c478bd9Sstevel@tonic-gate if(cname && !cmatch(a->ac_comm,cname))
4197c478bd9Sstevel@tonic-gate continue;
4207c478bd9Sstevel@tonic-gate if(iocut && iocut > io)
4217c478bd9Sstevel@tonic-gate continue;
4227c478bd9Sstevel@tonic-gate if(unkid && uidtonam(a->ac_uid)[0] != '?')
4237c478bd9Sstevel@tonic-gate continue;
4247c478bd9Sstevel@tonic-gate if(verbose && (fileout == 0)) {
4257c478bd9Sstevel@tonic-gate printhd();
4267c478bd9Sstevel@tonic-gate verbose = 0;
4277c478bd9Sstevel@tonic-gate }
4287c478bd9Sstevel@tonic-gate if(elapsed == 0)
4297c478bd9Sstevel@tonic-gate elapsed++;
4307c478bd9Sstevel@tonic-gate if(hogcut && hogcut >= (double)cpu/(double)elapsed)
4317c478bd9Sstevel@tonic-gate continue;
4327c478bd9Sstevel@tonic-gate if(fileout)
4337c478bd9Sstevel@tonic-gate fwrite(&ab, sizeof(ab), 1, ostrm);
4347c478bd9Sstevel@tonic-gate else
4357c478bd9Sstevel@tonic-gate println();
4367c478bd9Sstevel@tonic-gate if(average) {
4377c478bd9Sstevel@tonic-gate cmdcount++;
4387c478bd9Sstevel@tonic-gate realtot += (double)elapsed;
4397c478bd9Sstevel@tonic-gate usertot += (double)user;
4407c478bd9Sstevel@tonic-gate systot += (double)sys;
4417c478bd9Sstevel@tonic-gate kcoretot += (double)mem;
4427c478bd9Sstevel@tonic-gate iotot += (double)io;
4437c478bd9Sstevel@tonic-gate rwtot += (double)rw;
4447c478bd9Sstevel@tonic-gate };
4457c478bd9Sstevel@tonic-gate }
4467c478bd9Sstevel@tonic-gate }
4477c478bd9Sstevel@tonic-gate
448*414388d7Ssl108498 int
aread(int ver)449*414388d7Ssl108498 aread(int ver)
4507c478bd9Sstevel@tonic-gate {
451*414388d7Ssl108498 static int ok = 1;
4527c478bd9Sstevel@tonic-gate struct o_acct oab;
4537c478bd9Sstevel@tonic-gate int ret;
4547c478bd9Sstevel@tonic-gate
4557c478bd9Sstevel@tonic-gate if (ver != 2) {
4567c478bd9Sstevel@tonic-gate if ((ret = fread((char *)&oab, sizeof(struct o_acct), 1, stdin)) == 1){
4577c478bd9Sstevel@tonic-gate /* copy SVR3 acct struct to SVR4 acct struct */
4587c478bd9Sstevel@tonic-gate ab.ac_flag = oab.ac_flag | AEXPND;
4597c478bd9Sstevel@tonic-gate ab.ac_stat = oab.ac_stat;
4607c478bd9Sstevel@tonic-gate ab.ac_uid = (uid_t) oab.ac_uid;
4617c478bd9Sstevel@tonic-gate ab.ac_gid = (gid_t) oab.ac_gid;
4627c478bd9Sstevel@tonic-gate ab.ac_tty = (dev_t) oab.ac_tty;
4637c478bd9Sstevel@tonic-gate ab.ac_btime = oab.ac_btime;
4647c478bd9Sstevel@tonic-gate ab.ac_utime = oab.ac_utime;
4657c478bd9Sstevel@tonic-gate ab.ac_stime = oab.ac_stime;
4667c478bd9Sstevel@tonic-gate ab.ac_mem = oab.ac_mem;
4677c478bd9Sstevel@tonic-gate ab.ac_io = oab.ac_io;
4687c478bd9Sstevel@tonic-gate ab.ac_rw = oab.ac_rw;
4697c478bd9Sstevel@tonic-gate strcpy(ab.ac_comm, oab.ac_comm);
4707c478bd9Sstevel@tonic-gate }
4717c478bd9Sstevel@tonic-gate } else
4727c478bd9Sstevel@tonic-gate ret = fread((char *)&ab, sizeof(struct acct), 1, stdin);
4737c478bd9Sstevel@tonic-gate
4747c478bd9Sstevel@tonic-gate
4757c478bd9Sstevel@tonic-gate if(backward) {
4767c478bd9Sstevel@tonic-gate if(ok) {
4777c478bd9Sstevel@tonic-gate if(fseek(stdin,
4787c478bd9Sstevel@tonic-gate (long)(offset*(ver == 2 ? sizeof(struct acct) :
4797c478bd9Sstevel@tonic-gate sizeof(struct o_acct))), 1) != 0) {
4807c478bd9Sstevel@tonic-gate
4817c478bd9Sstevel@tonic-gate rewind(stdin); /* get 1st record */
4827c478bd9Sstevel@tonic-gate ok = 0;
4837c478bd9Sstevel@tonic-gate }
4847c478bd9Sstevel@tonic-gate } else
4857c478bd9Sstevel@tonic-gate ret = 0;
4867c478bd9Sstevel@tonic-gate }
4877c478bd9Sstevel@tonic-gate return(ret != 1 ? 0 : 1);
4887c478bd9Sstevel@tonic-gate }
4897c478bd9Sstevel@tonic-gate
490*414388d7Ssl108498 void
printhd(void)491*414388d7Ssl108498 printhd(void)
4927c478bd9Sstevel@tonic-gate {
4937c478bd9Sstevel@tonic-gate fprintf(stdout, "COMMAND START END REAL");
4947c478bd9Sstevel@tonic-gate ps("CPU");
4957c478bd9Sstevel@tonic-gate if(option & SEPTIME)
4967c478bd9Sstevel@tonic-gate ps("(SECS)");
4977c478bd9Sstevel@tonic-gate if(option & IORW){
4987c478bd9Sstevel@tonic-gate ps("CHARS");
4997c478bd9Sstevel@tonic-gate ps("BLOCKS");
5007c478bd9Sstevel@tonic-gate }
5017c478bd9Sstevel@tonic-gate if(option & CPUFACTOR)
5027c478bd9Sstevel@tonic-gate ps("CPU");
5037c478bd9Sstevel@tonic-gate if(option & HOGFACTOR)
5047c478bd9Sstevel@tonic-gate ps("HOG");
5057c478bd9Sstevel@tonic-gate if(!option || (option & MEANSIZE))
5067c478bd9Sstevel@tonic-gate ps("MEAN");
5077c478bd9Sstevel@tonic-gate if(option & KCOREMIN)
5087c478bd9Sstevel@tonic-gate ps("KCORE");
5097c478bd9Sstevel@tonic-gate fprintf(stdout, "\n");
5107c478bd9Sstevel@tonic-gate fprintf(stdout, "NAME USER TTYNAME TIME TIME (SECS)");
5117c478bd9Sstevel@tonic-gate if(option & SEPTIME) {
5127c478bd9Sstevel@tonic-gate ps("SYS");
5137c478bd9Sstevel@tonic-gate ps("USER");
5147c478bd9Sstevel@tonic-gate } else
5157c478bd9Sstevel@tonic-gate ps("(SECS)");
5167c478bd9Sstevel@tonic-gate if(option & IORW) {
5177c478bd9Sstevel@tonic-gate ps("TRNSFD");
5187c478bd9Sstevel@tonic-gate ps("READ");
5197c478bd9Sstevel@tonic-gate }
5207c478bd9Sstevel@tonic-gate if(option & CPUFACTOR)
5217c478bd9Sstevel@tonic-gate ps("FACTOR");
5227c478bd9Sstevel@tonic-gate if(option & HOGFACTOR)
5237c478bd9Sstevel@tonic-gate ps("FACTOR");
5247c478bd9Sstevel@tonic-gate if(!option || (option & MEANSIZE))
5257c478bd9Sstevel@tonic-gate ps("SIZE(K)");
5267c478bd9Sstevel@tonic-gate if(option & KCOREMIN)
5277c478bd9Sstevel@tonic-gate ps("MIN");
5287c478bd9Sstevel@tonic-gate if(flag_field)
5297c478bd9Sstevel@tonic-gate fprintf(stdout, " F STAT");
5307c478bd9Sstevel@tonic-gate fprintf(stdout, "\n");
5317c478bd9Sstevel@tonic-gate fflush(stdout);
5327c478bd9Sstevel@tonic-gate }
5337c478bd9Sstevel@tonic-gate
534*414388d7Ssl108498 void
println(void)535*414388d7Ssl108498 println(void)
5367c478bd9Sstevel@tonic-gate {
5377c478bd9Sstevel@tonic-gate char name[32];
538*414388d7Ssl108498 struct acct *a = &ab;
5397c478bd9Sstevel@tonic-gate time_t t;
5407c478bd9Sstevel@tonic-gate
5417c478bd9Sstevel@tonic-gate if(quiet)
5427c478bd9Sstevel@tonic-gate return;
5437c478bd9Sstevel@tonic-gate if(!SU(a->ac_flag))
5447c478bd9Sstevel@tonic-gate strcpy(name,command_name);
5457c478bd9Sstevel@tonic-gate else {
5467c478bd9Sstevel@tonic-gate strcpy(name,"#");
5477c478bd9Sstevel@tonic-gate strcat(name,command_name);
5487c478bd9Sstevel@tonic-gate }
5497c478bd9Sstevel@tonic-gate fprintf(stdout, "%-*.*s", (OUTPUT_NSZ + 1),
5507c478bd9Sstevel@tonic-gate (OUTPUT_NSZ + 1), name);
5517c478bd9Sstevel@tonic-gate strcpy(name,uidtonam(a->ac_uid));
5527c478bd9Sstevel@tonic-gate if(*name != '?')
5537c478bd9Sstevel@tonic-gate fprintf(stdout, " %-*.*s", (OUTPUT_NSZ + 1),
5547c478bd9Sstevel@tonic-gate (OUTPUT_NSZ + 1), name);
5557c478bd9Sstevel@tonic-gate else
5567c478bd9Sstevel@tonic-gate fprintf(stdout, " %-9d",a->ac_uid);
5577c478bd9Sstevel@tonic-gate #ifdef uts
5587c478bd9Sstevel@tonic-gate fprintf(stdout, " %-*.*s", OUTPUT_LSZ, OUTPUT_LSZ,
5597c478bd9Sstevel@tonic-gate a->ac_tty != 0xffff? devtolin(a->ac_tty):"?");
5607c478bd9Sstevel@tonic-gate #else
5617c478bd9Sstevel@tonic-gate fprintf(stdout, " %-*.*s", OUTPUT_LSZ, OUTPUT_LSZ,
5627c478bd9Sstevel@tonic-gate a->ac_tty != (dev_t)-1? devtolin(a->ac_tty):"?");
5637c478bd9Sstevel@tonic-gate #endif
5647c478bd9Sstevel@tonic-gate t = a->ac_btime;
5657c478bd9Sstevel@tonic-gate cftime(time_buf, DATE_FMT1, &t);
5667c478bd9Sstevel@tonic-gate fprintf(stdout, "%.9s", time_buf);
5677c478bd9Sstevel@tonic-gate cftime(time_buf, DATE_FMT1, (time_t *)&etime);
5687c478bd9Sstevel@tonic-gate fprintf(stdout, "%.9s ", time_buf);
5697c478bd9Sstevel@tonic-gate pf((double)SECS(elapsed));
5707c478bd9Sstevel@tonic-gate if(option & SEPTIME) {
5717c478bd9Sstevel@tonic-gate pf((double)sys / HZ);
5727c478bd9Sstevel@tonic-gate pf((double)user / HZ);
5737c478bd9Sstevel@tonic-gate } else
5747c478bd9Sstevel@tonic-gate pf((double)cpu / HZ);
5757c478bd9Sstevel@tonic-gate if(option & IORW)
5767c478bd9Sstevel@tonic-gate fprintf(stdout, io < 100000000 ? "%8ld%8ld" : "%12ld%8ld",io,rw);
5777c478bd9Sstevel@tonic-gate if(option & CPUFACTOR)
5787c478bd9Sstevel@tonic-gate pf((double)user / cpu);
5797c478bd9Sstevel@tonic-gate if(option & HOGFACTOR)
5807c478bd9Sstevel@tonic-gate pf((double)cpu / elapsed);
5817c478bd9Sstevel@tonic-gate if(!option || (option & MEANSIZE))
5827c478bd9Sstevel@tonic-gate pf(KCORE(mem / cpu));
5837c478bd9Sstevel@tonic-gate if(option & KCOREMIN)
5847c478bd9Sstevel@tonic-gate pf(MINT(KCORE(mem)));
5857c478bd9Sstevel@tonic-gate if(flag_field)
5867c478bd9Sstevel@tonic-gate fprintf(stdout, " %1o %3o", (unsigned char) a->ac_flag,
5877c478bd9Sstevel@tonic-gate (unsigned char) a->ac_stat);
5887c478bd9Sstevel@tonic-gate fprintf(stdout, "\n");
5897c478bd9Sstevel@tonic-gate }
5907c478bd9Sstevel@tonic-gate
5917c478bd9Sstevel@tonic-gate /*
5927c478bd9Sstevel@tonic-gate * convtime converts time arg to internal value
5937c478bd9Sstevel@tonic-gate * arg has form hr:min:sec, min or sec are assumed to be 0 if omitted
5947c478bd9Sstevel@tonic-gate */
5957c478bd9Sstevel@tonic-gate long
convtime(str)5967c478bd9Sstevel@tonic-gate convtime(str)
5977c478bd9Sstevel@tonic-gate char *str;
5987c478bd9Sstevel@tonic-gate {
5997c478bd9Sstevel@tonic-gate long hr, min, sec;
6007c478bd9Sstevel@tonic-gate
6017c478bd9Sstevel@tonic-gate min = sec = 0;
6027c478bd9Sstevel@tonic-gate
6037c478bd9Sstevel@tonic-gate if(sscanf(str, "%ld:%ld:%ld", &hr, &min, &sec) < 1) {
6047c478bd9Sstevel@tonic-gate fatal("acctcom: bad time:", str);
6057c478bd9Sstevel@tonic-gate }
6067c478bd9Sstevel@tonic-gate tzset();
6077c478bd9Sstevel@tonic-gate sec += (min*60);
6087c478bd9Sstevel@tonic-gate sec += (hr*3600);
6097c478bd9Sstevel@tonic-gate return(sec + timezone);
6107c478bd9Sstevel@tonic-gate }
6117c478bd9Sstevel@tonic-gate
612*414388d7Ssl108498 int
cmatch(char * comm,char * cstr)613*414388d7Ssl108498 cmatch(char *comm, char *cstr)
6147c478bd9Sstevel@tonic-gate {
6157c478bd9Sstevel@tonic-gate
6167c478bd9Sstevel@tonic-gate char xcomm[9];
617*414388d7Ssl108498 int i;
6187c478bd9Sstevel@tonic-gate
6197c478bd9Sstevel@tonic-gate for(i=0;i<8;i++){
6207c478bd9Sstevel@tonic-gate if(comm[i]==' '||comm[i]=='\0')
6217c478bd9Sstevel@tonic-gate break;
6227c478bd9Sstevel@tonic-gate xcomm[i] = comm[i];
6237c478bd9Sstevel@tonic-gate }
6247c478bd9Sstevel@tonic-gate xcomm[i] = '\0';
6257c478bd9Sstevel@tonic-gate
626*414388d7Ssl108498 return (regex(cstr,xcomm) ? 1 : 0);
6277c478bd9Sstevel@tonic-gate }
6287c478bd9Sstevel@tonic-gate
629*414388d7Ssl108498 char *
cmset(char * pattern)630*414388d7Ssl108498 cmset(char *pattern)
6317c478bd9Sstevel@tonic-gate {
6327c478bd9Sstevel@tonic-gate
6337c478bd9Sstevel@tonic-gate if((pattern=(char *)regcmp(pattern,(char *)0))==NULL){
6347c478bd9Sstevel@tonic-gate fatal("pattern syntax", NULL);
6357c478bd9Sstevel@tonic-gate }
6367c478bd9Sstevel@tonic-gate
637*414388d7Ssl108498 return (pattern);
6387c478bd9Sstevel@tonic-gate }
6397c478bd9Sstevel@tonic-gate
640*414388d7Ssl108498 void
doexit(int status)641*414388d7Ssl108498 doexit(int status)
6427c478bd9Sstevel@tonic-gate {
6437c478bd9Sstevel@tonic-gate if(!average)
6447c478bd9Sstevel@tonic-gate exit(status);
6457c478bd9Sstevel@tonic-gate if(cmdcount) {
6467c478bd9Sstevel@tonic-gate fprintf(stdout, "cmds=%ld ",cmdcount);
6477c478bd9Sstevel@tonic-gate fprintf(stdout, "Real=%-6.2f ",SECS(realtot)/cmdcount);
6487c478bd9Sstevel@tonic-gate cputot = systot + usertot;
6497c478bd9Sstevel@tonic-gate fprintf(stdout, "CPU=%-6.2f ",SECS(cputot)/cmdcount);
6507c478bd9Sstevel@tonic-gate fprintf(stdout, "USER=%-6.2f ",SECS(usertot)/cmdcount);
6517c478bd9Sstevel@tonic-gate fprintf(stdout, "SYS=%-6.2f ",SECS(systot)/cmdcount);
6527c478bd9Sstevel@tonic-gate fprintf(stdout, "CHAR=%-8.2f ",iotot/cmdcount);
6537c478bd9Sstevel@tonic-gate fprintf(stdout, "BLK=%-8.2f ",rwtot/cmdcount);
6547c478bd9Sstevel@tonic-gate fprintf(stdout, "USR/TOT=%-4.2f ",usertot/cputot);
6557c478bd9Sstevel@tonic-gate fprintf(stdout, "HOG=%-4.2f ",cputot/realtot);
6567c478bd9Sstevel@tonic-gate fprintf(stdout, "\n");
6577c478bd9Sstevel@tonic-gate }
6587c478bd9Sstevel@tonic-gate else
6597c478bd9Sstevel@tonic-gate fprintf(stdout, "\nNo commands matched\n");
6607c478bd9Sstevel@tonic-gate exit(status);
6617c478bd9Sstevel@tonic-gate }
662*414388d7Ssl108498
663*414388d7Ssl108498 int
isdevnull(void)664*414388d7Ssl108498 isdevnull(void)
6657c478bd9Sstevel@tonic-gate {
6667c478bd9Sstevel@tonic-gate struct stat filearg;
6677c478bd9Sstevel@tonic-gate struct stat devnull;
6687c478bd9Sstevel@tonic-gate
6697c478bd9Sstevel@tonic-gate if(fstat(0,&filearg) == -1) {
6707c478bd9Sstevel@tonic-gate fprintf(stderr,"acctcom: cannot stat stdin\n");
671*414388d7Ssl108498 return (0);
6727c478bd9Sstevel@tonic-gate }
6737c478bd9Sstevel@tonic-gate if(stat("/dev/null",&devnull) == -1) {
6747c478bd9Sstevel@tonic-gate fprintf(stderr,"acctcom: cannot stat /dev/null\n");
675*414388d7Ssl108498 return (0);
6767c478bd9Sstevel@tonic-gate }
6777c478bd9Sstevel@tonic-gate
678*414388d7Ssl108498 if (filearg.st_rdev == devnull.st_rdev)
679*414388d7Ssl108498 return (1);
680*414388d7Ssl108498 else
681*414388d7Ssl108498 return (0);
6827c478bd9Sstevel@tonic-gate }
6837c478bd9Sstevel@tonic-gate
684*414388d7Ssl108498 void
fatal(char * s1,char * s2)685*414388d7Ssl108498 fatal(char *s1, char *s2)
6867c478bd9Sstevel@tonic-gate {
6877c478bd9Sstevel@tonic-gate fprintf(stderr,"acctcom: %s %s\n", s1, (s2 ? s2 : ""));
6887c478bd9Sstevel@tonic-gate exit(1);
6897c478bd9Sstevel@tonic-gate }
6907c478bd9Sstevel@tonic-gate
691*414388d7Ssl108498 void
usage(void)692*414388d7Ssl108498 usage(void)
6937c478bd9Sstevel@tonic-gate {
6947c478bd9Sstevel@tonic-gate fprintf(stderr, "Usage: acctcom [options] [files]\n");
6957c478bd9Sstevel@tonic-gate fprintf(stderr, "\nWhere options can be:\n");
6967c478bd9Sstevel@tonic-gate diag("-b read backwards through file");
6977c478bd9Sstevel@tonic-gate diag("-f print the fork/exec flag and exit status");
6987c478bd9Sstevel@tonic-gate diag("-h print hog factor (total-CPU-time/elapsed-time)");
6997c478bd9Sstevel@tonic-gate diag("-i print I/O counts");
7007c478bd9Sstevel@tonic-gate diag("-k show total Kcore minutes instead of memory size");
7017c478bd9Sstevel@tonic-gate diag("-m show mean memory size");
7027c478bd9Sstevel@tonic-gate diag("-r show CPU factor (user-time/(sys-time + user-time))");
7037c478bd9Sstevel@tonic-gate diag("-t show separate system and user CPU times");
7047c478bd9Sstevel@tonic-gate diag("-v don't print column headings");
7057c478bd9Sstevel@tonic-gate diag("-a print average statistics of selected commands");
7067c478bd9Sstevel@tonic-gate diag("-q print average statistics only");
7077c478bd9Sstevel@tonic-gate diag("-l line \tshow processes belonging to terminal /dev/line");
7087c478bd9Sstevel@tonic-gate diag("-u user \tshow processes belonging to user name or user ID");
7097c478bd9Sstevel@tonic-gate diag("-u # \tshow processes executed by super-user");
7107c478bd9Sstevel@tonic-gate diag("-u ? \tshow processes executed by unknown UID's");
7117c478bd9Sstevel@tonic-gate diag("-g group show processes belonging to group name of group ID");
7127c478bd9Sstevel@tonic-gate diag("-s time \tshow processes ending after time (hh[:mm[:ss]])");
7137c478bd9Sstevel@tonic-gate diag("-e time \tshow processes starting before time");
7147c478bd9Sstevel@tonic-gate diag("-S time \tshow processes starting after time");
7157c478bd9Sstevel@tonic-gate diag("-E time \tshow processes ending before time");
7167c478bd9Sstevel@tonic-gate diag("-n regex select commands matching the ed(1) regular expression");
7177c478bd9Sstevel@tonic-gate diag("-o file \tdo not print, put selected pacct records into file");
7187c478bd9Sstevel@tonic-gate diag("-H factor show processes that exceed hog factor");
7197c478bd9Sstevel@tonic-gate diag("-O sec \tshow processes that exceed CPU system time sec");
7207c478bd9Sstevel@tonic-gate diag("-C sec \tshow processes that exceed total CPU time sec");
7217c478bd9Sstevel@tonic-gate diag("-I chars show processes that transfer more than char chars");
7227c478bd9Sstevel@tonic-gate }
723