[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference humane::scheduler

Title:SCHEDULER
Notice:Welcome to the Scheduler Conference on node HUMANEril
Moderator:RUMOR::FALEK
Created:Sat Mar 20 1993
Last Modified:Tue Jun 03 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1240
Total number of notes:5017

1062.0. "Real Time Messages to a file ?" by ROM01::CALDONI () Wed Apr 10 1996 12:46

    
    Hi,
    
    Any chances to redirect to a file the "Real Time Messages" so it will
    be possible to monitor the access for security reason ?
    
    Thanks a lot.
    
    Gaetano
T.RTitleUserPersonal
Name
DateLines
1062.1scheduler_listnerHLFS00::ERIC_SEric Sonneveld MCS - B.O. IS HollandThu Apr 11 1996 06:03379
>    
>    Any chances to redirect to a file the "Real Time Messages" so it will
>    be possible to monitor the access for security reason ?

Yes.

There is a scheduler listen program, which just dumps the messages of all
scheduler engine's. I use it already for many years. It needs syslck priv to
run. It's from the old scheduler V1 notes conference:

================================================================================
Note 954.0       real-time message display program - source code    No replies
RUMOR::FALEK "ex-TU58 King"                       360 lines  15-APR-1992 18:49
--------------------------------------------------------------------------------

*** This is under discussion in notesfile AISG::SCHEDULER ***

    The DECscheduler distribution saveset contains source code for
    a BASIC program that listens to the same messages the workstation
    interface listens to for keeping its screen updated.

    This is undocumented (you have to know its there and unpack it manually
    from the saveset). We tell people about it sometimes at DECUS.

    In V1.1A it stopped working because we changed the message format.
    The message type field went from longword to byte to free up bytes
    for passing which PID issued UI requests and for eventual use in
    real-time monitoring of remote (not the same VAXcluster) jobs.

    We're going to put the corrected source code in the T2.0-BL1 kit
    In the meantime, I'm posting it here in case anyone is interested
    (may also be easier than extracting from the saveset).

    To build:
        $ basic sched_listen
        $ basic msg_ast
        $ link sched_listen,msg_ast

    To run:
        $ run sched_listen (syslck privilege required)

    ---------sched_listen.bas---(hasn't changed from V1.1)----

1       REM   SCHED_LISTEN.BAS - display changes to DECscheduler jobs

        Copyright 1989,1990 Digital Equipment Corporation

        This program is UNSUPPORTED.
        It can be used to display in real time changes in the status of
        DECscheduler jobs.

        How it works:

        Obtain a NL-mode lock on resource "GUIDO_MSG" and a CR-mode lock on
        "GUIDO_SIGNAL".  In the call to $ENQW, it specifies that
        MSG_AST blocking AST (linked with this program) be delivered if
        another program's lock request is blocked by our lock on "GUIDO_SIGNAL"

        MSG_AST contains a protocol to read the broadcast message, which
        is contained in the GUIDO_MSG lock value block.

        Multiple copies of this can run in a VAXcluster without interfering
        with each other or with any message sender.

        (Messages are sent using undocumented routine TELL_GUIDO, in
         NSCHED_SUBS.OLB)

        To build:
                $ BASIC SCHED_LISTEN
                $ LINK SCHED_LISTEN,MSG_AST
                $ SET PROC/PRIV=SYSLCK ! syslck privilege required!
                $ RUN SCHED_LISTEN
                 (or $ SPAWN/NOWAIT/INPUT=NL: SCHED_LISTEN)

10      option type=explicit

        external long function sys$enqw,sys$hiber
        external long constant msg_ast  ! Address of Blocking AST

        declare long constant           &
        lck$k_nlmode=X'00000000'L,      &
        lck$m_system=X'00000010'L,      &
        lck$m_valblk=X'00000001'L,      &
        lck$k_crmode=X'0000001'L,       &
        lck$m_nodlckwt=X'00000200'L

        declare long cstatus
        MAP (lock$block) long m_lblk(5%),long s_lblk(1%) ! map with lockblocks

        !print "Waiting for NL-mode lock on GUIDO_MSG..."
        cstatus=sys$enqw(       ,                       ! efn           &
                                lck$k_nlmode by value,  ! lkmode        &
                                m_lblk() by ref,        ! status_block  &
                                lck$m_system by value,  &
                                "GUIDO_MSG",            ! resource name &
                                ,                       ! parent lockid &
                                ,                       ! ast addr      &
                                ,                       ! ast parm      &
                                ,                       ! blocking ast  &
                                ,       )               ! access mode, null

        if not cstatus and 1% then      ! error getting lock (privilege?)
                print "error Getting GUIDO_MSG lock: ";cstatus;" bye-bye now."
                goto 32767      ! probably lack of SYSLCK priv
        else
                !print "Waiting for shared read lock on GUIDO_SIGNAL..."
                cstatus=sys$enqw(       ,                       ! efn   &
                                lck$k_crmode by value,  ! lkmode        &
                                s_lblk() by ref,        ! status_block  &
                                lck$m_nodlckwt or lck$m_system by value,&
                                "GUIDO_SIGNAL",         ! resource name &
                                ,                       ! parent lockid &
                                ,                       ! ast addr      &
                                ,                       ! ast parm      &
                                msg_ast by value,       ! blocking ast  &
                                ,       )               ! access mode, null
                if cstatus=1% then &
                        print "Listening for broadcast messages from Schedulers..."
                        cstatus=sys$hiber
                else            &
                        print "error getting GUIDO_SIGNAL lock: ";cstatus
                end if
        end if
32767   end

    --------------MSG_AST.BAS-----(for V1.1A and T2.0-BL0,1)--------------
        SUB MSG_AST ( long OUR_PARAM, R0, R1, PC, PSL)

        ! Copyright 1989,1992 Digital Equipment Corporation
        ! DECscheduler V1.1A, T2.0

        ! Blocking AST for SCHED_LISTEN program.
        ! This program is UNSUPPORTED.
        ! It can be used to display in real time changes in the status of
        ! DECscheduler jobs.

        ! This blocking AST recieves VAXcluster broadcasts
        ! which are sent whenever a Scheduler changes the state of a job.
        ! It is triggered when the Scheduler calls TELL_GUIDO (in NSCHED_SUBS)
        ! to send a message. TELL_GUIDO puts a message in the GUIDO_MSG
        ! lock value block, then requests a lock on "GUIDO_SIGNAL" in EX-mode,
        ! We never actually give up our lock on GUIDO_SIGNAL, rather, we
        ! call $GETLKIW to get the info from the GUIDO_MSG lock value block.

        ! Note that this AST only receives the LATEST message sent.
        ! If messages are sent more quickly then they are read, they are
        ! over-written (not queued).

        OPTION TYPE = EXPLICIT
        external long function sys$getlkiw,sys$enqw,lib$wait,lib$date_time,&
                sys$exit,lib$getjpi
        external long constant msg_ast,ss$_valnotvalid

        declare long constant           &
        lck$m_system=X'00000010'L,      &
        lck$m_valblk=X'00000001'L,      &
        lck$m_convert=X'00000002'L,     &
        lck$k_nlmode=X'00000000'L,      &
        lck$k_crmode=X'00000001'L,      &
        lck$k_exmode=X'00000005'L,      &
        lck$m_nodlckwt=X'00000200'L

        declare word constant lki$_valblk=X'203'W,  ! to request value block &
                              lki$_locks=X'208'W    ! to request info on locks

        declare long cstatus,flags,number_of_locks,i
        declare string old,new, info_state,who,user

        ! SCHED_LISTEN.BAS (which we're linked with) uses same lock$block map
        map (lock$block) word cond,word fill,long lock_id, string msg=16%, &
                        long s_lblk(1%),string current_time=20%

        ! description of lock status/value block fields for message lock
        map(mbuf) string ret_buffer=16%,long buff_len ! for returned info
        map(mbuf) long jobnum,string mtype=1%,string old_state=1%,&
                new_state=1%,string fill$=3,string sender=6%
        map(mbuf) long jobnum,string mtype=1%,string operation=1%,&
                long pid,string sender=6%
        map (mbuf) string signals_info=1024% ! info on all signal locks

        ! description of lock info returned by $GETLKIW for signal lock(s)
        map(msignal) long s_lockid,long s_opid, long s_sid, &
                   byte s_reqmode, byte s_grmode, byte s_que, byte s_fill, &
                   long s_remid, long s_remsid
        map(msignal) string one_lock=24% ! buffer for info about one signal lock


        record item_list                ! declare item_list structure
                word buffer_len         ! for system services
                word item_code
                long buff_addr
                long ret_len_addr
                long end_list
        end record item_list
        declare item_list items                 ! fill in the item list

        DEF string long_to_hex(long inlong)     ! longword to HEX string
        ! convert a longword to a hexadecimal string
        external long function ots$cvt_l_tz
        declare string hex_string
        hex_string=space$(8%)
        cstatus=ots$cvt_l_tz(inlong,hex_string,8% by value,4% by value)
        long_to_hex=hex_string
        END DEF

        ! Call SYS$GETLKIW to get the value block for the GUIDO_MSG lock
        ! fill in item list for call to $GETLKIW
        items::item_code=lki$_valblk            ! value block wanted
        items::buffer_len=16%                   ! our buffer length
        items::buff_addr=loc(ret_buffer)        ! addr. of ret_buffer
        items::ret_len_addr=loc(buff_len)       ! addr of length of retd. info
        items::end_list=0                       ! terminator

        cstatus=sys$getlkiw( ,! efn         &
                        lock_id,! lock-id addr  &
                        items,   ! item list        &
                        ,,,)

        if cstatus<>1% then     ! error &
                print "MSG_AST: GETLKIW error : ";cstatus
                cstatus=sys$exit(cstatus by value) ! exit program
        end if

        ! parse the value block
        ! The format is  job_number (longword), mtype (byte) (changed in V1.1A)
        ! data for state change msg (mtype="0") :
        !       old_state (1 byte) new_state (1 byte) sender_node (6 bytes)
        ! data for create/modify msg (mtype="1") :
        !       operation (1 byte = "C" or "M"
        !       PID that did it (long)
        !       sender node (6 bytes)
        ! data for informational msg (mtype="2") : see code

        cstatus=lib$date_time(current_time)     ! get current time



        if mtype="5"  then ! local job success completion   &
                print current_time;" Job";jobnum; &
                 "completed with SUCCESS status on ";trm$(sender)
                goto re_set
        else
                if mtype="6"  then ! local job success completion   &
                        print current_time;" Job";jobnum; &
                        "completed with FAILURE status on ";trm$(sender)
                        goto re_set
                end if
        end if

        if mtype="0" then ! job state change &
                ! make understandable strings out of 1 byte states
                select old_state
                case = "S"
                        old="Scheduled"
                case="J"
                        old="Job Slot Wait"
                case="R"
                        old="Running"
                case="D"
                        old="Job dependency wait"
                case="H"
                        old="Holding"
                case="Q"
                        old="Queued"
                case else
                        old=old_state
                end select

                select new_state
                case = "S"
                        new="Scheduled"
                case="J"
                        new="Job Slot Wait"
                case="R"
                        new="Running"
                case="D"
                        new="Job dependency wait"
                case="H"
                        new="Holding"
                case="Q"
                        new="Queued"
                case else
                        new=new_state
                end select

                print current_time;" Job";jobnum;"changed from "; &
                    old;" to ";new;" on ";trm$(sender)
                goto re_set
        end if


        if mtype="1"  then ! user-interface command &
                cstatus=lib$getjpi(X'202'L,pid,,,user,)! pid to user
                who=" Username="+trm$(user)+", PID="+long_to_hex(pid)
                print current_time;" Job";jobnum;
                select operation
                case="M"
                        print "Modified by";who
                case="C"
                        print "Created by";who
                case="D"
                        print "Delete Requested by";who
                case="A"
                        print "Abort Requested by";who
                case="H"
                        print "Hold Requested by";who
                case="U"
                        print "Release Requested by";who
                case="N"
                        print "Run Requested by";who
                case="R"
                        print "Deleted from job database by server"
                case else
                        print "Operation = ";operation
                end select
        else
                print current_time;" Unknown event type ";mtype; " job ";jobnum
        end if


        if mtype="2" then ! informational msg from NSCHED &
                info_state = old_state+new_state
                select info_state
                case = "XR"
                        new="Exceeded maximum run-time"
                case = "XS"
                        new="Exceeded maximum stall-time without starting"
                case else
                        new="unknown informational event"
                end select
                print current_time;" Job";jobnum;new;" on ";trm$(sender)
                goto re_set
        end if

   re_set:
        ! loop until sender has $deq'd lock request
        ! call $getlkiw until no more requestors are waiting

        ! fill in item list code for call to $GETLKIW
        items::item_code=lki$_locks             ! get info on all SIGNAL locks
        items::buffer_len=1024%                 ! up to 1024 bytes total
        items::buff_addr=loc(signals_info)      ! addr. of ret_buffer
        get_info:
        cstatus=sys$getlkiw( ,! efn         &
                s_lblk(1%),! lock-id of SIGNAL lock &
                items,   ! item list        &
                        ,,,)

        print "bad status from GETLKIW (signal) : ";cstatus if cstatus<>1%
        number_of_locks=(buff_len and 65535%)/24% ! save returned info

        for i=number_of_locks-1% to 0% step -1%
                ! backwards because EX requested lock is usually last
                lset one_lock=seg$(signals_info,(i*24%)+1%,(i*24%)+24%)
                if (s_reqmode=lck$k_exmode) then ! talker's still queued &
                        cstatus=lib$wait(0.1)   ! wait 0.1 sec, save SCS
                        goto get_info
                end if
        next i

        ! convert GUIDO_SIGNAL lock from CR to CR to reset blocking AST
        cstatus=sys$enqw        ( ,             ! efn           &
                lck$k_crmode by value,  ! lkmode        &
                s_lblk() by ref,        ! status_block  &
                lck$m_system or lck$m_nodlckwt or lck$m_convert by value, &
                "GUIDO_SIGNAL",         ! resource name (ignored for converts) &
                ,                       ! parent id     &
                ,                       ! ast addr      &
                ,                       ! ast parm      &
                MSG_AST by value,       ! blocking ast  &
                ,       )               ! access mode,null
        if not cstatus and 1% then
                print "MSG_AST: SIGNAL lock CR-CR ERROR: ";cstatus;
                exit sub
        end if

        END SUB

1062.2not supportedMRBASS::PUISHYSProject Leader Scheduler V3.0 for Digital UNIXThu Apr 11 1996 19:133
    If you use .1 The scheduler Team does not Offcialy support this!
    bob