I recently downloaded OPRMONE which allows me ot monitor QSYSOPR and send messages to my phone when I have an error.
It works fine as designed. I would like to modify it to include the JobName/User/Number. I have not worked much with APIs. I am assuming the QMHLSTM API will get this information, but I could use some guidance on how to make the modifications.
Here is the code:
F**************************************************************** F* OBJECT ID: Oprmone F* TEXT: MONITOR qsysopr msgs e-mail a person F* Jul 14/04 S.R.Pascas F**************************************************************** foprmonemsgIT F 71 disk D message S 198 d desc s 50 d test s 20 d editword5 C ' : : ' D aryM s 7 DIM(500) fromfile(oprmonemsg D arysent s 20 DIM(5000) D SpacePtr s * inz(*null) d* D GeneralDs DS based(spaceptr) D InputSize 113 116B 0 D OFFSETHDR 117 120b 0 D ListOffset 125 128B 0 D ListNbr 133 136B 0 D EntrySize 137 140B 0 D userspace S 20 D SIZEinfo S 10i 0 inz(%SiZE(MSGINFO)) d formatsize s 10i 0 INZ(%size(qlstm0100)) d offset s 10i 0 D OBJTYPE S 10 D SpaceLen s 10i 0 inz(2048) D SpaceAtrib S 10 D SpaceValue S 1 INZ(X'00') D SpaceAuth S 10 INZ('*ALL') D SpaceText S 50 D SpaceReplc S 10 INZ('*YES') D FormatName S 8 inz('LSTM0100') D msgformat S 8 INZ('MSLT0200') D POS s 4 0 D sent s 5 0 inz(0) D scandata s 64 D SIZE s 4 0 d* Error code data D ErrorDS DS D BytesProv 1 4B 0 Inz( 272 ) D errorAval 5 8B 0 D ExcpId 9 15A D Reserved 16 16A D ExcpData 17 272A D SDS D S1SWID 244 253 D S1USER 254 263 d DmSGINFO DS D MAXMSG 10i 0 inz(-1) D listdir 10 inz('*NEXT') D selcriteria 10 inz('*MNR') D sevcriteria 10i 0 inz(0) D maxlength 10i 0 inz(112) D maxHELP 10i 0 inz(4) D*OFFSETQ 10i 0 inz(56) D OFFSETQ 10i 0 inz(80) D*OFFSETKEY 10i 0 inz(76) D OFFSETKEY 10i 0 inz(100) D NUMBERQUEUES 10i 0 INZ(1) D*OFFSETIDENTS 10i 0 inz(80) D OFFSETIDENTS 10i 0 inz(104) D FIELDSRETURN 10i 0 inz(1) d charcode 10I 0 inz(65535) d datetime 13 d reserve 3 d reserve2 10I 0 inz(0) D QSYSOPr 20 inz('QSYSOPR QSYS ') D msgkey 4 inz(X'00000000') D identifiers 10i 0 inz(302) d*
DQLSTM0100 DS D* Qmh Lstm LSTM0100 D NEXTENTRY 1 4B 0 D* Offset Next Entry D NEXTSIZE 5 8B 0 D* Offset Field Return D QMHNBRFR04 9 12B 0 D* Number Field Return D MSGSEV 13 16B 0 D* Message Severity D MSGID# 17 23 D* Message Id D QMHMT00 24 25 D* Message Type D QMHMK00 26 29 D* Message Key D QMHMFILN00 30 39 D* Message File Name D QMHMFSL00 40 49 D* Message File Send L D QMHMQN01 50 59 D* Message Queue Name D QMHMQLIB 60 69 D* Message Queue Libra D MSGDATE 70 76 D* Send Date D MSGTIME 77 82 D* Send Time D T 109 109 D RSRV 111 124 D ld 125 128b 0 Dmessagedata DS D msg 1 256 D msg128 1 128 d D CREATESPACE pr Extpgm('QUSCRTUS') d userspace 20 d spaceatrib 10 d spacelen 10i 0 d spacevalue 1 d spaceauth 10 d spacetext 50 d spacereplc 10 d errors like(errords) d getmessages pr Extpgm('QMHLSTM') d userspace 20 d formatname 8 d msginf like(msginfo) d sizeinfo 10i 0 d msgformat 8 d errors like(errords) D RTVGENINFO pr Extpgm('QUSPTRUS') d userspace 20 d spaceptr * D RTVSPACE1 pr Extpgm('QUSRTVUS') d userspace 20 d listoffset 9b 0 d formatsize 10i 0 d LSTM0100 LIKE(QLSTM0100) d D RTVSPACE2 pr Extpgm('QUSRTVUS') d userspace 20 d formatname 10i 0 d LD 9b 0 d messagedta LIKE(MESSAGEDATA) D delay pr d freqseconds 4 0 D sendemail pr d message 198 d desc 50 c *entry plist C parm FREQUENCY 15 5 C parm CYYMMDDHHMMSS 13 C parm sysname 8 C do C if %parms <> 3 C seton l C leave C endif c* C 60 mult frequency freqseconds 4 0 C EVAL UserSpace = ('OPRMONE QTEMP') C EVAL datetime = cyymmddhhmmss * Create user space C callp CREATESPACE(userspace:spaceatrib: C spacelen:spacevalue:spaceauth: C spacetext:spacereplc:errords) c* Retrieve Pointer (general info about user space) C EVAL UserSpace = ('OPRMONE QTEMP') C CALLp RTVGENINFO(userspace:spaceptr) C exsr RTVmessages c enddo C********************************************************* C* retrieve messages * C********************************************************* C RTVmESSAGES BEGSR C *inlr doweq *off c* get messages into userspace C EVAL UserSpace = ('OPRMONE QTEMP') C callp getmessages(userspace:FORMATNAME: c MSGINFO:SIZEINFO:MSGFORMAT:ERRORDS) C if erroraval = 0 C EVAL LISTOFFSET = LISTOFFSET + 1 C do listnbr C callp RTVSPACE1(USERSPACE:listOFFSET:forma c :qlstm0100) C eval offset = listoffset + 128 C eval msg128 = *blanks C callp RTVSPACE2(USERSPACE:OFFSET:LD:MESSAG C do c* see if message is to be bypassed C eval pos = %lookup(msgid#:arym) C if POS >= 1 C iter C endif c* see if message has already been sent C eval test = msgid# + msgdate + msgtime C eval pos = %lookup(test:arysent) C if POS <> 0 C iter C endif C exsr preparemsg C enddo C EVAL LISTOFFSET = NEXTENTRY +1 c enddo C callp DELAY(FREQSECONDS) c endif c enddo c endsr C********************************************************* C* prepare message * C********************************************************* C preparemsg BEGSR C if sent < 5000 C add 1 sent C eval arysent(sent) = msgid# + msgdate + m c endif C time timex 12 0 C time time6 6 0 C eval %SUBST(message:1:16) ='System: ' + s C eval %SUBST(message:20:16) ='Error: ' C eval %SUBST(message:40:25) ='Date/time: ' C %subst(msgdate:2:6) + ' ' + msgtime C eval %SUBST(message:70:128) =MSG128 C eval desc ='OprmonE Warning: ' + sysname c %EDITW(TIME6 : EDITWORD5) C callp SENDEMAIL(MESSAGE:DESC) C endsr * * * * E N D O F S O U R C E * * * *
Software/Hardware used:
AS400 V5R4
ASKED:
April 27, 2010 4:03 PM
UPDATED:
April 29, 2010 12:55 AM
Any chance you could post that in a {code} block? It’d sure make review easier.
Tom
Just to ensure that I understand, it looks like you are currently requesting a single key (FIELDSRETURN inz(1)) for 0302=”Message with replacement data” (identifiers inz(302)). You would like to make FIELDSRETURN=2 in order to add an identifier for field 0601=”Qualified sender job name”.
Am I on track?
Tom
I am assuming the QMHLSTM API will get this information,…
I should have also said that the API will get that info (assuming that I understand correctly).
You appear on the right track and possibly can make minimal changes. (Some changes could be recommended, but they might be better left until after you see how to request what you want, what all gets returned and how it’s all structured both for input to the API and output from it.)
You probably saw that “Qualified sender job name” was listed in the API docs, which prompted your question. If that’s what you’re after, the difference between what you already have and what you need is small. But it can be kind of like coding a trigger program with hard-coded buffer offsets. It can work perfectly for a long time… then you make a small change, and !@#$%^… Best to grasp fully “what you need” first. Then we’ll make a little larger change to get to “what you should have”.
Tom
Thanks Tom
I got pulled away for some other project.
I’ll update this after I get I changve to test it out.
I assume that you know that the above line allows for something like adding a second element to the “identifiers array” without needing to update the SIZEinfo value. But it’s probably worth mentioning it for the sake of the thread. Others may follow in the track you started.
Tom