IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Suggestions to improve code


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Huzefa

New User


Joined: 05 Dec 2006
Posts: 83
Location: Bangalore

PostPosted: Tue Nov 24, 2009 3:00 pm
Reply with quote

I developed a REXX code to notify team when there are more than 200 jobs running in Queue or when a job takes CPU time more than 20.
Any suggestions to improve this code will be of use.
Code:

Do Forever
 RC=ISFCALLS("ON")
 ISFPREFIX='USERID*'
 ADDRESS SDSF "ISFEXEC ST"
  IF ISFROWS > 200 THEN  CALL NOTIFY_TEAM
ISFCOLS="JNAME JOBID CPU "
ADDRESS SDSF "ISFEXEC DA"
COLDTL=WORD(ISFCOLS,1)
DO IX=1 TO ISFROWS
 DO JX=1 TO WORDS(ISFCOLS)
   COL=WORD(ISFCOLS,JX)
 END
 IF CPU.IX > 20 THEN CALL NOTIFY_TEAM
 END
RC=ISFCALLS("OFF")
End

NOTIFY_TEAM:
this procedure will prepare a job to send email to team.
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Tue Nov 24, 2009 5:47 pm
Reply with quote

Try to add the NOMODIFY option.

O.
Back to top
View user's profile Send private message
Huzefa

New User


Joined: 05 Dec 2006
Posts: 83
Location: Bangalore

PostPosted: Tue Nov 24, 2009 7:04 pm
Reply with quote

i really appreciate that.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2593
Location: Silicon Valley

PostPosted: Tue Nov 24, 2009 9:18 pm
Reply with quote

Have you tried to run it?

1. I think you need a SLEEP statement within your loop. Otherwise, it will run continuously with no waiting. That is, the loop will execute 1000s of times each second. If you ever get more than 200 jobs, it will generate many, many messages before the team can respond. Your program may turn into a denial of service attack on yourself because a flood of messages will prevent you from doing any work (do not try this at home).
<update>I think you should wait several minutes before each iteration.

2. You have some setup statements that can be done before FOREVER statement. Likewise, you have some cleanup that can be done after the last END.

3. It is not clear why you need this:
Code:
DO JX=1 TO WORDS(ISFCOLS)
   COL=WORD(ISFCOLS,JX)
 END
Back to top
View user's profile Send private message
Huzefa

New User


Joined: 05 Dec 2006
Posts: 83
Location: Bangalore

PostPosted: Wed Nov 25, 2009 12:23 pm
Reply with quote

Hi,

Thanks a lot for your response.

My bad, did not try testing with DO FOREVER LOOP.

1. Wil chk SLEEP statement.

2. ok.

3. Good Catch.I was trying to get individual columns from sdsf and forgot to remove it.
Back to top
View user's profile Send private message
Huzefa

New User


Joined: 05 Dec 2006
Posts: 83
Location: Bangalore

PostPosted: Wed Nov 25, 2009 1:07 pm
Reply with quote

How does this look?

RC=ISFCALLS("ON")
ISFPREFIX='USERID*'
ISFCOLS="JNAME JOBID CPU "
Do Forever
ADDRESS SDSF "ISFEXEC ST (NOMODIFY"
IF ISFROWS > 200 THEN CALL NOTIFY_TEAM
ADDRESS SDSF "ISFEXEC DA (NOMODIFY"
DO IX=1 TO ISFROWS
IF CPU.IX > 20 THEN CALL NOTIFY_TEAM
END

CALL SYSCALLS ON
ADDRESS SYSCALL
"SLEEP" 900
CALL SYSCALLS OFF

End
RC=ISFCALLS("OFF")
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Wed Nov 25, 2009 1:15 pm
Reply with quote

Would it not be better to submit the job every 10-15 minutes rather than hog an initiator all of the time, thus preventing anyone else using that initiator.
Back to top
View user's profile Send private message
Huzefa

New User


Joined: 05 Dec 2006
Posts: 83
Location: Bangalore

PostPosted: Wed Nov 25, 2009 6:05 pm
Reply with quote

Thanks for suggestion. If we get to put this job in production, will definitely put forward this idea.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2593
Location: Silicon Valley

PostPosted: Wed Nov 25, 2009 10:30 pm
Reply with quote

Code:
CALL SYSCALLS ON
ADDRESS SYSCALL
"SLEEP" 900
CALL SYSCALLS OFF


Again, do your setup and cleanup outside of the loop.
Back to top
View user's profile Send private message
Huzefa

New User


Joined: 05 Dec 2006
Posts: 83
Location: Bangalore

PostPosted: Thu Nov 26, 2009 10:36 am
Reply with quote

I have the sleep statement inside "Do forever" so the pgm dose not chk sdsf unnecessarily. I want the pgm to chk sdsf once in 15 mins.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Thu Nov 26, 2009 10:44 am
Reply with quote

Hello,

You need to implement as Expat has suggested. . .

What you have now is unacceptable on every well-managed system i've ever seen. What you have is another of the things that can be done, but should not be done. All this method does is waste resources pretty much forever. . .

Taking an initiator permanently out-of-service is not acceptable.
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2593
Location: Silicon Valley

PostPosted: Thu Nov 26, 2009 9:05 pm
Reply with quote

Your rexx program seems to be a poor man's system health checker. If this is part of your site's system management plan, you should be able to start the rexx program as a started task. Or if there is a shortage of initiators, then define another for this purpose.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts Data Backup suggestions DB2 5
No new posts VSAM return code 23 - for a Random read COBOL Programming 4
Search our Forums:

Back to Top