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 2004 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 277c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <utmpx.h> 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate static struct utmpx utdummy; /* dummy - used to get member sizes */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #define PACCT "/var/adm/pacct" 347c478bd9Sstevel@tonic-gate #define HOLFILE "/etc/acct/holidays" 357c478bd9Sstevel@tonic-gate #define NHOLIDAYS 200 /* max number of company holidays per year */ 367c478bd9Sstevel@tonic-gate #define NSYS 200 /* number of run state changes */ 377c478bd9Sstevel@tonic-gate #define NFILE 100 /* max number of files that acctmerg handles */ 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifdef uts 407c478bd9Sstevel@tonic-gate #define CSIZE 10001 417c478bd9Sstevel@tonic-gate #define MAXUSERS 5003 427c478bd9Sstevel@tonic-gate #define A_SSIZE 60001 /* max num of sessions in 1 acct run */ 437c478bd9Sstevel@tonic-gate #define A_TSIZE 10001 /* max num of line names in 1 acct run */ 447c478bd9Sstevel@tonic-gate #define A_USIZE 20001 /* max num of distinct login names in 1 acct run */ 457c478bd9Sstevel@tonic-gate #else 467c478bd9Sstevel@tonic-gate #define CSIZE 5001 477c478bd9Sstevel@tonic-gate #define MAXUSERS 3001 487c478bd9Sstevel@tonic-gate #define A_SSIZE 6001 /* max num of sessions in 1 acct run */ 497c478bd9Sstevel@tonic-gate #define A_TSIZE 1001 /* max num of line names in 1 acct run */ 507c478bd9Sstevel@tonic-gate #define A_USIZE 2001 /* max num of distinct login names in 1 acct run */ 517c478bd9Sstevel@tonic-gate #endif 527c478bd9Sstevel@tonic-gate #define TSIZE1 100 /* # distinct names, for speed only */ 537c478bd9Sstevel@tonic-gate #define USIZE1 100 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate #define MAXIGN 10 567c478bd9Sstevel@tonic-gate #define UNUSED -1 577c478bd9Sstevel@tonic-gate #define FAIL -1 587c478bd9Sstevel@tonic-gate #define SUCCEED 0 597c478bd9Sstevel@tonic-gate #define TRUE 1 607c478bd9Sstevel@tonic-gate #define FALSE 0 617c478bd9Sstevel@tonic-gate #define PRIME 0 627c478bd9Sstevel@tonic-gate #define NONPRIME 1 637c478bd9Sstevel@tonic-gate #define MEANSIZE 01 647c478bd9Sstevel@tonic-gate #define KCOREMIN 02 657c478bd9Sstevel@tonic-gate #define HOGFACTOR 04 667c478bd9Sstevel@tonic-gate #define SEPTIME 010 677c478bd9Sstevel@tonic-gate #define CPUFACTOR 020 687c478bd9Sstevel@tonic-gate #define IORW 040 697c478bd9Sstevel@tonic-gate #define ROOT 0 707c478bd9Sstevel@tonic-gate #define ERR (-1) 717c478bd9Sstevel@tonic-gate #define OK 0 727c478bd9Sstevel@tonic-gate #define NOGOOD 1 737c478bd9Sstevel@tonic-gate #define VALID 0 747c478bd9Sstevel@tonic-gate #define INVALID 1 757c478bd9Sstevel@tonic-gate /* 767c478bd9Sstevel@tonic-gate * The size of LSZ is based on MAX_SRCH_DEPTH because of the 777c478bd9Sstevel@tonic-gate * implementation of devtolin() 787c478bd9Sstevel@tonic-gate */ 797c478bd9Sstevel@tonic-gate #define MAX_SRCH_DEPTH 4 807c478bd9Sstevel@tonic-gate #define LSZ (MAX_SRCH_DEPTH * sizeof (utdummy.ut_line)) 817c478bd9Sstevel@tonic-gate #define MAX_DEV_PATH (LSZ + 5) /* max len of abs line name path */ 827c478bd9Sstevel@tonic-gate #define NSZ (sizeof (utdummy.ut_name)) /* sizeof login name */ 837c478bd9Sstevel@tonic-gate #define LINESZ (sizeof (utdummy.ut_line)) /* sizeof device name */ 847c478bd9Sstevel@tonic-gate /* 857c478bd9Sstevel@tonic-gate * These exist for backward compatibility. Until we can change the 867c478bd9Sstevel@tonic-gate * output formats, we need to keep the field widths the same as 877c478bd9Sstevel@tonic-gate * they always have been. 887c478bd9Sstevel@tonic-gate */ 897c478bd9Sstevel@tonic-gate #define OUTPUT_NSZ 8 907c478bd9Sstevel@tonic-gate #define OUTPUT_LSZ 12 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate #define MYKIND(flag) ((flag & ACCTF) == 0) 937c478bd9Sstevel@tonic-gate #define SU(flag) ((flag & ASU) == ASU) 947c478bd9Sstevel@tonic-gate #define TOTAL(a) (a[PRIME] + a[NONPRIME]) 957c478bd9Sstevel@tonic-gate #define okay(time) ((time/100>=0) && (time/100<=24) \ 967c478bd9Sstevel@tonic-gate && (time%100>=0) && (time%100<60)) 977c478bd9Sstevel@tonic-gate #define pf(dble) fprintf(stdout, " %7.2lf", dble) 987c478bd9Sstevel@tonic-gate #define ps(s) fprintf(stdout, "%8.8s", s) 997c478bd9Sstevel@tonic-gate #define diag(string) fprintf(stderr, "\t%s\n", string) 1007c478bd9Sstevel@tonic-gate #define DATE_FMT "%a %b %e %H:%M:%S %Y\n" 1017c478bd9Sstevel@tonic-gate #define DATE_FMT1 " %H:%M:%S" 1027c478bd9Sstevel@tonic-gate #define CBEMPTY (ctab[i].ct_sess == 0) 1037c478bd9Sstevel@tonic-gate #define UBEMPTY (ub[i].ut_pc == 0 && ub[i].ut_cpu[0] == 0 && \ 1047c478bd9Sstevel@tonic-gate ub[i].ut_cpu[1] == 0 && ub[i].ut_kcore[0] ==0 && ub[i].ut_kcore[1] == 0) 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate #define EQN(s1, s2) (strncmp(s1, s2, sizeof(s1)) == 0) 1087c478bd9Sstevel@tonic-gate #define CPYN(s1, s2) (void) strncpy(s1, s2 ? s2 : "", sizeof(s1)) 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate #define SECSINDAY 86400L 1117c478bd9Sstevel@tonic-gate #define SECS(tics) ((double) tics)/HZ 1127c478bd9Sstevel@tonic-gate #define MINS(secs) ((double) secs)/60 1137c478bd9Sstevel@tonic-gate #define MINT(tics) ((double) tics)/(60*HZ) 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate #include <unistd.h> 1167c478bd9Sstevel@tonic-gate #if UTS 1177c478bd9Sstevel@tonic-gate #define KCORE(clicks) ((double) BSIZE * (clicks/1024.0)) 1187c478bd9Sstevel@tonic-gate #else 1197c478bd9Sstevel@tonic-gate #define KCORE(clicks) ((double) (sysconf(_SC_PAGESIZE) >> 10) *clicks) 1207c478bd9Sstevel@tonic-gate #endif 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate /* 1237c478bd9Sstevel@tonic-gate * total accounting (for acct period), also for day 1247c478bd9Sstevel@tonic-gate */ 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate struct tacct { 1277c478bd9Sstevel@tonic-gate uid_t ta_uid; /* userid */ 1287c478bd9Sstevel@tonic-gate char ta_name[NSZ]; /* login name */ 1297c478bd9Sstevel@tonic-gate float ta_cpu[2]; /* cum. cpu time, p/np (mins) */ 1307c478bd9Sstevel@tonic-gate float ta_kcore[2]; /* cum kcore-minutes, p/np */ 1317c478bd9Sstevel@tonic-gate float ta_con[2]; /* cum. connect time, p/np, mins */ 1327c478bd9Sstevel@tonic-gate float ta_du; /* cum. disk usage */ 1337c478bd9Sstevel@tonic-gate long ta_pc; /* count of processes */ 1347c478bd9Sstevel@tonic-gate unsigned short ta_sc; /* count of login sessions */ 1357c478bd9Sstevel@tonic-gate unsigned short ta_dc; /* count of disk samples */ 1367c478bd9Sstevel@tonic-gate unsigned short ta_fee; /* fee for special services */ 1377c478bd9Sstevel@tonic-gate }; 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate /* 141*2a8bcb4eSToomas Soome * connect time record 1427c478bd9Sstevel@tonic-gate */ 1437c478bd9Sstevel@tonic-gate struct ctmp { 1447c478bd9Sstevel@tonic-gate dev_t ct_tty; /* major minor */ 1457c478bd9Sstevel@tonic-gate uid_t ct_uid; /* userid */ 1467c478bd9Sstevel@tonic-gate char ct_name[NSZ]; /* login name */ 1477c478bd9Sstevel@tonic-gate long ct_con[2]; /* connect time (p/np) secs */ 1487c478bd9Sstevel@tonic-gate time_t ct_start; /* session start time */ 1497c478bd9Sstevel@tonic-gate }; 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate /* 1527c478bd9Sstevel@tonic-gate * per process temporary data 1537c478bd9Sstevel@tonic-gate */ 1547c478bd9Sstevel@tonic-gate struct ptmp { 1557c478bd9Sstevel@tonic-gate uid_t pt_uid; /* userid */ 1567c478bd9Sstevel@tonic-gate char pt_name[NSZ]; /* login name */ 1577c478bd9Sstevel@tonic-gate ulong_t pt_cpu[2]; /* CPU (sys+usr) P/NP time tics */ 1587c478bd9Sstevel@tonic-gate unsigned pt_mem; /* avg. memory size (64byte clicks) */ 159*2a8bcb4eSToomas Soome }; 160