From:	MERC::"uunet!WKUVX1.BITNET!list-mgr"  9-MAR-1993 15:47:08.76
To:	MX-List@WKUVX1.BITNET
CC:	redman@hiaras.hia.nrc.ca
Subj:	RE: An FLQU replacement

On Thu, 04 Mar 1993 09:13:09 EST, "Russell O. Redman"
<redman@hiaras.hia.nrc.ca> posted:
>.....
> What I think we want is a quick diagnostic of the state of the system which
> would summarise what is happening in less than one screen. It would be
> useful to check each of the MX components, showing that it is still present
> and reporting its internal state as best it can. As a minimum this would
> report the VMS state (HIB, RWAST, ...), but if the components maintain a
> record of their internal status in an accessible place, it might be better
> to construct a message from this.

Attached is my MXWATCH.COM file we use here for this purpose.  So long as
the account which runs MX has fewer than 20 processes running in it, this
is a very useful file.  I extend my thanks to Ken Selvia who provided me
with the base code for this which I have hacked upon.  Comments on this are
certainly welcome.

--George
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
George D. Greenwade, Ph.D.                            Bitnet:  BED_GDG@SHSU
Department of Economics and Business Analysis         THEnet: SHSU::BED_GDG
College of Business Administration                    Voice: (409) 294-1266
P. O. Box 2118                                        FAX:   (409) 294-3612
Sam Houston State University              Internet:        bed_gdg@SHSU.edu
Huntsville, TX 77341                      bed_gdg%SHSU.decnet@relay.the.net
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
$ !!! ======================================================================
$ !!!  @VAX-VMS-shell-file{
$ !!!     filename        = "mxwatch.com",
$ !!!     version         = "2.03",
$ !!!     date            = "04 March 1993",
$ !!!     time            = "11:29:17 CST",
$ !!!     author          = "George D. Greenwade",
$ !!!     address         = "Department of Economics and Business Analysis
$ !!!                        College of Business Administration
$ !!!                        P. O. Box 2118
$ !!!                        Sam Houston State University
$ !!!                        Huntsville, Texas, USA 77341-2118",
$ !!!     email           = "bed_gdg@SHSU.edu (Internet)
$ !!!                        BED_GDG@SHSU     (BITNET)
$ !!!                        SHSU::BED_GDG    (THENET)",
$ !!!     telephone       = "(409) 294-1266",
$ !!!     FAX             = "(409) 294-3712",
$ !!!     supported       = "yes",
$ !!!     archived        = "Niord.SHSU.edu:[FILESERV.MX]",
$ !!!     keywords        = "MX, process monitor",
$ !!!     codetable       = "ISO/ASCII",
$ !!!     abstract        = "This is a DCL command shell which provides a
$ !!!                        quick monitor of processes related to the
$ !!!                        account MX is run under.  The field delimited
$ !!!                        by LOCAL below provides an area for local
$ !!!                        customization of the MX mailer account name.
$ !!!                        The default mailer account name is MXMAILER.
$ !!!
$ !!!                        Information shown includes process ID number,
$ !!!                        process name, process state, elapsed CPU time,
$ !!!                        node name, and image in use.  Monitoring may
$ !!!                        be continuous or one-pass.  If one-pass, the
$ !!!                        screen may be updated and redisplayed by
$ !!!                        pressing <RETURN> at the inquiry line.  To
$ !!!                        run in continuous mode, include the character
$ !!!                        * at either startup as P1 on the command line
$ !!!                        or in response to the inquiry line.  Continuous
$ !!!                        view is ended by <RETURN>.  To exit in either
$ !!!                        mode, press F10 at the inquiry line (i.e, if
$ !!!                        in continuous mode, press <RETURN> F10).
$ !!!
$ !!!                        Process killing is also supported.  Processes
$ !!!                        may be "hard killed" by indicating the process
$ !!!                        process number (in column 1) at the inquiry
$ !!!                        line.  This option is provided primarily as a
$ !!!                        control mechanism for other processes which may
$ !!!                        be running under the mailer account.  IT IS NOT
$ !!!                        RECOMMENDED TO HARD KILL NATIVE MX PROCESSES --
$ !!!                        USE THE MCP SHUTDOWN SUITE TO ACHIEVE NATIVE
$ !!!                        MX PROCESS SHUTDOWNS.
$ !!!
$ !!!                        This monitor is most useful if 20 or fewer
$ !!!                        processes are running within the mailer
$ !!!                        account at a point in time.
$ !!!
$ !!!                        You must have privileges to view the mailer
$ !!!                        account in order to use this file.",
$ !!!     checksum        = "25762 159 899 7049",
$ !!!     docstring       = "The checksum field above contains a CRC-16
$ !!!                        checksum as the first value, followed by the
$ !!!                        equivalent of the standard UNIX wc (word
$ !!!                        count) utility output of lines, words, and
$ !!!                        characters.  This is produced by Robert
$ !!!                        Solovay's checksum utility."
$ !!! }
$ !!! ======================================================================
$ !!!!!!!!!!----------LOCAL----------LOCAL----------!!!!!!!!!!
$ MAILERNAME := MXMAILER
$ !!!!!!!!!!----------LOCAL----------LOCAL----------!!!!!!!!!!
$ FORMAT = "[!AS] PID #!8<!AS!> !15<!AS!> !6<!AS!> !8<!AS!> !6<!AS!> !21<!AS!>"
$ ESC[0,7] = %D27
$ RESET = "''ESC'[0m"
$ REVERSE = "''ESC'[7m"
$ CONT_MODE = "N"
$begin:
$ WRITE SYS$OUTPUT "''ESC'[2H''ESC'[2J                           " + -
     "     ''REVERSE'MX Detached Process Info''RESET'"
