[mod.computers.vax] user usage on VMS

DHASKIN@CLARKU.BITNET.UUCP (01/15/87)

Frank Simmons <QQA6194@UMNACVX> asks:

> Is there a way to tell what a given user/process is actually doing
> at a given time under VMS?  I would like to know whether or not I can
> monitor who is using SPSS or SAS or whatever.

Lots of ways, depending on how fancy you want to get.  At the bottom of this
message is a DCL command procedure that gives you that kind of information, and
could certainly be cannibalized/enhanced for your specific needs. It is taken
from a VMS manual itself; see that for further info (it requires a suitably
privileged process, obviously).

However, is it really snapshot information you want?  You will probably quickly
find that you want historical data... which one can also get.  Change the
installations of those images you want to track to include image-level
accounting, for example:

        INSTALL> ADD/OPEN/HEAD/SHARE/ACCOUNT APPL$ROOT:[SAS503.IMAGE]SAS503

(I don't remember if the above is exactly correct).  Any image installed
in this manner will generate image-level accounting records, as if a DCL
SET ACCOUNTING/ENABLE=IMAGE was done, but you avoid the overhead of image
accounting for stuff you couldn't care less about.

You can then use the ACCOUNTING utility ('free', once you've got VMS) to
generate usage reports to your heart's content.

Denis W. Haskin
------------------------------------------------------------------------
DHASKIN@CLARKU.BITNET    Office of Information Systems     (617)793-7193
                                Clark University
                                950 Main Street
                              Worcester MA  01610


DCL procedure follows:
---------------------------------------------------------------------------
$   SAVE_VERIFY = F$VERIFY(0)           ! Turn off verification
$ ! SYS.COM  displays information about owner, group, or system processes.
$ ! Taken from Appendix A of "VAX/VMS Guide to Using Command Procedures"
$ ! Minor modifications  DEJ, August, 1984.
$
$   PREV_PRIV = F$SETPRIV("WORLD,ALTPRI")       ! Set the world privilege on
$   BASE_PRIO = F$GETJPI("","PRIB")             ! Old base priority
$   SET PROCESS/PRIORITY=6
$   on control_y then goto done
$   CONTEXT = ""                                ! Initialize PID search context
$
$   PID = F$PID(CONTEXT)                        ! SKIP NULL
$   PID = F$PID(CONTEXT)                        ! SKIP SWAPPER
$
$ ! Output header line
$   HEADER := "   PID    Username    Term   Process name   State  Pri  Image"
$   UNDERL := "-------- ------------ ----- -------------   ----- ----- ---------
"
$   WRITE SYS$OUTPUT HEADER
$   write sys$output underl
$
$ ! Output process information
$
$ LOOP:
$
$ ! Get next PID.  If null, then done
$
$       PID = F$PID(CONTEXT)
$       IF PID .EQS. "" THEN GOTO ENDLOOP
$
$ ! Skip system processes
$       USERNAME = F$GETJPI(PID,"USERNAME")
$       IF USERNAME .EQS. "SYSTEM      " THEN GOTO LOOP
$
$ ! Get image file specification and extract the file name.
$
$       IMAGNAME = F$GETJPI(PID,"IMAGNAME")
$       IMAGNAME = F$EXTRACT(F$LOCATE("]",IMAGNAME)+1,999,IMAGNAME)
$       IMAGNAME = F$EXTRACT(F$LOCATE("]",IMAGNAME)+1,999,IMAGNAME)
$       IMAGNAME = F$EXTRACT(0,F$LOCATE(".",IMAGNAME),IMAGNAME)
$
$ ! Get terminal name.  If none, then describe type of process.
$
$       TERMINAL = F$GETJPI(PID,"TERMINAL")
$       IF TERMINAL .EQS. "" THEN -
                TERMINAL = "-"+F$EXTRACT(0,3,F$GETJPI(PID,"MODE"))+"-"
$       IF TERMINAL .EQS. "-INI-" THEN TERMINAL = "-DET-"
$       IF F$GETJPI(PID,"OWNER") .NE. 0 THEN TERMINAL = "-SUB-"
$
$ ! Get some more information, put process line together, and output it.
$
$       LINE = F$FAO(   -
                "!AS !12AS !5AS !15AS !5AS !2UL/!2UL !18AS",-
                PID,USERNAME,TERMINAL,  -
                F$GETJPI(PID,"PRCNAM"), -
                F$GETJPI(PID,"STATE"),F$GETJPI(PID,"PRI"),      -
                F$GETJPI(PID,"PRIB"),IMAGNAME)
$       WRITE SYS$OUTPUT LINE
$       GOTO LOOP
$
$ ENDLOOP:
$   write sys$output underl
$   WRITE SYS$OUTPUT HEADER
$
$ ! Restore verification and exit.
$
$ DONE:
$   SET PROCESS/PRIORITY='base_prio'
$   PREV_PRIV = F$SETPRIV(PREV_PRIV)            ! Reset privileges
$   IF SAVE_VERIFY THEN SET VERIFY
$   EXIT