/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* acctcms [-a] [-c] [-j] [-n] [-s] [-p] [-o] [-t] [file...]
* summarize per-process accounting
* -a output in ascii, rather than [pt]cms.h format
* -c sort by total cpu, rather than total kcore-minutes
* -j anything used only once -> ***other
* -n sort by number of processes
* -s any following files already in pcms.h format
* -p output prime time command summary (only with -a)
* -o output non-prime time (offshift) command summary (only
* with -a option)
* -t process records in total (old) style (tcms.h) format
* expected use:
* cp new old; rm new
* acctcms -a today; acctcms -a old
*/
#include <stdio.h>
#include "acctdef.h"
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
/*
* Total cms records format
*/
struct tcms {
} ;
/*
*/
struct pcms {
} ;
int aflg;
int cflg;
int jflg;
int nflg;
int sflg;
int pflg;
int oflg;
int tflg;
int errflg;
#ifdef uts
float expand();
#else
#endif
void outputc(void);
void outputa(void);
void toutptc(void);
void toutpta(void);
void tdofile(char *);
void dofile(char *);
void tfixjunk(void);
void fixjunk(void);
void tsqueeze(void);
void squeeze(void);
/* Format specification for ASCII printing */
int
{
int c;
switch(c) {
case 'a':
aflg++;
continue;
case 'c':
cflg++;
continue;
case 'j':
jflg++;
continue;
case 'n':
nflg++;
continue;
case 's':
sflg++;
continue;
case 'p':
pflg++;
continue;
case 'o':
oflg++;
continue;
case 't':
tflg++;
continue;
default:
errflg++;
continue;
}
if(errflg){
exit(1);
}
if(tflg) {
exit(5);
}
if (jflg)
tfixjunk();
tsqueeze();
(int (*)(const void *, const void *))
if (aflg)
toutpta();
else
toutptc();
} else {
exit(6);
}
if (jflg)
fixjunk();
squeeze();
(int (*)(const void *, const void *))
if (aflg)
outputa();
else
outputc();
}
exit(0);
}
void
{
union {
} acct;
int ver = 0;
return;
}
if (sflg)
else {
/* check for expanded account structure flag */
else
switch(ver) {
default:
/* this can't happen */
return;
case 1 :
}
break;
case 2 :
}
break;
}
}
}
void
{
union {
} acct;
double ratio;
double dtmp;
unsigned long ltmp;
return;
}
if (sflg)
else {
int ver = 0;
/* check for expanded account structure flag */
else
switch(ver) {
default :
/* this can't happen */
return;
case 1 :
/*
*/
etime = 1;
== 0) {
"hours\n");
exit(1);
}
} else {
}
}
break;
case 2 :
/*
*/
etime = 1;
exit(1);
}
} else {
}
}
break;
}
}
}
int
{
int i;
int j;
for (i = j = 0; j < sizeof(p->tcm_comm); j++) {
p->tcm_comm[j] = '?';
}
if (i < 0)
i = -i;
break;
if(j == csize) {
"acctcms: Cannot reallocate memory (tcm)\n");
return(-1);
} else {
i = csize;
}
}
return(i);
}
int
{
int i;
int j;
for (i = j = 0; j < sizeof(p->pcm_comm); j++) {
p->pcm_comm[j] = '?';
}
if (i < 0)
i = -i;
break;
if(j == csize) {
"acctcms: Cannot reallocate memory (pcm)\n");
return(-1);
} else {
i = csize;
}
}
return(i);
}
void
{
int i, j;
for (i = 0; i < csize; i++)
}
}
void
{
int i, j;
for (i = 0; i < csize; i++)
}
}
void
{
}
void
{
}
void
{
int i, k;
for (i = k = 0; i < csize; i++)
k++;
}
csize = k;
}
void
{
int i, k;
for (i = k = 0; i < csize; i++)
k++;
}
csize = k;
}
int
{
return(0);
}
int
{
int index;
return(0);
return ((p2->pcm_cpu[PRIME] + p2->pcm_cpu[NONPRIME] > p1->pcm_cpu[PRIME] + p1->pcm_cpu[NONPRIME])? 1 : -1);
}
return(0);
}
int
{
return(0);
}
int
{
int index;
if (p1->pcm_kcore[PRIME] + p1->pcm_kcore[NONPRIME] == p2->pcm_kcore[PRIME] + p2->pcm_kcore[NONPRIME])
return(0);
return ((p2->pcm_kcore[PRIME] + p2->pcm_kcore[NONPRIME] > p1->pcm_kcore[PRIME] + p1->pcm_kcore[NONPRIME])? 1 : -1);
}
return(0);
}
int
{
return(0);
}
int
{
int index;
return(0);
return ((p2->pcm_pc[PRIME] + p2->pcm_pc[NONPRIME] > p1->pcm_pc[PRIME] + p1->pcm_pc[NONPRIME])? 1 : -1);
}
return(0);
}
char thd1[] =
"COMMAND NUMBER TOTAL TOTAL TOTAL MEAN MEAN HOG CHARS BLOCKS\n";
char thd2[] =
"NAME CMDS KCOREMIN CPU-MIN REAL-MIN SIZE-K CPU-MIN FACTOR TRNSFD READ\n";
void
toutpta(void)
{
int i;
printf("\n");
for (i = 0; i < csize; i++)
printf("\n");
for (i = 0; i < csize; i++)
}
void
{
if (p->tcm_real == 0)
p->tcm_real = 1;
}
void
toutptc(void)
{
int i;
for (i = 0; i < csize; i++)
}
char hd1[] =
"COMMAND NUMBER TOTAL TOTAL TOTAL MEAN MEAN HOG CHARS BLOCKS\n";
char hd2[] =
"NAME CMDS KCOREMIN CPU-MIN REAL-MIN SIZE-K CPU-MIN FACTOR TRNSFD READ\n";
char hd3[] =
"COMMAND NUMBER TOTAL CPU-MIN REAL-MIN MEAN MEAN HOG CHARS BLOCKS\n";
char hd4[] =
"NAME (P) (NP) KCOREMIN (P) (NP) (P) (NP) SIZE-K CPU-MIN FACTOR TRNSFD READ\n";
char hdprime[] =
" PRIME TIME COMMAND SUMMARY\n";
char hdnonprime[] =
" NON-PRIME TIME COMMAND SUMMARY\n";
char hdtot[] =
" TOTAL COMMAND SUMMARY\n";
char hdp[] =
void
outputa(void)
{
int i;
}
else {
}
printf("\n");
for (i = 0; i < csize; i++)
printf("\n");
for (i = 0; i < csize; i++)
}
void
{
else totprnt(p);
}
void
{
printf("\n");
}
void
{
printf("\n");
}
void
{
printf("\n");
}
void
outputc(void)
{
int i;
for (i = 0; i < csize; i++)
}