1 0 stevel /* 2 0 stevel * CDDL HEADER START 3 0 stevel * 4 0 stevel * The contents of this file are subject to the terms of the 5 2685 akolb * Common Development and Distribution License (the "License"). 6 2685 akolb * You may not use this file except in compliance with the License. 7 0 stevel * 8 0 stevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 0 stevel * or http://www.opensolaris.org/os/licensing. 10 0 stevel * See the License for the specific language governing permissions 11 0 stevel * and limitations under the License. 12 0 stevel * 13 0 stevel * When distributing Covered Code, include this CDDL HEADER in each 14 0 stevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 0 stevel * If applicable, add the following below this CDDL HEADER, with the 16 0 stevel * fields enclosed by brackets "[]" replaced with your own identifying 17 0 stevel * information: Portions Copyright [yyyy] [name of copyright owner] 18 0 stevel * 19 0 stevel * CDDL HEADER END 20 0 stevel */ 21 2685 akolb 22 0 stevel /* 23 9123 john * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24 0 stevel * Use is subject to license terms. 25 9966 Menno * 26 9966 Menno * Portions Copyright 2009 Chad Mynhier 27 0 stevel */ 28 0 stevel 29 0 stevel #ifndef _PRSTAT_H 30 0 stevel #define _PRSTAT_H 31 0 stevel 32 0 stevel #include <sys/sysmacros.h> 33 0 stevel #include <sys/time.h> 34 0 stevel #include <sys/types.h> 35 0 stevel #include <procfs.h> 36 0 stevel 37 0 stevel #ifdef __cplusplus 38 0 stevel extern "C" { 39 0 stevel #endif 40 0 stevel 41 0 stevel /* 42 0 stevel * FRC2PCT macro is used to convert 16-bit binary fractions in the range 43 0 stevel * 0.0 to 1.0 with binary point to the right of the high order bit 44 0 stevel * (i.e. 1.0 == 0x8000) to percentage value. 45 0 stevel */ 46 0 stevel 47 0 stevel #define FRC2PCT(pp) (((float)(pp))/0x8000*100) 48 0 stevel 49 0 stevel #define TIME2NSEC(__t)\ 50 0 stevel (hrtime_t)(((hrtime_t)__t.tv_sec * (hrtime_t)NANOSEC) + (hrtime_t)__t.tv_nsec) 51 0 stevel #define TIME2SEC(__t)\ 52 0 stevel (hrtime_t)(__t.tv_sec) 53 0 stevel 54 0 stevel /* 55 0 stevel * List of available output modes 56 0 stevel */ 57 0 stevel #define OPT_PSINFO 0x0001 /* read process's data from "psinfo" */ 58 0 stevel #define OPT_LWPS 0x0002 /* report about all lwps */ 59 0 stevel #define OPT_USERS 0x0004 /* report about most active users */ 60 0 stevel #define OPT_UNUSED 0x0008 /* reserved for future use */ 61 0 stevel #define OPT_REALTIME 0x0010 /* real-time scheduling class flag */ 62 0 stevel #define OPT_MSACCT 0x0020 /* microstate accounting flag */ 63 0 stevel #define OPT_TERMCAP 0x0040 /* use termcap data to move cursor */ 64 0 stevel #define OPT_SPLIT 0x0080 /* split-screen mode flag */ 65 0 stevel #define OPT_TTY 0x0100 /* report results to tty or file */ 66 0 stevel #define OPT_FULLSCREEN 0x0200 /* full-screen mode flag */ 67 0 stevel #define OPT_USEHOME 0x0400 /* use 'home' to move cursor up */ 68 0 stevel #define OPT_TASKS 0x0800 /* report about system tasks */ 69 0 stevel #define OPT_PROJECTS 0x1000 /* report about system projects */ 70 0 stevel #define OPT_ZONES 0x2000 /* report about zones */ 71 0 stevel #define OPT_PSETS 0x4000 /* report for specified psets */ 72 2685 akolb #define OPT_LGRP 0x8000 /* report home lgroups */ 73 9123 john #define OPT_UDATE 0x20000 /* print unix timestamp */ 74 9123 john #define OPT_DDATE 0x40000 /* print timestamp in date(1) format */ 75 9966 Menno #define OPT_NORESOLVE 0x80000 /* no nsswitch lookups */ 76 0 stevel 77 0 stevel /* 78 0 stevel * Flags to keep track of process or lwp status 79 0 stevel */ 80 0 stevel #define LWP_ALIVE 0x0008 /* this pid/lwp still exists */ 81 0 stevel #define LWP_REPRESENT 0x0010 /* this LWP represents the process */ 82 0 stevel 83 0 stevel /* 84 0 stevel * Possible list types 85 0 stevel */ 86 0 stevel #define LT_LWPS 0x0001 87 0 stevel #define LT_USERS 0x0002 88 0 stevel #define LT_TASKS 0x0004 89 0 stevel #define LT_PROJECTS 0x0008 90 0 stevel #define LT_ZONES 0x0010 91 2685 akolb #define LT_LGRPS 0x0020 92 0 stevel 93 0 stevel /* 94 0 stevel * Linked list of per-process or per-lwp statistics 95 0 stevel */ 96 0 stevel typedef struct lwp_info { 97 0 stevel psinfo_t li_info; /* data read from psinfo file */ 98 0 stevel prusage_t li_usage; /* data read from usage file */ 99 0 stevel ulong_t li_key; /* value of the key for this lwp */ 100 0 stevel int li_flags; /* process/lwp flags */ 101 0 stevel float li_usr; /* user level CPU time */ 102 0 stevel float li_sys; /* system call CPU time */ 103 0 stevel float li_trp; /* other system trap CPU time */ 104 0 stevel float li_tfl; /* text page fault sleep time */ 105 0 stevel float li_dfl; /* data page fault sleep time */ 106 0 stevel float li_lck; /* user lock wait sleep time */ 107 0 stevel float li_slp; /* all other sleep time */ 108 0 stevel float li_lat; /* wait-cpu (latency) time */ 109 0 stevel ulong_t li_vcx; /* voluntary context switches */ 110 0 stevel ulong_t li_icx; /* involuntary context switches */ 111 0 stevel ulong_t li_scl; /* system calls */ 112 0 stevel ulong_t li_sig; /* received signals */ 113 0 stevel struct lwp_info *li_next; /* pointer to next lwp */ 114 0 stevel struct lwp_info *li_prev; /* pointer to previous lwp */ 115 0 stevel } lwp_info_t; 116 0 stevel 117 0 stevel /* 118 2685 akolb * Linked list of collective per-uid, per-taskid, per-projid or per-lgroup 119 2685 akolb * statistics 120 0 stevel */ 121 0 stevel typedef struct id_info { 122 0 stevel uid_t id_uid; /* user id */ 123 0 stevel taskid_t id_taskid; /* task id */ 124 0 stevel projid_t id_projid; /* project id */ 125 0 stevel zoneid_t id_zoneid; /* zone id */ 126 2685 akolb int id_lgroup; /* lgroup id */ 127 0 stevel uint_t id_nproc; /* number of processes */ 128 3247 gjelinek boolean_t id_sizematch; /* size/rssize from getvmusage() */ 129 0 stevel size_t id_size; /* memory usage */ 130 0 stevel size_t id_rssize; /* resident set size */ 131 0 stevel ulong_t id_time; /* cpu time (in secs) */ 132 0 stevel float id_pctcpu; /* percentage of cpu usage */ 133 0 stevel float id_pctmem; /* percentage of memory usage */ 134 0 stevel ulong_t id_key; /* sort key value */ 135 0 stevel struct id_info *id_next; /* pointer to next entry */ 136 0 stevel struct id_info *id_prev; /* pointer to previous entry */ 137 0 stevel } id_info_t; 138 0 stevel 139 0 stevel typedef ulong_t (*keyfunc_t)(void *); 140 0 stevel 141 0 stevel /* 142 0 stevel * Per-list structure 143 0 stevel */ 144 0 stevel typedef struct list { 145 0 stevel int l_type; /* list type */ 146 0 stevel int l_count; /* number of entries in the list */ 147 0 stevel void *l_head; /* pointer to the head of the list */ 148 0 stevel void *l_tail; /* pointer to the tail of the list */ 149 0 stevel 150 0 stevel int l_size; /* number of allocated pointers */ 151 0 stevel int l_used; /* number of used pointers */ 152 0 stevel int l_sortorder; /* sorting order for the list */ 153 0 stevel keyfunc_t l_func; /* pointer to key function */ 154 0 stevel void **l_ptrs; /* pointer to an array of pointers */ 155 0 stevel } list_t; 156 0 stevel 157 0 stevel /* 158 0 stevel * Command line options 159 0 stevel */ 160 0 stevel typedef struct optdesc { 161 0 stevel int o_interval; /* interval between updates */ 162 0 stevel int o_ntop; /* number of lines in top half */ 163 0 stevel int o_nbottom; /* number of lines in bottom half */ 164 0 stevel int o_count; /* number of iterations */ 165 0 stevel int o_outpmode; /* selected output mode */ 166 0 stevel int o_sortorder; /* +1 ascending, -1 descending */ 167 0 stevel } optdesc_t; 168 0 stevel 169 0 stevel #ifdef __cplusplus 170 0 stevel } 171 0 stevel #endif 172 0 stevel 173 0 stevel #endif /* _PRSTAT_H */ 174