Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!columbia!rutgers!ames!ucbcad!ucbvax!a.cs.okstate.EDU!usenet From: usenet@a.cs.okstate.EDU (The News System) Newsgroups: mod.computers.vax Subject: Submission for mod-computers-vax Message-ID: <8703161908.AA05505@cbosgd.MIS.OH.ATT.COM> Date: Sat, 14-Mar-87 02:09:42 EST Article-I.D.: cbosgd.8703161908.AA05505 Posted: Sat Mar 14 02:09:42 1987 Date-Received: Fri, 20-Mar-87 03:38:26 EST Sender: daemon@ucbvax.BERKELEY.EDU Distribution: world Organization: The ARPA Internet Lines: 375 Approved: info-vax@sri-kl.arpa Path: okstate!gregg From: gregg@a.cs.okstate.edu (Gregg Wonderly) Newsgroups: mod.computers.vax Subject: Active Operator Terminals Keywords: VAX VMS operator Message-ID: <1695@a.cs.okstate.edu> Date: 14 Mar 87 07:09:41 GMT Organization: Oklahoma State Univ., Stillwater Lines: 365 Below is a modified version of the SHOW-OPERATORS macro program posted a while back. This particular version displays a little more information about each terminal, such as it's physical device, the username of the user logged onto the terminal, and the UIC of the process active there. Gregg Wonderly Department of Computing and Information Sciences Oklahoma State University UUCP: {cbosgd, ea, ihnp4, isucs1, mcvax, uokvax}!okstate!gregg ARPA: gregg@A.CS.OKSTATE.EDU -------------------------------- CUT HERE ------------------------------- $ show default $ write sys$output "Creating MAKE.COM" $ create MAKE.COM $ DECK/DOLLARS="*$*$*EOD*$*$*" $! $! Compile and/or install OPERS.EXE $! $ IF P1 .EQS. "" THEN P1="COMPILE" $ P1=","+P1+"," $ N=1 $ NEXT: $ WHAT = F$ELEMENT(N,",",P1) $ IF (WHAT .NES. "") .AND. (WHAT .NES. ",") THEN GOTO 'WHAT' $ GOTO DONE $! $ COMPILE: $ V=F$VERIFY(1) $ MACRO OPERS+SYS$LIBRARY:LIB/LIB $ LINK OPERS,SYS$SYSTEM:SYS.STB/SELECT $ N=N+1+(0*'F$VERIFY(V)') $ GOTO NEXT $! $ INSTALL: $ V=F$VERIFY(1) $ COPY OPERS.EXE EXE$DIR:OPERS.EXE $ N=N+1+(0*'F$VERIFY(V)') $ GOTO NEXT $! $ DONE: $ EXIT *$*$*EOD*$*$* $ write sys$output "Creating OPERS.MAR" $ create OPERS.MAR $ DECK/DOLLARS="*$*$*EOD*$*$*" .title show_operators See what operators are enabled. .sbttl documentation ;+++ ; This routine diplays the enabled operators. Sorry that it's ; not well documented or clean, it was a quick hack. R. Wells ; ; AUTHORS: ; ; R. WELLS ; ; CREATION DATE: 10-OCT-1985 ; ; ; C H A N G E L O G ; ; Date | Name | Description ;---------------+----------+--------------------------------------------------- ; 10-OCT-1985 | WELLS | ORIGINAL RELEASE ;---------------+----------+--------------------------------------------------- ; 23-Feb-1987 | Gerber | Have the program use CMKRNL temporarily so the ; | | number of funny results are reduced. ; | | Also get the UNIT number from the UCB instead of a ; | | local counter as units do not have to be ; | | contiguous! ;---------------+----------+--------------------------------------------------- ; 03-Mar-1987 | Wonderly | Add some real formating, and print out other ; | | useful information. Don't explicitly enable CMKRNL ;------------------------------------------------------------------------------ ; ; BUILD: ; MACRO SHOWENABLED+SYS$LIBRARY:LIB/LIB ; LINK SHOWENABLED,SYS$SYSTEM:SYS.STB/SEL ; ; INVOKE: ; RUN SHOWENABLED ; ;--- .sbttl data_declarations .psect data, noexe $dcdef ; device class info $ucbdef ; unit control block info $ddbdef ; device data block info $prvdef ; define priv bits $devdef ; define device characteristic bits $dvidef $jpidef .macro infodef,code,len,addr,lenaddr .word len .word code .address addr .address lenaddr .endm buffer: .blkb 512 bufsiz=.-buffer bufdsc: .long bufsiz ; fao output buffer .address buffer faohead: .long headsize .address header header: .ascii \!UL operator!%S at: !%D!/\ .ascii \Terminal!6* Device!12* UIC!21* Username!/!70*-\ headsize=.-header faomsg1: .ascid /!11!3* !8!8* !24!4* !8/ faomsg2: .ascid /!%D No operator terminals enabled./ faomsg3: .ASCID /!AC!ZW/ maxops = 500 ; maximum number of ops ttname: .blkl maxops ; array of saved names ttunit: .blkw maxops ; array of saved units ttcnt: .long 0 termname: .blkb 32 termdescr: .long 32 .address - termname dviblk: infodef DVI$_TT_PHYDEVNAM,64,devname,devnamelen infodef DVI$_PID,4,pid,dumlen .long 0,0 jpiblk: infodef JPI$_USERNAME,14,username,username_len infodef JPI$_UIC,4,ownuic,dumlen .long 0,0 devname: .blkb 64 devnamelen: .long 64 devnamedescr: .long 64 .address - devname ownuic: .long pid: .long username: .blkb 14 userdescr: username_len: .long 0 .address username dumlen: .long 0 ;++ ; ; ;-- .sbttl executable .psect code, exe,nowrt .entry main,^m $cmkrnl_s routin=kernal1 ; Collect the statistics blbs r0,5$ ; Branch if there is no error brw error ; Go to error code 5$: movl ttcnt,r5 ; Get count of operators tstl r5 ; See if zero bgtr 10$ ; Jump if not brw no_operators ; Go to no oper code 10$: movl #bufsiz,bufdsc ; Store descriptor size $fao_s outbuf=bufdsc, - ; Make header in buffer ctrstr=faohead,- p1=r5, p2=#0, - outlen=bufdsc cmpl #SS$_NORMAL,r0 ; Make sure it worked beql 12$ ; Branch if $fao okay brw error ; Go to error code 12$: pushal bufdsc ; Pass buffer descriptor calls #1,g^lib$put_output ; Print the header cmpl #SS$_NORMAL,r0 ; Make sure that worked beql 13$ ; Branch if so brw error ; Go to error code 13$: moval ttname,r3 ; Get names strings moval ttunit,r2 ; Get unit numbers write: movl #32,termdescr ; Restore buffer length $fao_s outbuf=termdescr, - ; Format terminal name ctrstr=faomsg3,- p1=r3,p2=(r2), - outlen=termdescr cmpl #SS$_NORMAL,r0 ; Make sure that worked beql 20$ ; Jump if it did brw error ; To error code 20$: $getdvi_s - ; Get physical device name devnam=termdescr,- itmlst=dviblk cmpl #SS$_NORMAL,r0 ; Make sure that worked beql 30$ ; Jump if it did brw error ; Go to error code 30$: $getjpi_s - ; Given owner pid, get username, and uic pidadr=pid,- itmlst=jpiblk cmpl #SS$_NORMAL,r0 ; Check for normal beql 40$ ; Branch if it is brw error ; Go to error code 40$: movl #username,r7 ; Trim username to no blanks movb #32,r6 movl #0,r1 50$: cmpb r6,(r7)+ beql 60$ incl r1 brb 50$ 60$: movl r1,userdescr ; Store username length in descr movl #bufsiz,bufdsc ; Set FAO buffer size ; ; Format a line of output ; $fao_s outbuf=bufdsc, - ctrstr=faomsg1,- outlen=bufdsc,- p1=R3, p2=(R2), - p3=#devnamedescr, - p4=ownuic, - p5=#userdescr cmpl #SS$_NORMAL,r0 ; Check for normal beql 70$ ; Branch if ok brw error ; Go to error code 70$: pushal bufdsc ; Output line to screen calls #1,g^lib$put_output cmpl #SS$_NORMAL,r0 ; Check for normal bneq error ; Branch if not addl #2,r2 ; Get next unit number addl #4,r3 ; Get next device name sobgtr r5,80$ ; Decrement counter and branch if more $exit_s r0 ; Exit SS$_NORMAL 80$: brw write ; Go to top of loop no_operators: movl #bufsiz,bufdsc ; Format no operators message $fao_s outbuf=bufdsc, - ctrstr=faomsg2,- outlen=bufdsc,- p1=#0 cmpl #SS$_NORMAL,r0 ; Make sure that is ok beql 90$ ; Branch if ok brw error ; Go to error code 90$: pushal bufdsc ; Output message calls #1,g^lib$put_output cmpl #SS$_NORMAL,r0 ; Check for normal bneq error ; Branch if not $exit_s r0 ; Return to system error: pushl r0 ; Pass error code calls #1,g^lib$stop ; Stop with message and trace ret ; ; CMKRNL routine to peek around and get the active terminals. ; .entry kernal1,^m moval nocrash,(fp) ;Establish a kernal mode ; excpetion handler. movl ioc$gl_devlist,r9 ;Get first ddb clrl r6 ;Count of operators 5$: clrl r7 ;Clear unit counter movl ddb$l_ucb(r9),r8 ;Get first ucb on this ddb cmpb ucb$b_devclass(r8),#dc$_term ;Is this a terminal ddb/ucb? bneq 20$ ;branch if not ; ; Check all ucbs on all ddbs, if op bit is set, then save name of terminal, ; for output when we're not in kmode. ; 10$: bbc #dev$v_opr,ucb$l_devchar(r8),15$ ;Operator enabled on this ucb? movl ddb$t_name(r9),ttname[r6] ;get device name movw ucb$w_unit(r8),ttunit[r6] ;get unit name incl r6 ;Bump op count movl r6,ttcnt ;Save it 15$: incl r7 movl ucb$l_link(r8),r8 ;Get next ucb tstl r8 ;More ucbs? bneq 10$ ;if neq, yes 20$: movl ddb$l_link(r9),r9 ;Get next ddb tstl r9 ;More ddbs? bneq 5$ ;if neq, yes movl #ss$_normal,r0 ret ;back to caller ; .sbttl KMODE_EXCEPTION_HANDLER ; ; Provides some reasonable safeguard against crashing your system. ; (From Bruce Elliot, thanks.) ; reason: .long 80 .address 10$ 10$: .blkb 80 control_reason: .ascid /Access violation at VA = !XL & PC = !XL/ .entry nocrash,^m movl 4(ap),r2 ;Get address of signal array cmpl 4(r2),#ss$_accvio ;if it's an access violation, ; display and get out. bneq not_access_violation $fao_s outbuf=reason,- outlen=reason,- ctrstr=control_reason,- p1=12(r2),p2=16(r2) pushal reason calls #1,g^lib$put_output ;Display the reason for the crash. $exit_s ;kill the process not_access_violation: movl #ss$_resignal,r0 ;Pass the buck ret .END MAIN *$*$*EOD*$*$* $ exit