From:	SMTP%"turion@research.ptt.nl"  4-APR-1994 16:58:47.93
To:	EVERHART
CC:	
Subj:	part 16 status tool, the last part

X-Newsgroups: comp.os.vms
From: turion_s@dnlts0research.ptt.nl. (Paul Turion)
Subject: part 16 status tool, the last part
Message-ID: <1994Mar21.145114.2377@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:51:14 GMT
Lines: 347
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 16 -+-+-+-+-+-+-+-+
X                .address retlength              ; Always a 8 byte field
X;
X                .word   MAX_VER_LEN             ; Suggested length of buffer
X                .word   SYI$_VERSION            ; We want the op sys version
X                .address version                ; Where to put the version
X                .address l_ver                  ; Length actually returned
X;
X                .word   MAX_CPU_LEN             ; Suggested length of the bu
Vffer
X                .word   SYI$_NODE_HWTYPE        ; We want the cpu type
X                .address cpu_type               ; Where to put the cpu type
X                .address l_cpu                  ; Length actually returned
X;
X                .long   0                       ; End of item list
X;
X;
X;
X;***************************************************************************
V****
X;* Status *
X;*      This procedure talks to the system device to get the load average. *
X;* It then moves all nescessary information out of system space and into our
V *
X;* little buffer.  If the second argument is odd, we use the first argument
V as *
X;* the address of a channel to send the information on.  If second argument
V is *
X;* even, we use the first argument as the address of buffer of where to put
V *
X;* the information.  The format of the record we send is: *
X;* *
X;*                             Field          Bytes *
X;*                      +------------------+---------+ *
X;*                      `124 node             `124 0 - 5   `124 *
X;*                      +------------------+---------+ *
X;*                      `124 op sys version   `124 6 - 13  `124 *
X;*                      +------------------+---------+ *
X;*                      `124 cpu type         `124 14 - 17 `124 *
X;*                      +------------------+---------+ *
X;*                      `124 boot time        `124 18 - 25 `124 *
X;*                      +------------------+---------+ *
X;*                      `124 max # of proc    `124 26 - 27 `124 *
X;*                      +------------------+---------+ *
X;*                      `124 interactive proc `124 28 - 29 `124 *
X;*                      +------------------+---------+ *
X;*                      `124 batch proc       `124 30 - 31 `124 *
X;*                      +------------------+---------+ *
X;*                      `124 network proc     `124 32 - 33 `124 *
X;*                      +------------------+---------+ *
X;*                      `124 total proc       `124 34 - 35 `124 *
X;*                      +------------------+---------+ *
X;*                      `124 load average     `124 36 - 47 `124 *
X;*                      +------------------+---------+ *
X;*                      `124 freepages        `124 48 - 51 `124 *
X;*                      +------------------+---------+ *
X;***************************************************************************
V****
X;
X                .psect  what_status_code, con, exe, lcl, shr, nowrt, pic, re
Vl
X;
X                .entry  what_status, `094m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>
X;
X                movl    4(ap), r9               ; Save the channel or buffer
V to send info on
X                movl    8(ap), r10              ; Move whether we want a cha
Vnnel of a buffer
X;
X                movw    @ijoblim, job_lim       ; Move maximum number of use
Vrs allowed
X                movw    @ijobcnt, int_cnt       ; Move number of interactive
V jobs
X                movw    @bjobcnt, bat_cnt       ; Move number of batch jobs
X                movw    @njobcnt, net_cnt       ; Move number of network job
Vs
X                movw    @proccnt, tot_cnt       ; Move total number of proce
Vsses
X                movl    @freecnt, freepages     ; Return the number of free
V pages
X;
X                tstb    assigned                ; Have we assigned a channel
V yet
X                bneq    cont                    ; If we have, continue on...
X;
X                $assign_s -                     ; Assign chan to load functi
Von
X                        devnam = device, -
X                        chan = load_chan
X                movb    #1, assigned            ; Set that we have been here
X;
Xcont:           $qiow_s -                       ; Talk to the function
X                        chan = load_chan, -     ; Channel for the load avera
Vge
X                        func = #IO$_READVBLK, - ; Read the load average
X                        p1 = load_avg, -        ; Where to put them
X                        p2 = #12                ; Length in bytes to put loa
Vd
X;
X                movc5   #0,#0,#32,#CHAR_PART_LEN,node ; Blank out the versio
Vnstring
X                $getsyiw_s -
X                        itmlst = syi_list       ; Get the specified info
X;
X                movc5   l_ver, version, #32, #MAX_VER_LEN, version
X                movc5   l_cpu, cpu_type, #32, #MAX_CPU_LEN , cpu_type
X                movc5   l_node, temp_node, #32, #MAX_NODE_LEN, node
X;
X                bbc     #7, r10, use_buffer
X                $qiow_s -
X                        chan = (r9), -          ; What channel to write to
X                        func = #IO$_WRITEVBLK,- ; Write out the line
X                        iosb = iosblk, -        ; Status of operation
X                        p1 = stat_buf, -        ; Where to write from
X                        p2 = #STAT_LEN          ; Length of bytes to put out
X                movzwl  iosblk, r0              ; Return the status conditio
Vn
X                ret                             ; Possibly successful
X;
Xuse_buffer:     movc3   #STAT_LEN, stat_buf, (r9)
X                movl    #1, r0                  ; Always successful
X                ret                             ; End of What_status
X;
X                .end
$ CALL UNPACK WHAT_STATUS.MAR;1 1107459394
$ create/nolog 'f'
X;***************************************************************************
V****
X;* Module to handle logical name translation *
X;***************************************************************************
V****
X;
X                .title  WHAT_TRNLNM
X;
X                $lnmdef                         ; Get logical name constants
X;
X                .psect  what_trnlnm_data, con, lcl, noexe, noshr, pic, rel,
V wrt
X;
Xtable_name:     .ascid  /LNM$FILE_DEV/          ; What table to translate lo
Vgical
X;
Xlog_name:       .ascii  /WHAT_/                 ; Prefix for logical name
Xincomming:      .blkb   256                     ; Reserve a mess of storage
V for incoming name
X;
Xlog_descr:      .long   5                       ; How long the logical name
V is
X                .address log_name               ; Where the logical name is
X;
Xequiv_name:     .byte   32`091255`093                 ; Temp place to store
V translation
Xequiv_len:      .long   0                       ; How long temp translation
V is
X;
Xindex:          .long   0                       ; Temporary index into trans
Vlations
Xmax_index:      .long   0                       ; Maximum number of translat
Vions
Xretlength:      .long   0                       ; Dummy return length
X;
Xtrnlnm_list:                                    ; SYS$TRNLNM item list
X                .word   4                       ; The current index is 4 byt
Ves
X                .word   LNM$_INDEX              ; We want to get this index
X                .address index                  ; Where the index is
X                .address retlength              ; Dummy return length
X;
X                .word   4                       ; The maximum index is 4 byt
Ves
X                .word   LNM$_MAX_INDEX          ; We want the maximum index
X                .address max_index              ; Where to put the maximum i
Vndex
X                .address retlength              ; Dummy return length
X;
X                .word   6                       ; How long our string can be
X                .word   LNM$_STRING             ; We want the equivalent str
Ving
X                .address equiv_name             ; Where to put the return st
Vring
X                .address equiv_len              ; Where to put the return le
Vngth
X;
X                .long   0                       ; End of our item list
X;
X;
X;
X;***************************************************************************
V****
X;* What_trnlnm *
X;*      This procedure is intended to translate the logical name "WHAT_strin
Vg" *
X;* string being passed in, and return all the nodes that are associated with
V *
X;* it in the DAE_NODE_DESCR buffer. *
X;* *
X;* Arguments - *
X;*              NODES - buffer to put the nodes returned from the logical na
Vme *
X;*                      by reference, DAE_NODE_DESCR *
X;*              LOG_NAME - logical name string to translate, "WHAT_string" i
Vs *
X;*                         what actually gets translated. *
X;*                      by descriptor *
X;***************************************************************************
V****
X;
X                .psect  what_trnlnm_code, con, exe, lcl, shr, nowrt, pic, re
Vl
X;
X                .entry  what_trnlnm, `094m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>
X;
X                movl    4(ap), r11              ; Where the node array is
X                movl    8(ap), r10              ; Save the logical name
X                addw2   (r10), log_descr        ; Add the length of the stri
Vng to translate to the prefix
X                movc3   (r10), @4(r10), incomming ; Save the incomming strin
Vg
X;
X                clrl    index                   ; Initialize our index
X                clrl    max_index               ; For cleanliness, clear the
V maximum index out
X;
X                $trnlnm_s -
X                        tabnam = table_name, -  ; What table to translate un
Vder
X                        lognam = log_descr, -   ; Where our logical name is
X                        itmlst = trnlnm_list    ; Where our item list is
X                blbs    r0, 10$
X                brw     error                   ; Error, get out
X;
X10$:            cmpb    #-1, max_index          ; Are there any translations
X                bneq    20$
X                brw     end                     ; No there aren't, get out
X;
X20$:            addb3   max_index, #1, (r11)+   ; Save number of nodes
X                movb    equiv_len, (r11)+       ; Save first translation len
Vgth
X                movc5   equiv_len, equiv_name, #32, #6, (r11) ; Save first s
Vtring
X                movl    r3, r11                 ; Save new address in nodes
V list
X                incl    index                   ; Increment our index
X;
Xloop:           $trnlnm_s -
X                        tabnam = table_name, -  ; What table to translate un
Vder
X                        lognam = log_descr, -   ; Where our logical name is
X                        itmlst = trnlnm_list    ; Where our item list is
X                blbc    r0, error
X;
X                movb    equiv_len, (r11)+       ; Save first translation len
Vgth
X                movc5   equiv_len, equiv_name, #32, #6, (r11) ; Save first s
Vtring
X                movl    r3, r11                 ; Save new address in nodes
V list
X;
X                aobleq  max_index, index, loop  ; Keep looping until index >
V max_index
X                movl    #1, r0                  ; We are successfull
X;
Xend:            ret                             ; End of What_trnlnm
X;
Xerror:          pushl   r0                      ; Push the error returned
X                pushal  log_descr               ; What logical name failed
X                pushl   #1                      ; How many arguments we are
V passing
X                pushl   #WHAT_BADLNM            ; Failure talking to the dae
Vmon
X                calls   #4, g`094lib$signal        ; Signal the error
X;
X                ret                             ; End of Trnlnm
X;
X                .end
$ CALL UNPACK WHAT_TRNLNM.MAR;1 825098196
$ create/nolog 'f'
X;***************************************************************************
V****
X;* What_uptime *
X;*      This procedure is intended to return a formated string of the curren
Vt *
X;* time a CPU has been up, given its boot time. *
X;***************************************************************************
V****
X;
X                .title  WHAT_UPTIME
X;
X                .psect  what_uptime_data, con, lcl, noexe, noshr, pic, rel,
V wrt
X;
Xepoch:          .quad   0                       ; Used to make delta positiv
Ve
Xcurr_time:      .quad   0                       ; Current time program is ru
Vn
Xdelta_time:     .long   0                       ; Storage place for delta ti
Vme
Xup_half:        .long   0                       ; - after subtraction
X;
X                .psect  what_uptime_code, con, exe, lcl, shr, nowrt, pic, re
Vl
X;
X                .entry  what_uptime, `094m<r2,r3,r4,r5,r6,r7,r8,r9,r10,r11>
X;
X                movl    4(ap), r11              ; Boot time needed to be con
Vverted
X                movl    8(ap), r10              ; Descriptor of time buffer
X                movl    12(ap), r9              ; Length of the returned str
Ving
X;
X                $gettim_s -
X                        timadr = curr_time      ; Get the current time
X;
X                pushal  delta_time
X                pushl   r11                     ; Subtract boot time from cu
Vrrent
X                pushal  curr_time               ; - time to find uptime.
X                calls   #3, g`094lib$subx
X;
X                bbs     #31, up_half, 10$       ; If bit 31 set, its is nega
Vtive
X;
X                pushal  delta_time
X                pushal  delta_time              ; Subtract the time so that
X                pushal  epoch                   ; - it is positive
X                calls   #3, g`094lib$subx
X;
X10$:            $asctim_s -                     ; Convert the delta time to
X                        timlen = (r9), -        ; - a string
X                        timbuf = (r10), -
X                        timadr = delta_time
X;
X                ret                             ; End of What_uptime
X;
X                .end
$ CALL UNPACK WHAT_UPTIME.MAR;1 388005775
$ v=f$verify(v)
$ EXIT

