/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <fcntl.h>
#include <exacct.h>
#include <pwd.h>
#include <grp.h>
#include <project.h>
#include <stdlib.h>
#include <strings.h>
#include <netdb.h>
#ifndef _LP64
#else
#endif
static int vflag = 0;
typedef struct catalog_item {
int type;
char *name;
/*
* The actual constants are defined in <sys/exacct_catalog.h>.
*/
{ EXD_VERSION, "version" },
{ EXD_FILETYPE, "filetype" },
{ EXD_CREATOR, "creator" },
{ EXD_HOSTNAME, "hostname" },
{ EXD_GROUP_HEADER, "group-header" },
{ EXD_GROUP_PROC, "group-proc" },
{ EXD_GROUP_TASK, "group-task" },
{ EXD_GROUP_LWP, "group-lwp" },
{ EXD_GROUP_FLOW, "group-flow" },
{ EXD_GROUP_PROC_TAG, "group-proc-tag" },
{ EXD_GROUP_TASK_TAG, "group-task-tag" },
{ EXD_GROUP_LWP_TAG, "group-lwp-tag" },
{ EXD_GROUP_PROC_PARTIAL, "group-proc-partial" },
{ EXD_GROUP_TASK_PARTIAL, "group-task-partial" },
{ EXD_GROUP_TASK_INTERVAL, "group-task-interval" },
{ EXD_PROC_PID, "pid" },
{ EXD_PROC_ANCPID, "ppid" },
{ EXD_PROC_UID, "uid" },
{ EXD_PROC_GID, "gid" },
{ EXD_PROC_TASKID, "taskid" },
{ EXD_PROC_PROJID, "projid" },
{ EXD_PROC_HOSTNAME, "hostname" },
{ EXD_PROC_COMMAND, "command" },
{ EXD_PROC_WAIT_STATUS, "wait-status" },
{ EXD_PROC_START_SEC, "start-sec" },
{ EXD_PROC_START_NSEC, "start-nsec" },
{ EXD_PROC_FINISH_SEC, "finish-sec" },
{ EXD_PROC_FINISH_NSEC, "finish-nsec" },
{ EXD_PROC_CPU_USER_SEC, "cpu-user-sec" },
{ EXD_PROC_CPU_USER_NSEC, "cpu-user-nsec" },
{ EXD_PROC_CPU_SYS_SEC, "cpu-sys-sec" },
{ EXD_PROC_CPU_SYS_NSEC, "cpu-sys-nsec" },
{ EXD_PROC_TTY_MAJOR, "tty-major" },
{ EXD_PROC_TTY_MINOR, "tty-minor" },
{ EXD_PROC_FAULTS_MAJOR, "faults-major" },
{ EXD_PROC_FAULTS_MINOR, "faults-minor" },
{ EXD_PROC_MESSAGES_RCV, "msgs-recv" },
{ EXD_PROC_MESSAGES_SND, "msgs-snd" },
{ EXD_PROC_BLOCKS_IN, "blocks-in" },
{ EXD_PROC_BLOCKS_OUT, "blocks-out" },
{ EXD_PROC_CHARS_RDWR, "chars-rdwr" },
{ EXD_PROC_CONTEXT_VOL, "ctxt-vol" },
{ EXD_PROC_CONTEXT_INV, "ctxt-inv" },
{ EXD_PROC_SIGNALS, "signals" },
{ EXD_PROC_SWAPS, "swaps" },
{ EXD_PROC_SYSCALLS, "syscalls" },
{ EXD_PROC_TAG, "proc-tag" },
{ EXD_PROC_ACCT_FLAGS, "acctflags" },
{ EXD_PROC_ZONENAME, "zone" },
{ EXD_PROC_MEM_RSS_AVG_K, "memory-rss-avg-k" },
{ EXD_PROC_MEM_RSS_MAX_K, "memory-rss-max-k" },
{ EXD_TASK_TASKID, "taskid" },
{ EXD_TASK_ANCTASKID, "anctaskid" },
{ EXD_TASK_PROJID, "projid" },
{ EXD_TASK_HOSTNAME, "hostname" },
{ EXD_TASK_START_SEC, "start-sec" },
{ EXD_TASK_START_NSEC, "start-nsec" },
{ EXD_TASK_FINISH_SEC, "finish-sec" },
{ EXD_TASK_FINISH_NSEC, "finish-nsec" },
{ EXD_TASK_CPU_USER_SEC, "cpu-user-sec" },
{ EXD_TASK_CPU_USER_NSEC, "cpu-user-nsec" },
{ EXD_TASK_CPU_SYS_SEC, "cpu-sys-sec" },
{ EXD_TASK_CPU_SYS_NSEC, "cpu-sys-nsec" },
{ EXD_TASK_FAULTS_MAJOR, "faults-major" },
{ EXD_TASK_FAULTS_MINOR, "faults-minor" },
{ EXD_TASK_MESSAGES_RCV, "msgs-recv" },
{ EXD_TASK_MESSAGES_SND, "msgs-snd" },
{ EXD_TASK_BLOCKS_IN, "blocks-in" },
{ EXD_TASK_BLOCKS_OUT, "blocks-out" },
{ EXD_TASK_CHARS_RDWR, "chars-rdwr" },
{ EXD_TASK_CONTEXT_VOL, "ctxt-vol" },
{ EXD_TASK_CONTEXT_INV, "ctxt-inv" },
{ EXD_TASK_SIGNALS, "signals" },
{ EXD_TASK_SWAPS, "swaps" },
{ EXD_TASK_SYSCALLS, "syscalls" },
{ EXD_TASK_TAG, "task-tag" },
{ EXD_TASK_ZONENAME, "zone" },
{ EXD_FLOW_V4SADDR, "src-addr-v4" },
{ EXD_FLOW_V4DADDR, "dest-addr-v4" },
{ EXD_FLOW_V6SADDR, "src-addr-v6" },
{ EXD_FLOW_V6DADDR, "dest-addr-v6" },
{ EXD_FLOW_SPORT, "src-port" },
{ EXD_FLOW_DPORT, "dest-port" },
{ EXD_FLOW_PROTOCOL, "protocol" },
{ EXD_FLOW_DSFIELD, "diffserv-field" },
{ EXD_FLOW_NBYTES, "total-bytes" },
{ EXD_FLOW_NPKTS, "total-packets" },
{ EXD_FLOW_CTIME, "creation-time" },
{ EXD_FLOW_LSEEN, "last-seen" },
{ EXD_FLOW_PROJID, "projid" },
{ EXD_FLOW_UID, "uid" },
{ EXD_FLOW_ANAME, "action-name" },
{ EXD_NONE, "none" }
};
/*
* Convert catalog ID into catalog name.
*/
static char *
{
int i = 0;
i++;
}
return ("unknown");
}
/*
* Display port information, if available
*/
static void
{
}
}
/*
* Display host name for a given IP address if available.
*/
static void
{
int error_num;
sizeof (struct in6_addr);
}
}
/*
* Display protocol information, if available.
*/
static void
{
}
}
/*
* Display recursively exacct objects in a given embedded group.
*/
static void
{
}
}
/*
* Display the data stored in a given exacct object.
*/
static void
{
objname[0] = '>';
indent = 1;
}
switch (o->eo_catalog & EXT_TYPE_MASK) {
case EXT_UINT8:
if (vflag &&
}
break;
case EXT_UINT16:
if (vflag &&
}
break;
case EXT_UINT32:
switch (o->eo_catalog & EXD_DATA_MASK) {
case EXD_PROC_WAIT_STATUS:
{
if (vflag) {
(void) printf("%-14d exit",
WEXITSTATUS(wstat));
else if (WIFSIGNALED(wstat))
(void) printf("%14d, signal",
else
} else {
}
}
break;
case EXD_PROC_UID:
{
if (vflag) {
(void) printf("%s",
}
}
break;
case EXD_PROC_GID:
{
if (vflag) {
(void) printf("%s",
}
}
break;
case EXD_PROC_PROJID:
case EXD_TASK_PROJID:
{
if (vflag) {
PROJECT_BUFSZ) != NULL)
(void) printf("%s",
}
}
break;
case EXD_PROC_ACCT_FLAGS:
{
if (vflag) {
(void) printf("FORK ");
(void) printf("SU");
}
}
break;
case EXD_FLOW_V4SADDR:
/* FALLTHRU */
case EXD_FLOW_V4DADDR:
{
(void) printf("%-15s",
if (vflag) {
}
}
break;
default:
}
break;
case EXT_UINT64:
{
if (!vflag)
break;
if (ea_match_object_catalog(o, EXD_TASK_START_SEC) ||
}
}
break;
case EXT_DOUBLE:
break;
case EXT_STRING:
break;
case EXT_RAW:
switch (o->eo_catalog & EXD_DATA_MASK) {
case EXD_FLOW_V6SADDR:
/* FALLTHRU */
case EXD_FLOW_V6DADDR:
{
if (vflag) {
AF_INET6);
}
}
break;
default:
{
uint64_t i;
for (i = 0; i < size && i < 6; i++)
if (size > 6)
(void) printf("...");
}
}
break;
case EXT_GROUP:
break;
case EXT_EXACCT_OBJECT:
/*
* Embedded exacct records.
*/
{
(void) printf("error: couldn't unpack embedded "
"object\n");
break;
}
eol = 0;
(void) printf("[embedded group of %u "
} else {
(void) printf("[embedded object]\n");
}
}
break;
default:
(void) printf("[complex value]");
break;
}
if (eol)
(void) printf("\n");
}
/*
* Read and display a group of exacct objects from the file.
*/
static void
{
uint_t i;
for (i = 0; i < nobjs; i++) {
int res;
"bad file: ea_get_object()==%d\n", res);
exit(2);
}
else
}
}
static void
usage()
{
exit(2);
}
int
{
char *fname;
int opt;
switch (opt) {
case 'v':
vflag = 1;
break;
default:
usage();
}
}
usage();
usage();
return (1);
}
else
}
return (0);
}