My FAQ,最新最全的IT技术FAQ
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 未整理篇 | 技术讨论
  当前位置: > 操作系统 > IBM Server
如何查看JOBLOG?(转载)
作者:未知 时间:2005-09-13 15:44 出处:ChinaUnix.net 责编:My FAQ
              摘要:如何查看JOBLOG?(转载)

有時候系統本身的 System Job (以 Q 開頭的 Job)會寫某些通知性質的訊息至 Job Log, 但
並未將該訊息寫至 QSYSOPR message queue 或 System Log, 所以有時候系統管理人員並無法
得知需要的訊息, 如有可能需要知道誰透過ODBC, OLEDB 或 JDBC 連線進入系統, 要取
得這些資訊可以藉由 Exit Program 或利用 檢查 Job log 的方式. 這裡我僅利用檢查 Job log 
的方式完成檢查 MSGID CPIAD02.
[code:1:d253d50631]File  : QRPGLESRC
Member: CHKJOBLOGR
Type  : RPGLE
Usage : CRTBNDRPG CHKJOBLOGR
OS version : V5R1(but also can modify to V4R5 earlier for 
            %LOOKUP bulid-in function to LOOKUP opcode)


    H DFTACTGRP(*NO) ACTGRP(*CALLER) BNDDIR('QC2LE') EXPROPTS(*RESDECPOS)
    H DATFMT(*ISO)   TIMFMT(*ISO)    OPTION(*NODEBUGIO) DEBUG
     *----------------------------------------------------------------
     * CHKJOBLOG  Check specified job's job log
     * Copyright (C) 10/02/2002  Vengoal Chang    
     * This program is free software, you can redistribute it and/or modify it under the terms
     * of the GNU General Public License as published by the Free Software Foundation.
     *
     *----------------------------------------------------------------
     * This program retrieve specified job job's log and send all log
     * to QSYSOPR message queue, you could modify for checking message
     * type or message id to archive yourself purpose.
     *----------------------------------------------------------------
     * api (application program interfaces) used:
     * quscrtus  create user space
     * qusptrus  retrieve pointer to user space
     * qmhljobl  list job log messages
     * qmhsndm   send non-program messages
     *----------------------------------------------------------------
    D uSpaceName      s             20    inz('CHKJOBLOG QTEMP     ')
    D msgtxt          s            256
    D QUSLIB          s             10

    D MsgIdDs         Ds
    D  MsgIdEntSize                  4B 0
    D  MsgIdEntStr                   7    Dim( 20 )
     *Array for contain MsgIdStr
    D MsgIdAry        S             10    Dim( 20 )
    D                                     Inz( *HiVal )    Ascend
    D Idx             S              2  0
    D AryIdx          S              2  0
    D iMsgId          S              7

     *  -------------------------------------------------------------------
     *  -  User space attributes data structure                           -
     *  -------------------------------------------------------------------

    D QUSAttr         DS
    D  QUSNumRec                    10I 0 Inz( 1 )
    D  QUSKey                       10I 0 Inz( 3 )
    D  QUSRecLen                    10I 0 Inz( 1 )
    D  QUSRecData                    1A   Inz( '1' )
     *----------------------------------------------------------------
    D struct          DS
    D  msgdln                       10I 0
    D  msgq#                        10I 0
    D  msgkey                        4
    D  msgq                         20    INZ('QSYSOPR   *LIBL     ')
     *
     *----------------------------------------------------------------
     * Get user space list info from header section.
     *----------------------------------------------------------------
    D                 ds                  based(uHeadPtr)
    D uOffSetToList         125    128i 0
    D uNumOfEntrys          133    136i 0
    D uSizeOfEntry          137    140i 0
     *
    D uListEntry1     ds                  Based(uListPtr )
    D uOffsetToNext                 10i 0 overlay(uListEntry1:1)
    D uOffsetToFlds                 10i 0 overlay(uListEntry1:5)
    D uNumFldsRetrnd                10i 0 overlay(uListEntry1:9)
    D uMsgSeverity                  10i 0 overlay(uListEntry1:12)
    D uMsgId                         7a   overlay(uListEntry1:17)
    D uMsgType                       2a   overlay(uListEntry1:24)
    D uMsgKey                        4a   overlay(uListEntry1:26)
    D uMsgFile                      20a   overlay(uListEntry1:30)
    D uMsgFileName                  10a   overlay(uListEntry1:30)
    D uMsgFileLib                   10a   overlay(uListEntry1:40)
     * these fields repeat for each key selected.
    D uListEntry2     ds                  Based(uListPtr2)
    D u2OffsetToNext                10i 0
    D u2LengthOfFlds                10i 0
    D u2IdentifierF                 10i 0
    D u2TypeOfData                   1a
    D u2StatOfData                   1a
    D u2Reserved                    14a
    D u2LengthOfData                10i 0
    D u2Data                       500
     *----------------------------------------------------------------
     * Error return code parm for APIs.
     *----------------------------------------------------------------
    D vApiErrDs       ds
    D  vbytpv                       10i 0 inz(%size(vApiErrDs))
    D  vbytav                       10i 0 inz(0)
    D  vmsgid                        7a
    D  vresvd                        1a
    D  vrpldta                      50a
     *
     *----------------------------------------------------------------
     * Message selection data structure.
     *
     *                               Retrieve JOB Log direction
     *-----------------------------|-------------|--------------------
     * Parameter                   | From Top    | From Bottom
     *-----------------------------|-------------|--------------------
     * msListDirection             | *NEXT       | *PRV
     * msStartingMessageKey        | X'00000000' | X'FFFFFFFF'
     *----------------------------------------------------------------
    D MsgSelectDS     ds
    D  msMaxMsgRequested...
    D                               10i 0 inz(-1)     overlay(msgSelectDS:1)   num of msg requested
    D  msListDirection...
    D                               10a   inz('*NEXT') overlay(msgSelectDS:5)   List direction
    D  msQualifiedJobName...
    D                               10a   inz('*')    overlay(msgSelectDS:15)     * = current job
    D  msQualifiedUserName...
    D                               10a   inz(' ')    overlay(msgSelectDS:25)       = current job
    D  msQualifiedJobNumber...
    D                                6a   inz(' ')    overlay(msgSelectDS:35)       = current job
    D  msInternalJobIdentifier...
    D                               16a   inz(' ')    overlay(msgSelectDS:41)       = current job
    D  msStartingMessageKey...
    D                                4a   inz(x'00000000')                     start newest message
    D                                                 overlay(msgselectDS:57)
    D  msMaxMsgLength...
    D                               10i 0 inz(500)    overlay(msgSelectDS:61)  id 301,302 lengths
    D  msMaxMsgHelpLength...
    D                               10i 0 inz(100)    overlay(msgSelectDS:65)  id 401,402,403,404
    D  msOffsetToIdentifiersOfFieldstoReturn...
    D                               10i 0 inz(84)     overlay(msgSelectDS:69)  to start of array
    D  msNumberOfFieldsToReturn...
    D                               10i 0 inz(1)      overlay(msgSelectDS:73)
    D  msOffsetToCallMsgQname...
    D                               10i 0 inz(88)     overlay(msgSelectDS:77)
    D  msLengthOfCallMsgQname...
    D                               10i 0 inz(1)      overlay(msgSelectDS:81)
    D  msIndentifiersOfFieldsToReturn...
    D                               10i 0 inz(0302)   overlay(msgSelectDS:85)
    D  msCallMessageQueueName...
    D                                1a   inz('*')    overlay(msgSelectDS:89)
     *----------------------------------------------------------------
     * Create Prototypes for calls
     * --------------------------------------------------------------------
     *  -  QusCrtUs  - Create User Space API                              -
     *  -                                                                 -
     *  -  Usage      Length   Type         Parameter Description         -
     *  -                                                                 -
     *  -  Input          20   Character    Qualified user space name     -
     *  -  Input          10   Character    Extended attribute            -
     *  -  Input         4 0   Binary       Initial size                  -
     *  -  Input           1   Character    Initial value                 -
     *  -  Input          10   Character    Public authority              -
     *  -  Input          50   Character    Text description              -
     * --------------------------------------------------------------------
    D quscrtus        PR                  ExtPgm('QUSCRTUS')
    D                               20
    D                               10    const
    D                               10i 0 const
    D                                1    const
    D                               10    const
    D                               50    const
    D                               10    const
    Db                                    like(vApiErrDS)
     *  -------------------------------------------------------------------
     *  -  Qusptrus      - Get user space pointer       API               -
     *  -                                                                 -
     *  -  Usage      Length   Type         Parameter Description         -
     *  -                                                                 -
     *  -  Input          20   Character    Qualified user space name     -
     *  -  Output          *   Pointer      UserSpace Pointer             -
     *  -  Output                           Error Code                    -
     *  - -----------------------------------------------------------------
    D qusptrus        PR                  ExtPgm('QUSPTRUS')                   retrieve pointer
    D                               20                                         Space Name
    D                                 *                                        pointer
    Db                                    like(vApiErrDS)                      error parm
     *  -------------------------------------------------------------------
     *  -  Quscusat      - Change User Space Attributes API               -
     *  -                                                                 -
     *  -  Usage      Length   Type         Parameter Description         -
     *  -                                                                 -
     *  -  Output         10   Character    Returned library              -
     *  -  Input          20   Character    Qualified user space name     -
     *  -  Input          13   Character    Attribute structure           -
     *  -  Output                           Error code                    -
     *  -------------------------------------------------------------------
    D quscusat        PR                  ExtPgm( 'QUSCUSAT' )
    D                               10A   Const
    D                               20A   Const
    D                               13A   Const
    Db                                    like(vApiErrDS)
     *  ---------------------------------------------------------------
    D system          PR            10I 0 extproc('system')
    D  i_cmd                          *   value options(*string)
     *
    D EXCP_MSGID      S              7A   import('_EXCP_MSGID')
     *  --------------------------------------------------------------
    D qmhljobl        PR                  ExtPgm('QMHLJOBL ')
    D                               20
    D                                8    const
    Db                                    like(MsgSelectDS)
    D                               10i 0 const
    D                                8    const
    Db                                    like(vApiErrDS)
     *  --------------------------------------------------------------
    D qmhsndm         PR                  ExtPgm('QMHSNDM')
    D  msgid                         7    const
    D  msgfil                       20    const
    D  msgtxt                      256    const
    D  msglen                       10i 0 const
    D  msgtype                      10    const
    D  msgq                         10    const
    D  msgq#                        10i 0 const
    D  rpymq                        20    const
    D  msgkey                        4    const
    Db                                    like(vApiErrDS)
     *  --------------------------------------------------------------

    D main            PR                  extpgm('MONJOBLOGR')
    D  jobname                      10
    D  jobuser                      10
    D  jobnumber                     6
    Db                                    like(MsgIdDs)
    D  tomsgq                       20

    D main            PI
    D  jobname                      10
    D  jobuser                      10
    D  jobnumber                     6
    D  msgIdDsinput                       like(MsgIdDs)
    D  tomsgq                       20
     *----------------------------------------------------------------
    C                   eval      msQualifiedJobName   = jobname
    C                   eval      msQualifiedUserName  = jobuser
    C                   eval      msQualifiedJobNumber = jobnumber
    C                   eval      msgIdDs = msgIdDsInput
    C                   eval      msgq = tomsgq

    C                   Eval      Idx = 0
    C                   Eval      AryIdx = 0

    C                   DoW       Idx < MsgIdEntSize
    C                   Eval      Idx = Idx + 1
    C                   Eval      iMsgId = MsgIdEntStr(Idx)

     * only show msgid once
     * regardless of number times used.
    C                   If        AryIdx = 0  or
    C                             %lookup(iMsgId:MsgIdAry:1:AryIdx) = 0
    C                   Eval      AryIdx = AryIdx + 1
    C                   Eval      MsgIdAry(AryIdx)  = MsgIdEntStr( Idx )
    C                   EndIf

    C                   EndDo

     *----------------------------------------------------------------
     * Create user space
    C                   callp     QUSCRTUS(
    C                             uSpaceName:
    C                             'TEST':
    C                             1500000:
    C                             x'00':
    C                             '*ALL':
    C                             'User Space CHKJOBLOG' :
    C                             '*NO':
    C                             vApiErrDs)
     * set UserSpace to autoextended
    C                   CallP     QUSCUSAT( QUSLib     :
    C                                       uSpaceName :
    C                                       QUSAttr    :
    C                                       vApiErrDs  )
     * Get pointer to user space
    C                   callp     QUSPTRUS(
    C                             uSpaceName:
    C                             uHeadPtr:
    C                             vApiErrDs)
     * call api to load job log into user space.
    C                   callp     QMHLJOBL(
    C                             uSpaceName:
    C                             'LJOB0100':
    C                             MsgSelectDS:
    C                             %len(MsgSelectDS):
    C                             'JSLT0100':
    C                             vApiErrDs)
     * Process elements
     *
    C                   eval      uListPtr  = uHeadPtr + uOffSetToList
