From:	SMTP%"turion@research.ptt.nl"  4-APR-1994 15:47:52.93
To:	EVERHART
CC:	
Subj:	part 14 status tool

X-Newsgroups: comp.os.vms
From: turion_s@dnlts0research.ptt.nl. (Paul Turion)
Subject: part 14 status tool
Message-ID: <1994Mar21.144959.2174@news.research.ptt.nl>
Sender: turion_s@research.ptt.nl (Paul Turion)
Nntp-Posting-Host: dnlts0.research.ptt.nl
Reply-To: turion@research.ptt.nl
Organization: PTT Research
X-Newsreader: mxrn 6.18-4
Date: Mon, 21 Mar 1994 14:49:59 GMT
Lines: 350
To: Info-VAX@CRVAX.SRI.COM
X-Gateway-Source-Info: USENET


-- 
 ------- --------------------  			Paul Turion 
| p t t |  r e s e a r c h   |			The Netherlands
|      _|                    | 			e-mail address
|    _|_|   .  .  .  .  .    |			P.Turion@research.ptt.nl
|___|_|      
My interest is in the future because
I am going to spend the rest of my life there.
-+-+-+-+-+-+-+-+ START OF PART 14 -+-+-+-+-+-+-+-+
Xmode:           .long   0                       ; Mode of the process
Xchan_buf:       .long   0                       ; Default to useing a buffer
Xchan_buf_adr:   .long   0                       ; Address of where buffer or
V channel is
X;
Xchar_time_descr: .long  5                       ; How long the time is
X                .address char_time              ; Where the time should be p
Vut
Xchar_cpu_descr: .long   4                       ; How long we want it
X                .address char_cpu               ; Where the character cpu sh
Vould be put
X;
Xname_descr:     .long   17                      ; Maximum length of the name
X                .address name_only              ; Where the name of the imag
Veis stored
Xoutstr_descr:   .long   256                     ; Length of the outstr, doub
Vles as its descriptor
X                .address outstr                 ; Address out output string
Xl_ostr:         .long   0                       ; Length of the outstr, retu
Vrned by SYS$FAOL
X;
Xretlength:      .long   0                       ; Dummy place to hold some r
Veturn lengths from SYS$GETJPI
Xiosblk:         .quad   0                       ; IO status block
X;
Xfcpu:           .long   0                       ; Converted cpu time
X;
Xfilter:         .byte   0                       ; Assume we will filter no p
Vrocesses out
X;
Xfao_list:
X                .long   8                       ; How much of the username w
Vewant printed out
X                .address username               ; Where the username is
X                .long   6                       ; How long the node is
X                .address node                   ; Where the node name is
Xpid:            .long   0                       ; Process Identification num
Vber
X                .long   15                      ; How much of the processnam
Vewe want printed out
X                .address prcnam                 ; Where the process name is
X                .long   7                       ; How much of the account we
V want printed out
X                .address account                ; Where the group name is
X                .long   7                       ; How much of the terminal w
Vewant printed out
X                .address term                   ; Where the terminal name is
X                .long   5                       ; How much of the time we wa
Vnt printed out
X                .address char_time              ; Where the character time i
Vs
X                .long   3                       ; How much of the character
V state we want printed out
X                .address char_state             ; Where the character state
V is
X                .long   4                       ; How much of the character
V cpu usage we want printed out
X                .address char_cpu               ; Where the character cpu us
Vage is
X                .long   17                      ; How much of the image name
V we want printed out
X                .address name_only              ; Where the name is
X;
X;       DVI item list to get the physical terminal information
X;
Xdvi_list:       .word   16
X                .word   DVI$_TT_PHYDEVNAM
X                .address term
X                .address term_descr
X;
X                .long   0                       ; End of DVI list
X;
X;       SYI item list to get the system wide information
X;
Xsyi_list:       .word   6
X                .word   SYI$_NODENAME
X                .address node
X                .address retlength
X;
X                .long   0                       ; End of SYI list
X;
X;       JPI item list to get information that won't swap a process
X;
Xjpi_wild:       .long   -1                      ; We want a wild card lookup
V of processes
X;
Xjpi_lookup:     .word   4                       ; The pid is a longword, fou
Vrbytes
X                .word   JPI$_PID                ; We want the process identi
Vfication number
X                .address pid                    ; Where to store the pid
X                .address retlength              ; Dummy return length
X;
X                .word   4                       ; The state is a longword, f
Vour bytes
X                .word   JPI$_STATE              ; We want the state
X                .address state                  ; Where to put the state
X                .address retlength              ; Dummy return length
X;
X                .word   4                       ; The mode is a longword, fo
Vur bytes
X                .word   JPI$_MODE               ; We want the process's mode
X                .address mode                   ; Where to put the mode
X                .address retlength              ; Dummy return length
X;
X                .word   8                       ; Length we want for the use
Vrname
X                .word   JPI$_USERNAME           ; We want the username
X                .address username               ; Where to put the username
X                .address retlength              ; How long our username is
X; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   join with part 2 %%%%%%%%%%%%%%%%%%%%%%
V%%%
X; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   join with part 1 %%%%%%%%%%%%%%%%%%%%%%
V%%%
X;
X                .word   8                       ; Length we want for the acc
Vount
X                .word   JPI$_ACCOUNT            ; We want the account
X                .address account                ; Where to put the account
X                .address retlength              ; Dummy return length
X;
X                .word   16                      ; Length we want for the ter
Vminal
X                .word   JPI$_TERMINAL           ; Get the terminal of the pr
Vocess
X                .address term                   ; Where to put the terminal
X                .address term_descr             ; Dummy return length
X;
X                .word   15                      ; Length we want for the pro
Vcess name
X                .word   JPI$_PRCNAM             ; We want a process name
X                .address prcnam                 ; Where to put the process n
Vame
X                .address retlength              ; Dummy return length
X;
X                .long   0                       ; End of JPI list that won't
V swap a process in
X;
X;       JPI item list to get information that will swap a process in
X;
Xjpi_p1:         .word   128                     ; Length we want for the ima
Vge name
X                .word   JPI$_IMAGNAME           ; We want the image name
X                .address image                  ; Where to put the image nam
Ve
X                .address image_descr            ; Where to put the length of
V the image
X;
X                .word   8                       ; Length we want for the CPU
V time
X                .word   JPI$_CPUTIM             ; We want the CPU time
X                .address cpu_time               ; Where to put the cpu time
X                .address retlength              ; Dummy return length
X;
X                .word   8                       ; Length we want for the log
Vin time
X                .word   JPI$_LOGINTIM           ; We want the login time
X                .address login_time             ; Where to put the login tim
Ve
X                .address retlength              ; Where to put the return le
Vngth
X;
X                .word   4                       ; Length we want for the own
Ver
X                .word   JPI$_OWNER              ; We want the owner
X                .address owner                  ; Where to put the owner
X                .address retlength              ; Dummy return length
X;
X                .long   0                       ; End of JPI list that will
V swap a process in
X;
X;
X;
X;***************************************************************************
V****
X;* What_look *
X;*     This procedure is intended to take a function code that specifies a *
X;* format of output, and either a channel number or the address of a buffer
V *
X;* to put the information returned in.  The function codes currently support
Ved *
X;* for either channel or buffer are: *
X;* *
X;*              DAE_BRIEF *
X;*              DAE_SYSTEM *
X;*              DAE_FULL *
X;* *
X;* Arguments:   BUFFER or CHANNEL, address of either a buffer to put info in
Vto *
X;*                 - or a channel to send the info down.  Buffer is passed b
Vy *
X;*                 - descriptor. *
X;* *
X;*              FUNCTION, the function code to perform.  Only the first byte
V *
X;*                 - is used.  If the high order bit in the byte is set then
V *
X;*                 - the first argument is interpreted as a channel number,
V *
X;*                 - else it is interpreted as a buffer descriptor.  FUNCTIO
VN *
X;*                 - is passed by value. *
X;* *
X;*              USER, address of a descriptor of the user names to search fo
Vr. *
X;* *
X;* Register Use: *
X;* *
X;*      r6 - Holds the address of the format strings to be used *
X;*      r7 - Holds the current address in the print buffer *
X;*      r8 - Holds the address of the character state array *
X;*      r9 - Holds the address of the character mode array *
X;*      r10 - Holds the address of the buffer or channel to dump info to *
X;*      r11 - Holds the function code we are working with, then it holds the
V *
X;*            number of the control string we want *
X;* *
X;***************************************************************************
V****
X;
X                .psect  what_look_code, con, exe, lcl, shr, nowrt, pic, rel
X;
X                .entry  what_look, `094m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>
X;
X                moval   ctrl_list, r6           ; Put the control list into
V amemory for later use
X                moval   buffer, r7              ; Holds the address of the c
Vurrent position in print buffer
X                moval   char_state_arr, r8      ; Move the address of the ch
Varacter state for indexing later
X                moval   char_mode_arr, r9       ; Move the address of the ch
Varacter modes for indexing later
X                movl    4(ap), chan_buf_adr     ; Move either the address of
V a channel or address of a descriptor
X                movzbl  8(ap), r11              ; Move address of function c
Vode
X                movl    12(ap), r10             ; Move address of user descr
Viptor so we can work with it
X;
X                mnegl   #1, jpi_wild            ; We want to search all the
V processes
X;
X                blbs    r11, get_all            ; If the 0 bit is set, get a
Vll the process on system
X                movb    #INT_ONLY, filter       ; Get the interactive ones o
Vnly
X                brb     keep_parsing            ; Go and skip the swapper an
Vdnull processes
X;
Xget_all:        movb    #ALL_PROC, filter       ; Get all the system process
Ves
X;
Xkeep_parsing:   extzv   #7, #1, r11, chan_buf   ; Extract whether we want to
V use first arg as a channel of buffer
X                extzv   #3, #2, r11, r11        ; Extract out the format num
Vber
X;
Xskip_swap:      $getjpiw_s -                    ; Skip the NULL process
X                        pidadr = jpi_wild, -    ; We want to search all the
V processes
X                        itmlst = jpi_lookup     ; We want to lookup normal i
Vnformation
X                $getjpiw_s -                    ; Skip the SWAPPER process
X                        pidadr = jpi_wild, -    ; We want to search all the
V processes
X                        itmlst = jpi_lookup     ; We want to lookup normal i
Vnformation
X                $getsyiw_s -
X                        itmlst = syi_list       ; Get the specified info
X                movc5   retlength, node, #32, #6, node
X;
Xloop:           movc5   #0, #0, #32, -
X                        #BYTES_TO_BLANK, -
X                        strings_to_blank        ; Clear out the strings
X;
X                $getjpiw_s -                    ; Get the next process
X                        pidadr = jpi_wild, -    ; We want to search all the
V processes
X                        itmlst = jpi_lookup     ; We want to lookup normal i
Vnformation
X                cmpl    #SS$_NOMOREPROC, r0
X                bneq    cont_loop               ; Continue processing if the
Vre are still more
X;
X                brw     end_loop                ; We are done, get out
X;
Xcont_loop:      cmpl    #SS$_NOPRIV, r0         ; Do we have the privilege t
Voa get process
X                beql    loop                    ; Keep going, and get next p
Vrocess
X;
X                cmpb    mode, filter            ; If the mode is greater tha
Vnor equal to the
X                blss    loop                    ; - process mode we want, ke
Vep it
X;
X;       Compare username returned from SYS$GETJPI to the username passed in
X;
X                cmpw    (r10), #8               ; If we have less than 8 cha
Vrs, we will do a cmpc3
X                bleq    variable_cmp
X;
X                locc    #32, #8, username       ; Find end of the string
X                subl3   r0, #8, r0              ; Find out how long it is
X                matchc  r0, username, (r10), @4(r10)
X                beql    process_it              ; If we match, keep going
X                brw     loop                    ; Else get next dude
X;
Xvariable_cmp:   cmpc3   (r10), @4(r10), username ; Are the string equal
X                beql    process_it              ; If we match, keep going
X                brw     loop                    ; Else get next dude
X;
Xprocess_it:     movtc   #15, prcnam, #32, table, #15, prcnam    ; Clean out
V the processname string
X;
X                tstb    term
X                bneq    has_term                ; We have a terminal
X;
X                brw     get_other_info          ; We don't have a terminal
X;
Xhas_term:       locc    #`094a/:/, term_descr, term ; Find a colon in device
V name
X                bneq    get_phys                ; If we found, get physical
V device name
X;
X                movb    #`094a/:/, (r1)            ; Add in a colon, cause w
Ve couldn't find one
X                incl    term_descr              ; Increase the length
X;
Xget_phys:       $getdviw_s -
X                        devnam = term_descr, -  ; What name we are looking f
Vor
X                        itmlst = dvi_list       ; What information we want
X;
X                cmpb    #`094a/_/, term            ; Do we have an underline
V?
X                bneq    get_other_info          ; If we don't, keep going
X;
X                decl    term_descr              ; Decrease its length
+-+-+-+-+-+-+-+-  END  OF PART 14 +-+-+-+-+-+-+-+-

