星期四, 11月 09, 2023

2017-11-21 Check Message Queue Manager started or not


Check Message Queue Manager started or not

File  : QCLSRC
Member: CHKMQM
Type  : CLLE
Usage : CrtCLMod   Module( ChkMqm )
        CrtPgm Pgm( ChkMqm ) BndSrvPgm((QMQM/LIBMQM))
        




/*-------------------------------------------------------------------*/
/*                                                                   */
/*  Program . . : CHKMQM                                             */
/*  Description : Check MQM Status                                   */
/*  Author  . . : Vengoal Chang                                      */
/*  Published . : AS400ePaper                                        */
/*  Date  . . . : November 21, 2017                                  */
/*                                                                   */
/*  Program function:  CHKMQM   command processing program           */
/*                                                                   */
/*                                                                   */
/*  Programmer's notes:                                              */
/*                                                                   */
/*  Compile options:                                                 */
/*    CrtCLMod   Module( ChkMqm )                                    */
/*    CrtPgm Pgm( ChkMqm )                                           */
/*           BndSrvPgm((QMQM/LIBMQM))                                */
/*-------------------------------------------------------------------*/
/*                                                                   */
/*  Exceptions monitored :                                           */
/*       MQCONN         MQRC_Q_MGR_STOPPING                          */
/*                      MQRC_Q_MGR_QUIESCING                         */
/*                      MQRC_Q_MGR_NOT_AVAILABLE                     */
/*                      MQRC_STORAGE_NOT_AVAILABLE                   */
/*                                                                   */
/*-------------------------------------------------------------------*/
     Pgm      ( &MQMName &RCChar)

     Dcl        &MQMName      *CHAR    48
     Dcl        &RCChar      *Char    10

     /* Define local variables                      */
     Dcl        &HCONN       *CHAR     4   X'00000000'
     Dcl        &CCODE       *CHAR     4   X'00000000'
     Dcl        &REASON      *CHAR     4   X'00000000'
     Dcl        &NOTAVAIL    *CHAR     4   X'0000080B'
     Dcl        &STOPPING    *CHAR     4   X'00000872'
     Dcl        &QUIESCING   *CHAR     4   X'00000871'
     Dcl        &NOSTORAGE   *CHAR     4   X'00000817'
     Dcl        &UNKNOWN     *CHAR     4   X'0000080A'

     Dcl        &MsgDta      *Char   256
     Dcl        &Rc          *Dec   (10 0)


/*-- Global error monitoring:  --------------------------------------*/
     MonMsg    (CPF0000 MCH3601)     *N        GoTo Error

     AddLibLe  QMQM
     MonMsg    CPF0000

     /******************************************************/
     /* Connect to queue manager                           */
     /******************************************************/
     CallPrc 'MQCONN' (&MQMName &Hconn &Ccode &Reason)
     If     (%bin(&Ccode) *ne 0) Do
          /*************************************************/
          /* MQCONN failed                                 */
          /*************************************************/
          ChgVar   &Rc     %Bin(&Reason)
          ChgVar   &RcChar &Rc
          Select
          When (&Reason = &STOPPING)  Do
            ChgVar &MsgDta ('Qmgr' *bcat &MQMName *Bcat +
                            'stopping, RC =' *bcat &RcChar)
          EndDo

          When (&Reason = &NOTAVAIL)  Do
            ChgVar &MsgDta ('Qmgr' *bcat &MQMName *Bcat +
                            'not available, RC =' *bcat &RcChar)
          EndDo
          When (&Reason = &QUIESCING) Do
            ChgVar &MsgDta ('Qmgr' *bcat &MQMName *Bcat +
                            'quiescing, RC =' *bcat &RcChar)
          EndDo
          When (&Reason = &NOSTORAGE) Do
            ChgVar &MsgDta ('Qmgr' *bcat &MQMName *Bcat +
                            'nostorage, RC =' *bcat &RcChar)
          EndDo
          When (&Reason = &UNKNOWN)   Do
            ChgVar &MsgDta ('Qmgr' *bcat &MQMName *Bcat +
                            'unknown, RC =' *bcat &RcChar)
          EndDo
          Otherwise  Do
            ChgVar &MsgDta ('Qmgr' *bcat &MQMName *Bcat +
                            'conn error, RC =' *bcat &RcChar)
          EndDo
          EndSelect

          SndPgmMsg  MsgId(CPF9898) MsgF(QCPFMSG) +
                     MsgDta(&MsgDta) ToPgmQ(*Ext) MsgType(*Info)
          Goto         Return
     ENDDO

     ChgVar &MsgDta ('Qmgr' *bcat &MQMName *Bcat +
                     'started')
     SndPgmMsg  MsgId(CPF9898) MsgF(QCPFMSG) +
                MsgDta(&MsgDta) ToPgmQ(*EXT) MsgType(*INFO)

     /******************************************************/
     /* MQCONN worked so disonnect                         */
     /******************************************************/
     CallPrc 'MQDISC' (&Hconn &Ccode &Reason)

 Return:
     Return

