If you are wanting to monitor for system errors such as disk capacity or hardware errors use something like MessengerPlus.

If you are wanting to monitor application program errors why not have the programmers incorporate error handling into their programs?

For CL do something like this...

At top of program put in this line to handle errors globally.

MonMsg MsgID(CPF0000 MCH0000) Exec(Goto HandleErr)

/* your program does stuff here */

HandleErr:

/*---------------------------------------*/
/* Receive and resend Diagnostic message */
/*---------------------------------------*/

RcvMsg MsgType(*DIAG) MsgDta(&msgData) MsgDtaLen(&msgDtaLen) +
MsgID(&msgID) MsgF(&msgFile) msgFLib(&msgLib)

MonMsg MsgID(CPF0000 MCH0000) exec(GoTo PgmEnd)

If (&msgID *NE ' ') Then(Do)

DMPCLPGM
DSPJOBLOG JOB(*) OUTPUT(*PRINT)

SndPgmMsg MsgID(&msgId) MsgF(&msgLib/&msgFile) +
MsgDta(&msgData) ToPgmQ(*PRV) MsgType(*DIAG)
MonMsg MsgID(CPF0000 MCH0000) /* you don't want to loop */
/* Or call a program that sends an email an also sends an inquiry message to QSYSOPR */
/* call YourPgmName PARM(&rtncode &sndmsg &sndmsgfile &sndmsglib &sndmsgdta) */
/* MonMsg MsgID(CPF0000 MCH0000) Exec(Do) */
/* do what you will */
/* enddo */
GoTo PgmEnd

EndDo

/*-----------------------------------*/
/* Receive and resend Escape message */
/*-----------------------------------*/

RcvMsg MsgType(*EXCP) MsgDta(&msgData) MsgDtaLen(&msgDtaLen) +
MsgID(&msgID) MsgF(&msgFile) msgFLib(&msgLib)

MonMsg MsgID(CPF0000 MCH0000) exec(GoTo PgmEnd)

If (&msgID *NE ' ') Then(Do)
SndPgmMsg MsgID(&msgId) MsgF(&msgLib/&msgFile) +
MsgDta(&msgData) ToPgmQ(*PRV) MsgType(*ESCAPE)
MonMsg MsgID(CPF0000 MCH0000)
/* Or call a program that sends an email an also sends an inquiry message to QSYSOPR */
/* call YourPgm PARM(&rtncode &sndmsg &sndmsgfile &sndmsglib &sndmsgdta) */
/* MonMsg MsgID(CPF0000 MCH0000) Exec(Do) */
/* do what you will */
/* enddo */
GoTo PgmEnd

EndDo

GoTo PgmEnd

You can use whatever you currently use to send the email.

YourPgm could look like this...

/*-----------------------------*/
/* Globally monitor for errors */
/*-----------------------------*/

MonMsg MsgID(CPF0000 MCH0000) Exec(Goto HandleErr)

/*--------------------------*/
/* Send the inquiry message */
/*--------------------------*/

SNDMSG:

SndPgmmsg MsgID(&sndmsg) MsgF(&sndmsglib/&sndmsgfile) +
MsgDta(&sndmsgdta) ToMsgQ(QSYSOPR) +
MsgType(*INQ) KeyVar(&rtnmsgkey)

/*------------------------------*/
/* Receive the inquiry response */
/*------------------------------*/

RcvMsg MsgType(*RPY) MsgKey(&rtnmsgkey) Wait(*MAX) Msg(&msgreply)

ChgVar Var(&rtncode) value(&msgreply)

/*----------------*/
/* End processing */
/*----------------*/

GoTo PgmEnd

HandleErr:

/*---------------------------------------*/
/* Receive and resend Diagnostic message */
/*---------------------------------------*/

RcvMsg MsgType(*DIAG) MsgDta(&msgData) MsgDtaLen(&msgDtaLen) +
MsgID(&msgID) MsgF(&msgFile) msgFLib(&msgLib)

MonMsg MsgID(CPF0000 MCH0000) exec(GoTo PgmEnd)

If (&msgID *NE ' ') Then(Do)

SndPgmMsg MsgID(&msgId) MsgF(&msgLib/&msgFile) +
MsgDta(&msgData) ToPgmQ(*PRV) MsgType(*ESCAPE)

MonMsg MsgID(CPF0000 MCH0000)

If (&msgID *NE ' ') Then(Do)

SndPgmMsg MsgID(&msgId) MsgF(&msgLib/&msgFile) +
MsgDta(&msgData) ToPgmQ(*PRV) MsgType(*ESCAPE)

MonMsg MsgID(CPF0000 MCH0000)

GoTo PgmEnd

EndDo

/*-----------------------------------*/
/* Receive and resend Escape message */
/*-----------------------------------*/


RcvMsg MsgType(*EXCP) MsgDta(&msgData) MsgDtaLen(&msgDtaLen) +
MsgID(&msgID) MsgF(&msgFile) msgFLib(&msgLib)

MonMsg MsgID(CPF0000 MCH0000) exec(GoTo PgmEnd)

If (&msgID *NE ' ') Then(Do)
SndPgmMsg MsgID(&msgId) MsgF(&msgLib/&msgFile) +
MsgDta(&msgData) ToPgmQ(*PRV) MsgType(*ESCAPE)

MonMsg MsgID(CPF0000 MCH0000)

GoTo PgmEnd

EndDo

PgmEnd:

/*-----------------*/
/* End the program */
/*-----------------*/

Return

ENDPGM

HTH

Gary Monnier


-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of James Rich
Sent: Wednesday, September 02, 2015 1:17 PM
To: Midrange Systems Technical Discussion
Subject: Re: Send email on program halt

On Wed, 2 Sep 2015, Buck Calabro wrote:

On 9/2/2015 3:36 PM, Charles Wilt wrote:
Can't be done.

Either the job stops, or the job doesn't stop (and sends an email).

You'd need an external process that monitors for the MSGW and sends
an email.

A possible alternative is to MONMSG (ie trap the error), in the DO()
send the email and then re-throw the exception.

I thought about this but couldn't come up with a satisfactory way to do it. Many programs are called during the execution of the daily close and I'd want execution to stop at the original point of execution of the error.

James Rich

if you want to understand why that is, there are many good books on the design of operating systems. please pass them along to redmond when you're done reading them :)
- Paul Davis on ardour-dev
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx<mailto:MIDRANGE-L@xxxxxxxxxxxx> To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx<mailto:MIDRANGE-L-request@xxxxxxxxxxxx> Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.



This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].