$! $! WORKING_SET.COM - Command file to display working set information. $! Requires 'WORLD' privilege to display information $! on processes other than your own. $! $! Use the P1 parameter to specify the PID of a single $! process for which working set information is desired. $! $! Omitting the P1 parameter produces a display of working $! set information for all processes which you are privileged $! to see. $! $! The next symbol is used to insert quotes into command strings; $! because of the way DCL processes quotes, you cannot have a $! trailing comment after the quotes on the next line. $! $ quote = """ $! $ pid = "" ! initialize to blank $ context = "" ! initialize to blank $! $! Check to see if this procedure was invoked with the PID of $! one specific process to check. If it was, use that PID. If $! not, the procedure will scan for all PIDs where there is $! sufficient privilege to fetch the information. $! $ IF p1 .NES. "" THEN pid = p1 $! $! Write out a header. $! $ WRITE sys$output - " Working Set Info (in pagelets)" $ WRITE sys$output "" $ WRITE sys$output - " WS WS WS WS Pagelets Page" $ WRITE sys$output - "Username Processname State Extent Quota Default Limit in WS faults Image" $ WRITE sys$output "" $! $! Begin collecting information. $! $ collect_loop: $! $ IF P1 .EQS. "" THEN pid = F$PID (context) ! get this process' PID; $ IF pid .EQS. "" THEN EXIT ! if blank, no more to $! ! check, or no privilege. $ pid = quote + pid + quote ! enclose in quotes $! $ username = F$GETJPI ('pid, "USERNAME") ! retrieve proc. info. $! $ IF username .EQS. "" THEN GOTO collect_loop ! if blank, no priv.; try $! ! next PID $ processname = F$GETJPI ('pid, "PRCNAM") $ imagename = F$GETJPI ('pid, "IMAGNAME") $ imagename = F$PARSE (imagename,,,"NAME") ! separate the name from the filespec $ state = F$GETJPI ('pid, "STATE") $ wsdefault = F$GETJPI ('pid, "DFWSCNT") $ wsquota = F$GETJPI ('pid, "WSQUOTA") $ wsextent = F$GETJPI ('pid, "WSEXTENT") $ wssize = F$GETJPI ('pid, "WSSIZE") $ globalpages = F$GETJPI ('pid, "GPGCNT") $ processpages = F$GETJPI ('pid, "PPGCNT") $ pagefaults = F$GETJPI ('pid, "PAGEFLTS") $! $ pages = globalpages + processpages ! add pages together $! $! Format the information into a text string $! $ text = F$FAO("!13AS!16AS!6AS!5(9SL)!9SL !AS",- username,processname,state,wsextent,wsquota,wsdefault,wssize,- pages,pagefaults,imagename) $! $ WRITE sys$output text ! display information $! $ IF p1 .NES. "" THEN EXIT ! if invoked for a $! ! specific PID, we're done. $ GOTO collect_loop ! repeat for next PID $! $! End of WORKING_SET.COM $!