/*-- Error handling:  -----------------------------------------------*/
 Error:
     Call      QMHMOVPM    ( '    '                                  +
                             '*DIAG'                                 +
                             x'00000001'                             +
                             '*PGMBDY'                               +
                             x'00000001'                             +
                             x'0000000800000000'                     +
                           )

     Call      QMHRSNEM    ( '    '                                  +
                             x'0000000800000000'                     +
                           )

 EndPgm:
     EndPgm



File  : QCMDSRC
Member: CHKMQM
Type  : CMD
Usage : CrtCmd      Cmd( CHKMQM  )	
                    Pgm( CHKMQM   )
                    SrcFile( QCMDSRC )	
                    Allow( *IPGM *BPGM )					

       


/*-------------------------------------------------------------------*/
/*                                                                   */
/*  Compile options:                                                 */
/*                                                                   */
/*    CrtCmd Cmd( CHKMQM )                                           */
/*           Pgm( CHKMQM )                                           */
/*           SrcMbr( CHKMQM )                                        */
/*           Allow( *IPGM *BPGM )                                    */
/*                                                                   */
/*-------------------------------------------------------------------*/
          Cmd      Prompt( 'Check MQ Queue Manager')

          Parm     Kwd(MQMNAME) Type(*CHAR) Len(48) Min(1) +
                   Prompt('Message Queue Manager name')

          Parm     Kwd(RC) Type(*CHAR) Len(10)  +
                   RtnVal(*Yes)                 +
                   Prompt('Return code')


						
File  : QCLSRC
Member: CHKMQMTSTC
Type  : CLP 
Usage : CRTCLPGM CHKMQMTSTC

PGM
     DCL &MQMNAME        *CHAR     48
     DCL &RC             *CHAR     10


/*-- Global error monitoring:  --------------------------------------*/
     MonMsg     CPF0000      *N        GoTo Error

     CHGVAR     &MQMNAME              'TEST'
     CHKMQM     MQMNAME(&MQMNAME) RC(&RC)
     If        (&RC *NE ' ') Do
               DmpClPgm
       /* MQM got Exception */
       /* do exception process */
     EndDo

     CHGVAR     &MQMNAME              'TEST1'
     CHKMQM     MQMNAME(&MQMNAME) RC(&RC)
     If        (&RC *NE ' ') Do
               DmpClPgm
       /* MQM got Exception */
       /* do exception process */
     EndDo

 Return:
     RCLACTGRP  ACTGRP(*ELIGIBLE)
     Return

/*-- Error handling:  -----------------------------------------------*/
 Error:
     RCLACTGRP  ACTGRP(*ELIGIBLE)

     Call      QMHMOVPM    ( '    '                                  +
                             '*DIAG'                                 +
                             x'00000001'                             +
                             '*PGMBDY'                               +
                             x'00000001'                             +
                             x'0000000800000000'                     +
                           )

     Call      QMHRSNEM    ( '    '                                  +
                             x'0000000800000000'                     +
                           )

 EndPgm:
     EndPgm



沒有留言: