From:	SMTP%"turion@research.ptt.nl" 21-MAR-1994 18:16:01.97
To:	EVERHART
CC:	
Subj:	part 10 status tool

X-Newsgroups: comp.os.vms
From: turion_s@dnlts0research.ptt.nl. (Paul Turion)
Subject: part 10 status tool
Message-ID: <1994Mar21.144606.1721@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:46:06 GMT
Lines: 473
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 10 -+-+-+-+-+-+-+-+
X                if (`126stat&1) return(stat);  /* Signal if a bad error mess
Vage */
X
X                stat = sys$getdviw(___,dev_chan,  /* Get the unit number of
V the device */
X                                   ___,&items,
X                                   ___,___,___,___);
X                if (`126stat&1) return(stat);  /* Stop and message on a seve
Vre error */
X
X                *index = findunit(EMPTY);  /* Find an empty place in list of
V connects */
X
X                connects`091*index`093.channel = dev_chan;  /* Store device
V chan in connect blk */
X                connects`091*index`093.unit = unit;  /* Store unit number in
V connect blk */
X                link_cnt = link_cnt + 1;  /* Increment the link count */
X
X                stat = sys$qiow(___,  /* Grant access to connect request */
X                        dev_chan,
X                        IO$_ACCESS,
X                        &iosb,___,___,___,
X                        &ncb_desc,
X                        ___,___,___,___);
X                if (`126stat&1) return(iosb.condition);  /* Stop and error o
Vn a severe error */
X
X                ret_code = TRUE;
X        `125
X        else
X        `123
X                stat = sys$qiow(___,  /* Too many links, ..  deny access */
X                        daemon_chan,
X                        (IO$_ACCESS`124`124IO$M_ABORT),
X                        &iosb,___,___,___,
X                        &ncb_desc,
X                        ___,___,___,___);
X                if (`126stat&1) return(iosb.condition);  /* Stop and error o
Vn a severe condition */
X
X                ret_code = FALSE;
X        `125
X
Xreturn(ret_code);
X`125 /* Connect_accept */
X
X
X
X/***************************************************************************
V***/
X/* Read_chan*/
X/*      This procedure is intended to issue AST reads on the channel.*/
X/***************************************************************************
V***/
X
Xread_chan(index)
X
Xint index;
X
X`123
X        int read_ast();
X        int stat;
X
X        stat = sys$qio(___,
X                connects`091index`093.channel,
X                IO$_READVBLK,
X                &connects`091index`093.iosb,
X                &read_ast,
X                index,
X                &connects`091index`093.func_code,
X                FUNC_SIZE,  /* Size of the buffer to read */
X                ___,___,___,___);
X        return(stat);  /* Return the status of the QIO */
X`125  /* read_chan */
X
X
X
X/***************************************************************************
V***/
X/* Read_ast*/
X/*      Subroutine to check completion status of the mailbox read and handle
V*/
X/* request message from the link.  Completes by reissueing the read on the*/
X/* channel.*/
X/***************************************************************************
V***/
X
Xread_ast(index)
X
Xint index;
X
X`123
X        int     stat;  /* Status value of system service */
X
X        if (connects`091index`093.iosb.condition&1)  /* If the QIO completed
V alright */
X        `123
X           switch(connects`091index`093.func_code)
X              `123
X                 case DAE_SYSTEM:
X                 case DAE_BRIEF:
X                 case DAE_FULL:
X                        connects`091index`093.func_code = connects`091index`
V093.func_code`124 DAE_M_CHANNEL;
X                        connects`091index`093.func_code = connects`091index`
V093.func_code`124 DAE_M_NODE;
X                        user_name.length = connects`091index`093.user_len;
X                        user_name.pointer = &connects`091index`093.user_stri
Vng;
X                        what_look(&connects`091index`093.channel,  /* Answer
V their request with the processes on */
X                                  connects`091index`093.func_code,  /* the s
Vystem... */
X                                  &user_name);
X                 case DAE_STATUS:
X                        what_status(&connects`091index`093.channel, DAE_M_CH
VANNEL);  /* Just give them the status info on the channel */
X                        return;
X                 DEFAULT:
X                        disconnect(index);  /* Else disconnect them */
X              `125
X        `125  /* if */
X`125  /* read_ast */
X
X
X
X/***************************************************************************
V***/
X/* Routine to disconnect a logical link*/
X/***************************************************************************
V***/
X
Xdisconnect(index)
X
Xint     index;  /* Index of the connection to disconnect */
X
X`123
X        int     stat;  /* Status return value of system services */
X
X        if (index != -1)
X        `123
X                stat = sys$dassgn(connects`091index`093.channel);          /
V* Deassign the channel of the connection */
X                clearconnect(index);          /* Clear out the connection bl
Vock */
X        `125
X`125  /* disconnect */
X
X
X/***************************************************************************
V***/
X/* Findunit*/
X/*      Routine to find a connection by the unit number given*/
X/***************************************************************************
V***/
X
Xfindunit(unit)
X
Xint     unit;  /* Unit number to find */
X
X`123
X        int     index;  /* Loop control variable */
X
X        index = 0;  /* Start at the beginning */
X        do
X        `123
X                if (connects`091index`093.unit == unit)  /* Have we found th
Ve unit? */
X                `123
X                        return(index);  /* If we have, return where we are *
V/
X                `125
X                else index = index + 1;  /* Else look at the next one */
X        `125
X        while (index<=MAX_LINKS-1);  /* Until we have reached the maximum li
Vnks */
X
X        if (index > MAX_LINKS-1)
X                return(-1);  /* If we have reached this point, we have probs
V */
X
X`125  /* findunit */
X
X
X
X/***************************************************************************
V***/
X/* Clearconnect*/
X/*      This routine will clear out a given connect block*/
X/***************************************************************************
V***/
X
Xclearconnect(index)
X
Xint     index;  /* Which connection to clear out */
X
X`123
X        int     i;  /* Loop control variable */
X
X        connects`091index`093.unit = 0;  /* Clear out the unit number */
X        connects`091index`093.channel = 0;  /* Clear out the channel number
V */
X        connects`091index`093.func_code = 0;  /* Clear out the function requ
Vest */
X        connects`091index`093.user_len = 0;  /* Initialize character to zero
V */
X        for (i = 0; i < DAE_MAX_USER_STR; i++)
X        `123
X                connects`091index`093.user_string`091i`093 = 32;  /* Blank o
Vut the user string */
X        `125
X        link_cnt = link_cnt - 1;  /* Decrement our link count */
X`125  /* clearconnect */
$ CALL UNPACK ND.C;1 221938363
$ create/nolog 'f'
Xsys$share:vaxcrtl/share
Xsys$system:sys.stb/sel
$ CALL UNPACK ND.OPT;1 140383634
$ create/nolog 'f'
X$  pria/head what.pas, -
X             what_defs.pas, -
X             what_parseimage.mar, -
X             what_look.mar, -
X             what_status.mar, -
X             dae_func.mar, -
X             what_trnlnm.mar, -
X             what_uptime.mar, -
X             what_retnodes.mar, -
X             what_buildusers.mar, -
X             what_msg.msg, -
X             nd.c, -
X             getncb.mar
$ CALL UNPACK PRINT_WHAT.COM;1 2118010551
$ create/nolog 'f'
X
X$ ENTRY_VERIFY = F$VERIFY(0)
X$ SET NOVERIFY
X$ !***************************************************************
X$ !**`009`009`009`009`009`009`009`009**
X$ !**`009`009`009START_What.COM`009`009`009`009**
X$ !**`009`009`009`009`009`009`009`009**
X$ !***************************************************************
X$ !
X$ ! MODULE`009: START_What.COM
X$ ! ISSUE`009: V 1.1
X$ ! DATE`009: 10-DEC-1988
X$ ! FUNCTION`009: Starts the What utility and loads the LAVdriver
X$ ! PARAMETERS`009:   P1  ON  `009Set verify on.
X$ !`009`009        OFF `009Set verify off (DEFAULT).
X$ !                 P2  RESTART Indicates a restart of the deamon
X$ ! OUTPUT`009: NIL
X$ ! GLOB.SYMBOLS: NIL
X$ ! LOG NAMES`009: NIL
X$ ! CALLS`009: What_Dir:whatlog.com
X$ ! CALLED BY`009: Startup_software.com
X$ !
X$ !***************************************************************
X$ !
X$ ! MODIFICATION RECORD:
X$ !
X$ !  Setup symbols.
X$ !
X$ SET NOON
X$ SET CONTROL=(Y,T)
X$ REMT`009== "WRITE SYS$ERROR ""''F$TIME()"
X$ REM`009== "WRITE SYS$ERROR """
X$ !
X$ !  Check if verify is required.
X$ !
X$ IF P1 .EQS. "ON" THEN $SET VERIFY
X$!
X$ IF P2 .EQS. "RESTART" THEN GOTO res_symbs
X$     start := ""
X$     restart := "!"
X$ GOTO start_what
X$ !
X$ res_symbs:
X$     start := "!"
X$     restart := ""
X$!
X$ start_what:
X$ set noon
X$!
X$!  START_WHAT.COM
X$! Procedures starts (or restarts) the network what Daemon
X$! and defines and installes necessary logicals and images
X$!
X$! Note:   SITE SPECIFIC WHAT logical names should be defined in
X$!         WHATLOG.COM.
X$!
X$!
X$!***********************************************************************
X$!
X$ what_disk = f$trnlnm("SYS$COMMON")
X$ mynode = f$getsyi("NODENAME")
X$!
X$ 'start define/sys/exec/nolog What_Dir 'what_disk'`091net_what`093
X$!
X$! set up site specific logical names
X$!
X$!  Define WHAT_xxx logical names to set up specific lists
X$!  for the WHAT/SELECT=xxx option.
X$!
X$!
X$ 'start IF F$SEARCH ("WHAT_DIR:WHATLOG.COM") .NES. "" THEN @What_Dir:whatlo
Vg.com
X$!
X$!************************************************************************
X$!+
X$!    We need some privs to do the following, check ...
X$!-
X$ reqprv = "CMKRNL,ACNT,SYSPRV,DETACH,WORLD,SYSNAM,NETMBX,TMPMBX,OPER"
X$ old_priv = f$setprV(reqprv)
X$ if .not.f$privilege(reqprv) then write sys$output "''f$message(36)'"
X$ if .not.f$privilege(reqprv) then goto end
X$!
X$!******** install sharable images
X$!
X$!  Since both WHAT and the Daemon access the following RTLs, Ensure that
X$!  they are /SHAREd
X$!
X$! define/nolog/sys/exec what_shr what_dir:what_shr.exe
X$!
X$ Install = "$install/command"
X$ IF P2 .EQS. "RESTART" THEN GOTO NO_install
X$!
X$ IF F$FILE_ATTRITIBUTES ("SYS$SHARE:PASRTL.EXE", "KNOWN") THEN -
X     Install remove sys$share:PASRTL
X$ IF F$FILE_ATTRITIBUTES ("SYS$SHARE:LIBRTL2.EXE", "KNOWN") THEN -
X     Install remove sys$share:LIBRTL2
X$ IF F$FILE_ATTRITIBUTES ("what_dir:what.exe", "KNOWN") THEN -
X     Install remove WHAT_DIR:WHAT.EXE
X$ Install
Xadd sys$share:pasrtl/open/head/share
Xadd sys$share:librtl2/open/head/share
Xadd what_dir:what.exe/open/head/share/priv=(world)
X$!
X$!+
X$!    Now see to it that the Load Average Driver gets loaded!
X$!-
X$ sysgen := $sysgen
X$ sysgen
X`009LOAD LAVDRIVER
X`009CONNECT LAV0 /NOADAPT/DRIVER=LAVdriver
X$ NO_install:
X$ deamon_process := "Netwhat_daemon"
X$ ncp := $ncp
X$!
X$ IF P2 .NES. "RESTART" THEN GOTO NO_restart
X$!
X$! Start (or Restart the Daemon)
X$!
X$!+
X$!    Check if the deamon already runs, if so stop it...
X$!-
X$ context = ""
X$ search_deamon:
X$     pid := 'f$pid(context)
X$     IF pid .EQS. "" THEN goto Not_found
X$     prcnam = F$getjpi(pid, "prcnam")
X$     IF prcnam .NES. deamon_process THEN GOTO search_deamon
X$    GOTO found
X$!
X$ found:
X$!+
X$!    Stop it...
X$!-
X$     stop/id='pid'! "''deamon_process'"
X$     ncp
Xclear obj netwhat all
X$!+
X$!    Now start the deamon
X$!-
X$ No_restart:
X$ ncp
Xset obj netwhat NUMBER 252
X$ run/detached -
X  /uic=`0911,4`093-
X  /priv=(nosame,sysprv,netmbx,tmpmbx,sysnam,world) -
X  /prio=5  what_dir:nd.exe -
X  /process="Netwhat_daemon" -
X  /noaccounting -
X  /output=what_dir:whatlog_'mynode'.log -
X  /err=what_dir:whatlog_'mynode'.err -
X  /page=10000 -
X  /file_limit=40 -
X  /ast_limit=30 -
X  /maximum_working=768 -
X  /extent = 1024 -
X  /buffer_lim = 10240 -
X  /enque_limit = 30 -
X  /io_buffer = 50 -
X  /working = 300
X$!
X$ Not_found:
X$ end:
X$ foo = f$setprv(old_priv)
X$ !
X$ !-------------------------------------------------------------------------
V----
X$ !
X$ EXIT:
X$    EXIT_VERIFY = F$VERIFY(ENTRY_VERIFY)
X$    EXIT
$ CALL UNPACK START_WHAT.COM;12 1195135612
$ create/nolog 'f'
X!***************************************************************************
V****
X!* WHAT *
X!*      Verb that returns various combinations of user formats from differen
Vt *
X!* nodes. *
X!***************************************************************************
V****
X
Xdefine verb what
X        image what_dir:what
X
X        qualifier node, value(required, type=$file, list) ! Get specified no
Vdes
X        qualifier select, value(required, type=$file)     ! Select a particu
Vlar group of nodes
X
X        qualifier user, value(required, type=$file)       ! Select a particu
Vlar user
X
X        qualifier brief, default, negatable               ! In show users fo
Vrmat
X        qualifier full, negatable                         ! In where/users f
Vormat
X        qualifier all                                     ! Show all the pro
Vcesses
X        qualifier status, negatable                       ! Output status li
Vnes only
X
X        qualifier silent                                  ! Dont output erro
Vrs talking to the nodes
X        qualifier total, negatable                        ! Total up /STATUS
Ves
X        qualifier header, default, negatable              ! Do we want the h
Veader line present
X
X        qualifier output, value(required, type=$file)     ! Send output to a
V file name
X
X        disallow select and node
X        disallow brief and all
X        disallow brief and full
X        disallow total and (full or all or brief)
X        disallow status and (all or brief or full or user)
X
X!***************************************************************************
V****
X!* Note:  The /SELECT qualifier will take a given value, and translate the *
X!*      logical name WHAT_value to get a list of the nodes to get info on. *
X!*      For instance, WHAT/SELECT=CLUSTER would translate the logical name *
X!*      WHAT_CLUSTER and talk to all the nodes there.  Define WHAT_value *
X!*      in this manner: *
X!* *
X!*      DEFINE WHAT_cluster node0, node1, node2, ... , nodeN *
X!* *
+-+-+-+-+-+-+-+-  END  OF PART 10 +-+-+-+-+-+-+-+-