$ IF P1 .EQS. "*"
$   THEN CONT_MODE = "Y"
$   GOTO CONT
$ ENDIF
$CONT:
$ WRITE SYS$OUTPUT "''ESC'[2;1H"
$ IF F$TYPE(CTX) .EQS. "PROCESS_CONTEXT" THEN TMP = -
     F$CONTEXT("PROCESS",CTX,"CANCEL")
$ CTX = ""
$ TMP = F$CONTEXT("PROCESS",CTX,"NODENAME","*","EQL")
$ TMP = F$CONTEXT("PROCESS",CTX,"USERNAME","''MAILERNAME'","EQL")
$ PID_LIST = ""
$ PID_LINE = 0
$LOOP:
$ NPID = F$PID(CTX)
$ IF NPID .EQS. "" THEN GOTO MENU
$ PID_LINE = PID_LINE + 1
$ PID_LIST = PID_LIST + "''NPID'" + ","
$ PNAME = F$GETJPI(NPID,"PRCNAM")
$ NNAME = F$GETJPI(NPID,"NODENAME")
$ IMODE = F$GETJPI(NPID,"MODE")
$ ISPEC = F$GETJPI(NPID,"IMAGNAME")
$ PSTATE = F$GETJPI(NPID,"STATE")
$ PCPU = F$GETJPI(NPID,"CPUTIM")
$ INAME = F$PARSE(ISPEC,,,"NAME") + F$PARSE(ISPEC,,,"DIRECTORY")
$ IF F$PARSE(ISPEC,,,"NAME") .EQS. "" THEN INAME = "DCL"
$ PID_ASCII = F$STRING(PID_LINE)
$ IF PID_LINE .LT. 10 THEN PID_ASCII = " " + PID_ASCII
$ GOSUB EDTIME
$ WRITE SYS$OUTPUT F$FAO(FORMAT,PID_ASCII,NPID,PNAME,PSTATE,EDLINE,NNAME,INAME)
$ GOTO LOOP
$MENU:
$ IF CONT_MODE
$    THEN READ/PROMPT=""/TIME=5/ERROR=CONT/END=CONT SYS$COMMAND IPT
$    CONT_MODE = "N"
$ ENDIF
$ WRITE SYS$OUTPUT "[*] Display in continuous mode. " + -
     " (Press RETURN to interrupt)"
$CHOICE:
$ READ/PROMPT= -
     "Enter selection (# to kill, <RETURN> to redisplay, F10 to EXIT) : "  -
      SYS$COMMAND OPTN /END=EXIT
$ OPTN = F$EDIT(OPTN,"UPCASE")
$ IF OPTN .EQS. "" THEN GOTO BEGIN
$ IF OPTN .EQS. "*"
$   THEN CONT_MODE = "Y"
$   GOTO CONT
$ ENDIF
$ KILL_LINE = F$INT(OPTN)
$ IF (KILL_LINE .EQS. 0) .OR. (KILL_LINE .GT. PID_LINE)
$     THEN WRITE SYS$OUTPUT "Invalid item number."
$     GOTO CHOICE
$ ENDIF
$ KILL_PID = F$ELEMENT(KILL_LINE - 1,",",PID_LIST)
$ PNAME = F$GETJPI(KILL_PID,"PRCNAM")
$ NNAME = F$GETJPI(KILL_PID,"NODENAME")
$ IMODE = F$GETJPI(KILL_PID,"MODE")
$ ISPEC = F$GETJPI(KILL_PID,"IMAGNAME")
$ PSTATE = F$GETJPI(KILL_PID,"STATE")
$ Pcpu = F$GETJPI(KILL_PID,"cputim")
$ INAME = F$PARSE(ISPEC,,,"NAME") + F$PARSE(ISPEC,,,"DIRECTORY")
$ IF F$PARSE(ISPEC,,,"NAME") .EQS. "" THEN INAME = "DCL"
$ PID_ASCII = F$STRING(KILL_LINE)
$ IF KILL_LINE .LT. 10 THEN PID_ASCII = " " + PID_ASCII
$ GOSUB EDTIME
$ WRITE SYS$OUTPUT F$FAO(FORMAT,PID_ASCII,KILL_PID,PNAME,PSTATE,EDLINE,-
      NNAME,INAME)
$ WRITE SYS$OUTPUT EDLINE
$ READ/PROMPT="Stop process (Y/N): " SYS$COMMAND KILL_YN/END=CHOICE
$ IF KILL_YN THEN STOP PROC/ID='KILL_PID'
$ GOTO CHOICE
$EDTIME:
$ ED_SS=PCPU/100
$ ED_XX=PCPU-100*ED_SS
$ ED_MM=ED_SS/60
$ ED_SS=ED_SS-60*ED_MM
$ ED_HH=ED_MM/60
$ ED_MM=ED_MM-60*ED_HH
$ EDLINE=F$FAO("!2ZL:!2ZL.!2ZL",ED_MM,ED_SS,ED_XX)
$ RETURN
$EXIT:
$ EXIT
