ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Collecting QSYSOPR messages in a PF

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Collecting QSYSOPR messages in a PF

    CODE400 iSeries folks,

    I would like to automate the monitoring of QSYSOPR message queue alerts , The idea is to collect all the Logs from the QSYSOPR msgq in formatted text and sort it based on Date and Severity and store it for emailing


    i have pasted the format which i intend to collect the logs



    Date Time Message ID Sev Acc Type Rpy Message Text
    23/09/11 13:25:58 CPA0701 99 0001 INQ C LBE9001 received by WEBFAC01 at 10400. (C D I R)
    23/09/11 11:25:01 CPC1125 50 0001 COMP Job 22333/RBB001/DAYMON was ended by user QSECOFR.
    23/09/11 21:00:02 CPC1126 50 0001 COMP Job 32454/QYPSJSVR/QYPSJSVR was ended by user QSECOFR.


    Any help is really appreciated

    Roch
    When computing, whatever happens, behave as though you meant it to happen

  • #2
    Re: Collecting QSYSOPR messages in a PF

    DSPMSG MSGQ(*SYSOPR) OUTPUT(*PRINT)

    then

    crtpf mylibrary/myfile rcdlen(198)

    then

    cpysplf into the file...

    now you can read it
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: Collecting QSYSOPR messages in a PF

      Originally posted by jamief View Post
      DSPMSG MSGQ(*SYSOPR) OUTPUT(*PRINT)

      then

      crtpf mylibrary/myfile rcdlen(198)

      then

      cpysplf into the file...

      now you can read it



      Jamie,

      I did exactly what you had mentioned above . My requirement is to store it in a PF in a formatted way as below. copying spool QPDSPMSG into a PF gives it likes this




      MSGID SEV MSG TYPE
      ODE0405 00 INFO Job ODS_SEND01 either could not contact system BALINT or lost contact with it. Reinitiating
      ODS_SEND01 VSIOWNER 899788 ODC262 0000 27/10/11 13:03:29,855432 VSIOWNER
      ODE0405 00 INFO Job ODS_SEND01 either could not contact system BALINT or lost contact with it. Reinitiating
      ODS_SEND01 VSIOWNER 899788 ODC262 0000 27/10/11 13:05:50,085768 VSIOWNER




      HTML Code:
      
       MESSAGE ID  SEVERITY  REPLY   TYPE        JOB NAME    JOB USER    JOB NUMBER  MESSAGE                 
       CPI1E23       00             COMPLETION  QSYSSCD     QPGMR         899494    Cleanup has started.                          
       CPI1E82       00             INFO        QCLNUSRMSG  QPGMR         903499    Cleanup of user messages started.             
       CPI1E84       00             INFO        QCLNSYSMSG  QPGMR         903500    Cleanup of operator and work station messages 
       CPI1E93       00             INFO        QCLNSYSPRT  QPGMR         903501    Cleanup of job logs and other system output st
       CPI1E91       00             INFO        QCLNUSRPGM  QPGMR         903504    User cleanup program started.    
      When computing, whatever happens, behave as though you meant it to happen

      Comment


      • #4
        Re: Collecting QSYSOPR messages in a PF

        it's easy enough to just copy this into a externally defined PF to parse the data...or you could just use a DS to extract the relevant data and write out to a externally defined PF that matches your needs.
        I'm not anti-social, I just don't like people -Tommy Holden

        Comment


        • #5
          Re: Collecting QSYSOPR messages in a PF

          What would be the field length and type if i have to define a PF? where can i find the information about that ?
          When computing, whatever happens, behave as though you meant it to happen

          Comment


          • #6
            Re: Collecting QSYSOPR messages in a PF

            in this case all character to start with. if you need any of the data to be a numeric, date, etc then you'd have a 2 step process to convert the char to that data type.
            I'm not anti-social, I just don't like people -Tommy Holden

            Comment


            • #7
              Re: Collecting QSYSOPR messages in a PF

              Originally posted by tomholden View Post
              in this case all character to start with. if you need any of the data to be a numeric, date, etc then you'd have a 2 step process to convert the char to that data type.
              Tom ,

              You are the man !!!

              I almost got what i need . need some more perfection.

              You owe one beer from me.

              roch
              When computing, whatever happens, behave as though you meant it to happen

              Comment


              • #8
                Re: Collecting QSYSOPR messages in a PF

                try this: (semi-unit tested lol)

                messages table:
                Code:
                DROP TABLE THLIB/MESSAGES;
                
                CREATE TABLE THLIB/MESSAGES (
                  MSG_ID CHAR(7) CCSID 37 NOT NULL DEFAULT '',
                  SEVERITY CHAR(2) CCSID 37 NOT NULL DEFAULT '',
                  MSG_TYPE CHAR(10) CCSID 37 NOT NULL DEFAULT '',
                  MSG_TEXT CHAR(100) CCSID 37 NOT NULL DEFAULT '',
                  JOB_NAME CHAR(10) CCSID 37 NOT NULL DEFAULT '',
                  JOB_USER CHAR(10) CCSID 37 NOT NULL DEFAULT '',
                  JOB_NUMBER NUMERIC(6,0) NOT NULL DEFAULT 0,
                  PROGRAM CHAR(10) NOT NULL DEFAULT '',
                  MSG_TSTAMP TIMESTAMP NOT NULL DEFAULT '0001-01-01-00.00.00.000000',
                  CUR_USER CHAR(10) CCSID 37 NOT NULL DEFAULT ''
                ) RCDFMT MSGREC;
                CL driver GETMSGSCL:
                Code:
                pgm
                
                   dspmsg *sysopr output(*print)
                   dltf qtemp/temp
                   monmsg cpf0000
                   crtpf qtemp/temp rcdlen(198)
                   monmsg cpf0000
                   cpysplf qpdspmsg qtemp/temp splnbr(*last)
                   monmsg cpf0000
                
                   call getmsgrpg
                
                endpgm:
                   return
                   endpgm
                RPGLE GETMSGRPG:
                Code:
                     hoption(*nodebugio:*srcstmt) dftactgrp(*no) actgrp('GETMSG')
                     ftemp      if   e             disk    rename(temp:inrec) prefix(in_)
                     fmessages  o  a e             disk    extfile('THLIB/MESSAGES')
                
                     din_ds            ds                  qualified
                     d msgid                          7a
                     d severity                       2a   overlay(in_ds:10)
                     d msgtype                       10a   overlay(in_ds:14)
                     d text                         100a   overlay(in_ds:27)
                     d job                           10a   overlay(in_ds:23)
                     d user                          10a   overlay(in_ds:34)
                     d jobnumber                      6a   overlay(in_ds:45)
                     d program                       10a   overlay(in_ds:52)
                     d date                           8a   overlay(in_ds:70)
                     d time                          15a   overlay(in_ds:79)
                     d curuser                       10a   overlay(in_ds:95)
                
                     d workdate        s               d
                     d work_tstamp     s               z
                     d inz_tstamp      s               z
                     d work_field      s             26a
                     d got_msgid       s               n
                
                      /free
                
                         dou %eof( temp );
                           read temp;
                           if %eof;
                             *inlr=*on;
                             return;
                           endif;
                
                           if %subst(in_temp:120:4)='Page';
                             read temp;
                             read temp;
                           endif;
                
                           in_ds = in_temp;
                           if msg_id = ' '
                            or not got_msgid;
                             got_msgid = *On;
                             msg_id = in_ds.msgid;
                             severity = in_ds.severity;
                             msg_type = in_ds.msgtype;
                             msg_text = in_ds.text;
                             iter;
                           endif;
                
                           if got_msgid
                            and job_name = ' ';
                             job_name = in_ds.job;
                             job_user = in_ds.user;
                             job_number = %dec(in_ds.jobnumber:6:0);
                             program = in_ds.program;
                             monitor;
                               %subst(in_ds.time:3:1) = '.';
                               %subst(in_ds.time:6:1) = '.';
                               workdate = %date( in_ds.date : *MDY );
                               work_field = %char(workdate:*iso) + '-' + in_ds.time;
                               work_tstamp = %timestamp( work_field );
                               msg_tstamp = work_tstamp;
                             on-error;
                               msg_tstamp = inz_tstamp;
                             endmon;
                             cur_user = in_ds.curuser;
                             write msgrec;
                             clear msgrec;
                             got_msgid = *Off;
                           endif;
                         enddo;
                I'm not anti-social, I just don't like people -Tommy Holden

                Comment


                • #9
                  Re: Collecting QSYSOPR messages in a PF

                  oh yeah btw...using the APIs would be much better imo that the DSPMSG to spooled file, etc.
                  I'm not anti-social, I just don't like people -Tommy Holden

                  Comment

                  Working...
                  X