1B  C                   do        uNumOfEntrys

    C                   If        %lookup('*ALL   ':MsgIdAry:1:AryIdx) > 0 or
    C                             %lookup(uMsgId   :MsgIdAry:1:AryIdx) > 0
    C                   eval      uListPtr2 = uHeadPtr + uOffsetToFlds

    C                   eval      msgtxt = 'Job log: ' +
    C                                      %trim(jobnumber) + '/' +
    C                                      %trim(jobuser)   + '/' +
    C                                      %trim(jobname)   + ' ' +
    C                                         uMsgId + ': ' +
    C                                      %subst(u2Data:1:U2LengthOfData)

    C                   CALLP     QMHSNDM(
    C                             '       ' :
    C                             '                    ' :
    C                             %trim(msgtxt)  :
    C                             %len(%trim(msgtxt)) :
    C                             '*INFO     ' :
    C                             msgq :
    C                             1    :
    C                             '                    ' :
    C                             '    '  :
    C                             vApiErrDs)
    C                   EndIf

    C                   eval      uListPtr  = uHeadPtr  + uOffsetToNext
1E  C                   enddo

    C                   eval      *inlr = *on
    C                   return
File  : QCMDSRC
Member: CHKJOBLOG
Type  : CMD
Usage : CRTCMD CMD(CHKJOBLOG) PGM(CHKJOBLOGR)


/********************************************************************/
/*   Title:      CHKJOBLOG: Check jobs log                          */
/*                                                                  */
/*   Description - This command performs job log checked by MSGID   */
/*                                                                  */
/*   The Create Command command should include the following:       */
/*                                                                  */
/*           CRTCMD     CMD(CHKJOBLOG) PGM(CHKJOBLOGR)              */
/*                                                                  */
/********************************************************************/
     /*------------------------------------------------*/
     /*  Command Definition                            */
     /*------------------------------------------------*/

            CMD        PROMPT('Check Job Log')
            PARM       KWD(JOB) TYPE(*SNAME) LEN(10) MIN(1) +
                         PROMPT('Job name')
            PARM       KWD(USER) TYPE(*SNAME) LEN(10) MIN(1) +
                         PROMPT('User name')
            PARM       KWD(JOBNBR) TYPE(*CHAR) LEN(6) RANGE(000000 +
                         999999) MIN(1) PROMPT('Job number')
            PARM       KWD(MSGID) TYPE(*CHAR) LEN(7) SPCVAL((*ALL)) +
                         MIN(1) MAX(20) PROMPT('Message ID to be +
                         checked')
            PARM       KWD(TOMSGQ) TYPE(MSGQ)                 +
                         PROMPT('Send log to message queue')

MSGQ:       QUAL       TYPE(*NAME) LEN(10) DFT(QSYSOPR) +
                         SPCVAL((QSYSOPR)) EXPR(*YES)
            QUAL       TYPE(*NAME) LEN(10) DFT(*LIBL) +
                         SPCVAL((*LIBL) (*CURLIB)) EXPR(*YES) +
                         PROMPT(Library)[/code:1:d253d50631]

 andrewleading_he 回复于:2004-02-23 09:01:24
幫忙頂一下,^_^ ,有空拉下來看看。

 xuguopeng 回复于:2004-02-23 09:03:09
我还没试呢 据说可以查看使用CA操作的用户记录

 居士 回复于:2004-02-23 09:14:37
不错,加精。

大家谁有机会测试一下,把测试结果与大家分享啊

 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 myfaq.com.cn All rights reserved. www.myfaq.com.cn 版权所有