j From:	HENRY::IN%"bruceb%telesoft.UUCP%sdcsvax.ucsd.edu%sri-kl.ARPA%relay.cs.net@rca.com" 18-MAR-1987 09:40) To:	sri-kl.arpa!info-vax@sdcsvax.ucsd.edu % Subj:	An enhanced SHOW SYSTEM utility   @ It occurred to me the other day that I have been using this neat@ utility for viewing processes (similar to SHOW SYSTEM), and that+ there are others who may like this program.   > Enclosed you will find a DCL archive which contains two files:  	 	bigsis.c  	bigsis.man   = The .c file should be compiled with DEC C V2.0 or greater, on @ VMS V4.2 or greater.  I wrote this to run on that configuration,? and since I no longer have access to a C compiler, I can't tell ? you if it compiles on anything else.  However, if you get it to ? compile, it will tell you all sorts of useful information about 8 the jobs currently running on your system (not cluster).  @ It was written as a quick hak, and I never got around to putting? in all the features I wanted (like ability to work on 80 column @ displays, selective process info, etc).  It has one bug.  If you? run it on a non-clustered environment, it won't display the sub ? process parent information correctly.  This can be fixed easily = as it is in a small routine at the bottom of the code.  Other @ than that, there are no known bugs.  Read the man page to get an idea of what it will tell you.  ? I'd be interested in hearing from you if you like the program!!   > I've got a bunch of other nifty utilities I wrote, which I may= post at a later date.  I'd like to see how this one goes over > first, though.  Oh yes, the means of collecting the files into> one 'archive' is my own design.  I didn't have any of the shar@ programs running around, so I wrote my own.  Hope it works okay.  7 Comments, suggestions, flames, etc., can be sent to me.   
 bruce bergman I $ !------------------------------ cut here ------------------------------ 
 $ set noon $ on control then goto YOU_QUIT  $ on error then goto I_QUIT  $ file = "BIGSIS.C"  $ chksum = 309885657 $ pass_fail = "FAILED" N $ write sys$output "Extracting ""''file'"" - original checksum was: ''chksum'" $ create/nolog 'file'   $ deck/dollars="EoF@11:34:11.17"I /************************************************************************   *									*  *				B I G S I S				*  *									*I  ************************************************************************   I ** PURPOSE -------------------------------------------------------------- / 	Show VMS system/process information concisely.   I ** PACKAGE --------------------------------------------------------------  	VAX/VMS BIGSIS   I ** HISTORY -------------------------------------------------------------- * 	1.0	01-Jun-85	Creation (Bruce A. Bergman)4 	1.1	27-Jun-85	Added ability to see process children( 				and parent id's.  (Bruce A. Bergman)4 	1.1a	10-Sep-85	Suspended processes were hanging the) 				program so added code to display them % 				and continue.  (Bruce A. Bergman)   I ** NON-DISCLOSURE ------------------------------------------------------- ; 	This program can be copied or modified, not for profit, as ; 	long as this disclosure notice and author/edit information : 	remain with the source code at all times.  No use of this> 	software or its associated source is permitted for commercial0 	or personal monetary gain (profit) in any form.7 	The author of this software is not responsible for any 8 	repercussions that may arise from use of this software.6 	Bugs and/or suggestions may be sent to the author at:   		Bruce A. Bergman" 		460 East Washington Avenue, #109 		Escondido, CA.  92025-2958 		(619) 489-8195 		fido: 103/203 " 		uucp: ...sdcsvax!telesoft!bruceb  I ** CODE -------------------------------------------------------------- */    #include <stdio.h> #include <descrip.h> #include <ssdef.h> #include <jpidef.h>    /*6 |	These weren't identified in the sys$library:jpidef.h! |	files so they MUST be included.  */   globalvalue JPI$_CLINAME;  globalvalue JPI$_MODE; globalvalue JPI$K_OTHER; globalvalue JPI$K_INTERACTIVE; globalvalue JPI$K_BATCH; globalvalue JPI$K_NETWORK; globalvalue JPI$_MASTER_PID; globalvalue JPI$_MAXDETACH;  globalvalue JPI$_MAXJOBS;    #include <pcbdef.h>  #include <statedef.h>   ; main(argc, argv)		/* show vms system/process information */ 	 int argc; 
 char *argv[];  {    	struct _itmlst {  		unsigned short int buf_len;  		unsigned short int item_code;  		unsigned int buf_addr; 		unsigned int ret_len;  	} item_list[20];  	char	username[13],  		procname[16],  		terminal[9], 		cliname[128],  		states[6],
 		subs[6], 		cputime[10], 		imag_name[132],  		image_name[50];  	float	fcputim; 	 	unsigned  	int	ret_flag, 		pid,
 		cur_pid, 		mem, 		pri, 		prib, 	 		cputim,  		susp_flag,	 		ppgcnt,  		sts, 		state, 		mode, 
 		master_pid,  		jobprccnt, 		owner, 		all_p, 		net_w, 		iosb; 	 	unsigned  	short
 	int	maxjobs;    		/*/ 		|	Set our options to none (until we evauluate , 		|	them and determine that some are wanted. 		*/   	all_p = net_w = FALSE;    		/*- 		|	Check arguments for all possible info (a) , 		|	or just network info (n).  If no options1 		|	just display the normal stuff.  'ALL' assumes ! 		|	user wants network info also.  		*/  % 	if (argc > 1 && argv[1][0] == '-') { . 			if (argv[1][1] == 'a' || argv[1][1] == 'A') 				all_p = net_w = TRUE; . 			if (argv[1][1] == 'n' || argv[1][1] == 'N') 				net_w = TRUE;  	}   		/*) 		|	Set up item list with the information  		|	we want.  This includes:
 		|		Username  		|		Process name  		|		Process identification  		|		Amount of memory used 		|		Priority (current)  		|		Priority (base)
 		|		CPU time  		|		Page count for image  		|		Virtual terminal id	 		|		Mode 
 		|		CLI name  		|		Job status  		|		Job state 		|		Process parent's PID   		|		Sub-process count (current) 		|		Sub-process count (max) 		|		PID of owner of job 		|		Image name  		*/   	item_list[0].buf_len = 12; ( 	item_list[0].item_code = JPI$_USERNAME;" 	item_list[0].buf_addr = username; 	item_list[0].ret_len = 0;   	item_list[1].buf_len = 15; & 	item_list[1].item_code = JPI$_PRCNAM;" 	item_list[1].buf_addr = procname; 	item_list[1].ret_len = 0;   	item_list[2].buf_len = 4;# 	item_list[2].item_code = JPI$_PID;  	item_list[2].buf_addr = &pid; 	item_list[2].ret_len = 0;   	item_list[3].buf_len = 4;# 	item_list[3].item_code = JPI$_MEM;  	item_list[3].buf_addr = &mem; 	item_list[3].ret_len = 0;   	item_list[4].buf_len = 4;# 	item_list[4].item_code = JPI$_PRI;  	item_list[4].buf_addr = &pri; 	item_list[4].ret_len = 0;   	item_list[5].buf_len = 4;$ 	item_list[5].item_code = JPI$_PRIB; 	item_list[5].buf_addr = &prib;  	item_list[5].ret_len = 0;   	item_list[6].buf_len = 4;& 	item_list[6].item_code = JPI$_CPUTIM;! 	item_list[6].buf_addr = &cputim;  	item_list[6].ret_len = 0;   	item_list[7].buf_len = 4;& 	item_list[7].item_code = JPI$_PPGCNT;! 	item_list[7].buf_addr = &ppgcnt;  	item_list[7].ret_len = 0;   	item_list[8].buf_len = 8;( 	item_list[8].item_code = JPI$_TERMINAL;" 	item_list[8].buf_addr = terminal; 	item_list[8].ret_len = 0;   	item_list[9].buf_len = 4;$ 	item_list[9].item_code = JPI$_MODE; 	item_list[9].buf_addr = &mode;  	item_list[9].ret_len = 0;   	item_list[10].buf_len = 39;( 	item_list[10].item_code = JPI$_CLINAME;" 	item_list[10].buf_addr = cliname; 	item_list[101].ret_len = 0;   	item_list[11].buf_len = 4; $ 	item_list[11].item_code = JPI$_STS; 	item_list[11].buf_addr = &sts;  	item_list[11].ret_len = 0;    	item_list[12].buf_len = 4; & 	item_list[12].item_code = JPI$_STATE;! 	item_list[12].buf_addr = &state;  	item_list[12].ret_len = 0;    	item_list[13].buf_len = 4; + 	item_list[13].item_code = JPI$_MASTER_PID; & 	item_list[13].buf_addr = &master_pid; 	item_list[13].ret_len = 0;    	item_list[14].buf_len = 4; * 	item_list[14].item_code = JPI$_JOBPRCCNT;% 	item_list[14].buf_addr = &jobprccnt;  	item_list[14].ret_len = 0;    	item_list[15].buf_len = 2; ( 	item_list[15].item_code = JPI$_MAXJOBS;# 	item_list[15].buf_addr = &maxjobs;  	item_list[15].ret_len = 0;    	item_list[16].buf_len = 4; & 	item_list[16].item_code = JPI$_OWNER;! 	item_list[16].buf_addr = &owner;u 	item_list[16].ret_len = 0;d   	item_list[17].buf_len = 132;.) 	item_list[17].item_code = JPI$_IMAGNAME;o$ 	item_list[17].buf_addr = imag_name; 	item_list[17].ret_len = 0;t   		/*( 		|	Signal no more information required. 		*/   	item_list[18].buf_len = 0;c   		/* 		|	Print formatted headers. 		*/  Q 	printf("%-8s %-12s %-15s %-8s ", "PID", "Username", "Process name", "Terminal");iT 	printf("%-5s %-7s %-9s %-5s %-5s ", "Sub's", "Pri's", "CPU time", "State", "Size");! 	printf("%-11s\n", "Image name"); ; 	printf("-------- ------------ --------------- -------- "); 0 	printf("----- ------- --------- ----- ----- ");? 	printf("-------------------------------------------------\n");    		/*+ 		|	We want information from all processes.f 		*/   	cur_pid = -1; 	while (1) {   			/*r) 			|	Set a flag saying we this process isw, 			|	NOT suspended (we handle this special). 			*/p   		susp_flag = FALSE;   			/*t, 			|	Call $GETJPI to obtain the actual info. 			*/e  B 		ret_flag = sys$getjpi(32, &cur_pid, 0, &item_list, &iosb, 0, 0);   			/*n4 			|	If $GETJPI says this process is suspended, mark5 			|	it as such and pretend like it is okay - we will  			|	deal with it later. 			*/o  " 		if (ret_flag == SS$_SUSPENDED) { 			ret_flag |= SS$_NORMAL; 			susp_flag = TRUE; 		}a   			/*i2 			|	If $GETJPI says everything was 'queued' okay,2 			|	let's wait until VMS says it has given us all, 			|	the info we requested (we're being nice, 			|	to VMS since we could have not waited). 			*/    		if (ret_flag & SS$_NORMAL) { 			if (susp_flag == FALSE) { 				ret_flag = sys$waitfr(32); 				if (!ret_flag & SS$_NORMAL)  					sys$exit(ret_flag); 			}   				/*. 				|	Everything is okay, so now check and see# 				|	if this job is at a terminal.t 				*/   			if (terminal[0] == 0)   					/*-( 					|	If this job is a batch job, check, 					|	its pid with its parent pid.  If they) 					|	match, then this is a spawned job. - 					|	If they don't match, it must be batch.s 					*/F   				if (mode & PCB$V_BATCH)x 					if (master_pid == pid)a" 						strcpy(terminal, "*BATCH*");	 					elsee" 						strcpy(terminal, "Spawned"); 				else   						/*, 						|	This job is interactive (not batch).' 						|	If this job is a network server	( 						|	and the user wants to know about' 						|	networks, say so.  If we aren't*) 						|	network then if the user wants to-* 						|	know about all jobs, then announce 						|	system jobs too. 						*/  & 					if (net_w && mode & PCB$V_NETWRK)" 						strcpy(terminal, "Network");	 					else- 						if (all_p)$ 							strcpy(terminal, "[System]");
 						else 							continue;   				/*9 				|	If this job has no children, set a value indicating-< 				|	how many children are possible out of the max allowed. 				*/ 				 			if (master_pid == pid)p 				if (jobprccnt > 0)3 					sprintf(subs, "%2d/%-2d", jobprccnt, maxjobs);  				else 					strcpy(subs, "     ");  			elseD   					/*-< 					|	If this job has children, place the last 4 characters< 					|	of the parent pid into the process count area instead= 					|	of indicating how many the job could have.  This makes 2 					|	it easier to track down children processes. 					*/    				set_sub(subs, owner);e   				/* 				|	Set process state. 				*/   			set_state(states, state);   				/*+ 				|	If user is not running an image, then + 				|	check to see if it has a CLI, if not,s/ 				|	it must be a dead system process so placet 				|	defunct into image slot.6 				|	Otherwise display the CLI name when appropriate. 				*/   			if (imag_name[0] == 0)	 				if (cliname[0] == 0)& 					sprintf(image_name, "<defunct>"); 				else* 					sprintf(image_name, "(%s)", cliname); 			else    					/*<+ 					|	Now we see if the job was suspended.e, 					|	If it was, make it obvious to all and- 					|	change state to relfect type of MWAIT.i. 					|	Otherwise just copy the image name into6 					|	the slot (truncating and parsing as necessary). 					*/;   				if (susp_flag == TRUE) { 					strcpy(states, "SUSP");+ 					sprintf(image_name, "[Out To Lunch]");S 				}; 				else% 					set_name(image_name, imag_name);M   				/*0 				|	Change CPU time to float so we can display1 				|	it as a decimal value rather than time; itsa1 				|	easier to see change that way (who says?!).  				*/   			fcputim = cputim;   				/*+ 				|	If no username, just defunct it also.d 				*/   			if (username[0] == 0)" 				strcpy(username, "<defunct>");   				/*+ 				|	At long last, time to print the info.[3 				|	Format everything so my sense of taste is notm4 				|	offended and make sure all process id's are in8 				|	hexadecimal and hope the CPU time never gets HUGE. 				*/  G 			printf("%-8x %-12s %-15s %-8s ", pid, username, procname, terminal);	Z 			printf("%-5s %3d/%-3d %9.2f %-5s %-5d ", subs, pri, prib, fcputim/100, states, ppgcnt);! 			printf("%-49s\n", image_name);i   				/*( 				|	Go get another process until done. 				*/   			continue; 		}	   			/*l; 			|	Hooray we're done!  Let's clean up and get outta here.s 			*/f  ! 		if (ret_flag == SS$_NOMOREPROC) 	 			break;o   			/*u. 			|	The user has no oper priv so we must just7 			|	skip over this process like a good little program.& 			*/]   		if (ret_flag == SS$_NOPRIV)  			continue;   			/* + 			|	Some unknown nasty has interrupted our[- 			|	session (how rude!).  Let VMS handle it.  			*/    		sys$exit(ret_flag);e 	}   }t  J set_state(destin, state)		/* turn process state code into readable form */
 char *destin;o unsigned int state;  {	   		/*. 		|	Assume we don't know what state we are in. 		*/   	strcpy(destin, "?????");	  3 		/*	Start evaluating states until we find a match.M5 		|	Note: we could have done this with a switch() had 6 		|	these not been gloabalvalues.  We're really better6 		|	off this way and we don't loose any functionality. 		*/   	if (state == SCH$C_CEF) 		strcpy(destin, "CEF"); 	if (state == SCH$C_COM) 		strcpy(destin, "COM"); 	if (state == SCH$C_COMO)  		strcpy(destin, "COMO");  	if (state == SCH$C_CUR) 		strcpy(destin, "CUR"); 	if (state == SCH$C_COLPG) 		strcpy(destin, "COLPG"); 	if (state == SCH$C_FPG) 		strcpy(destin, "FPG"); 	if (state == SCH$C_HIB) 		strcpy(destin, "HIB"); 	if (state == SCH$C_HIBO)e 		strcpy(destin, "HIBO");i 	if (state == SCH$C_LEF) 		strcpy(destin, "LEF"); 	if (state == SCH$C_LEFO)u 		strcpy(destin, "LEFO");3 	if (state == SCH$C_MWAIT) 		strcpy(destin, "MWAIT"); 	if (state == SCH$C_PFW) 		strcpy(destin, "PFW"); 	if (state == SCH$C_SUSP)e 		strcpy(destin, "SUSP");_ 	if (state == SCH$C_SUSPO) 		strcpy(destin, "SUSPO");   		/* 		|	Return pointer to state5 		*/   	return (destin);t   }u  > set_sub(destin, pid)		/* evaulate and set parent process id */
 char *destin;t unsigned int pid;. {_   	char	temp[9]; 	int	i;u   		/*$ 		|	Print the parent process id into# 		|	a holding region and put 'P' att* 		|	first char position so user knows that% 		|	the number following is a PARENT!d 		*/   	sprintf(temp, "%-8x", pid); 	*destin = 'P';    		/*0 		|	Copy the last 4 characters in the parent pid/ 		|	into destination.  If pid was 0, just blank92 		|	out (occurs in some defunct system processes). 		*/   	for (i = 1; i <= 4; i++)_ 		*(destin+i) = temp[i+3]; 	*(destin+i) = '\0'; 	if (pid == 0) 		*destin = '\0';1   		/*% 		|	Return pointer to process string.  		*/   	return (destin);J   }T  < set_name(destin, source)	/* parse and truncate image name */ char *destin, *source; {n  	 	int pos;_   		/*2 		|	Search for first occurence of a directory spec0 		|	searching from the end backwards.  This will5 		|	get rid of long (like in VMS 4.x) disk pathnames.A: 		|	Note: look to "SHOW DEVICE/FILES/NOSYSTEM" to see what 		|	is on which disk.  		*/   	pos = strrchr(source, '[');   		/*2 		|	Only copy the next 49 characters (so won't run 		|	off end of 132 col screen).t 		*/   	strncpy(destin, pos, 49);   		/*% 		|	Return pointer to the image name.; 		*/   	return (destin);    }o EoF@11:34:11.171 $ checksum 'file' @ $ if 'chksum' .eq. 'checksum$checksum' then pass_fail = "PASSED"R $ write sys$output "    Computed checksum is: ''checksum$checksum' (''pass_fail')" $ file = "BIGSIS.MAN"e $ chksum = 979708107 $ pass_fail = "FAILED"iN $ write sys$output "Extracting ""''file'"" - original checksum was: ''chksum'" $ create/nolog 'file'i  $ deck/dollars="EoF@11:35:48.99"  O BIGSIS(1)                      VAX/VMS Utilities                     BIGSIS(1) -       NAME4      bigsis - display system and process information      s SYNOPSIS      bigsis [ -an ]i      P DESCRIPTIONtO      Bigsis displays  VAX/VMS system and process information.  The information -O      taken is a 'snapshot' of the system at the moment the request was  given. pO      The -a option asks for information about all processes, including defunct nO      ones.  The -n option asks that network processes be included as  part  of rO      the display  (they  are not normally).  Specifying the -a option includes sO      the -n option automatically.   Bigsis  is  formatted  for  a  132  column h      screen.    5      The information returned to the user includes:  l      oO           PID       The process  id  of  the  current  process.  The PID is in i+                     hexadecimal notation.  l                     O           USERNAME  The username is the actual login name that was used.    It  O                     will  never  change,  whereas  the process name CAN change 'O                     during the process' session.  The username may  appear  as eO                     "<defunct>"  if  the  process  is a defunct system process 	.                     (e.g.  NULL or SWAPPER).                       O           NAME      The process name can be changed by the user, but initially  O                     is identical to the username unless more than one  process  6                     already share the same username.                       O           TERMINAL  The  terminal  name (a virtual keyboard id under VMS V4.x) 	O                     will appear if the process is an active job connected to a tY                     physical terminal.  If the job is a _b_a_t_c_h job, the special tO                     identifier  "*BATCH*"  will  be  shown  in  place  of  the  O                     terminal name.    If  the  process  belongs  to the system nO                     (created  by  the  system),  "[SYSTEM]"  appears  in  this o]                     column.   If  the process is _s_p_a_w_n_e_d from another process,  O                     "Spawned" is displayed and the user is  shown  the  parent TO                     process   in  the  adjecent  column  (see  SUBS  for  more r                     detail).                       O           SUBS      If a job has been spawned by this process, a count appears oO                     that shows how many processes have been  spawned  and  how _O                     many processes   CAN  be  spawned.    The  two  pieces  of aO                     information are separated by a slash (/).  If the  maximum  O                     number  of  possible sub-processes is zero, then unlimited  O                     processes may be spawned.    Note  that  this  information  U                     appears for the _p_a_r_e_n_t of the spawned process only.  u  Y                     If  the  process  is  a _c_h_i_l_d of another process, then the  O                     special identifier "Pxxxx" is displayed  in  this  column, hO                     where  xxxx  refers to the last four (4) characters of the cK                     parent process.  The characters are also hexadecimal.  	                     O           PRIORITY  The priority of the  current  process  is  shown  in  this 	O                     column, in  the  form  xx/xx.   The first xx refers to the NO                     process' CURRENT priority.  The second xx  refers  to  the d    M                                     - 1 -                                    a  n    O BIGSIS(1)                      VAX/VMS Utilities                     BIGSIS(1) (      -                     process' BASE priority.  	                     O           CPUTIME   The  amount  of  CPU  time  the process has accumulated is  O                     displayed as an  integer  rather  than  an  actual  'time' aO                     value.    The   decimal   place   separates  seconds  from 	O                     hundredth's of seconds.  Later, when cows fly,  the  value o9                     may be converted to an actual time.  ,                     O           STATE     The  current  state  that the process was in at the moment eO                     the 'snapshot' was taken is displayed as an abbreviation.  	O                     Refer to the VAX/VMS System Routines manual for a complete 2O                     description of each state.    The  special  state,  "SUSP" .O                     appears  when  a  process  has  been  suspended  for  some nO                     reason.  If this is the case, the image name  will  appear 	L                     as "[Out To Lunch]" to bring attention to the process.                       O           SIZE      The  size (in pages) of the image that the current process eO                     is executing is displayed.  This is an  approximate  value  O                     and  should  not be construed as an accurate reflection of w%                     the image size.  i                     O           IMAGE     The image name is displayed for the current process, if it tO                     is executing an image.  Otherwise, if the process  is  not iO                     suspended  (see  the STATE column for more detail), and if sO                     it is not a  defunct  system  process,  the  CLI  (Command  O                     Language Interpreter) for the current process is displayed lO                     enclosed in  parenthesis.    If  the  process is a defunct tM                     system process, "<defunct>" will appear in this column.  C  O                     The image name, if displayed, is parsed and  truncated  to OW                     show only the _l_a_s_t directory specification and the next 49 	O                     characters (e.g.      [SYSEXE]BIGSIS.EXE;1   rather   than  1                     DUA0:[SYSEXE]BIGSIS.EXE;1).                        
      BUGS O           Bigsis requires that the user have appropriate privileges to  obtain =O           information about  other processes.  If the user does not have these dI           privileges, only the user's process information is displayed.  s  O           The CPU time value is really not perfect, but it is easier to see  a cO           change in  the  value  in  this form.  I hope the process time never i@           exceeds the what can be stored as a 32 bit longword!    O           Finally, the parsing of the image name to fit on the screen  can  be 	O           deceptive,  in  that  an  image from one directory can be on several 	O           disks and never appear different from the bigsis display.  I suggest  L           using "SHOW DEVICE/FILES/NOSYSTEM" for process-disk information.                          M                                     - 2 -                                    n  m   EoF@11:35:48.99o $ checksum 'file'f@ $ if 'chksum' .eq. 'checksum$checksum' then pass_fail = "PASSED"R $ write sys$output "    Computed checksum is: ''checksum$checksum' (''pass_fail')" $ write sys$output "Finished." $ exit
 $YOU_QUIT:5 $ write sys$output "Aborting upon request of user..."  $ exit $I_QUIT:A $ write sys$output "Encountered a fatal condition - aborting..."  $ exitI $ !------------------------------ cut here ------------------------------n