Hi friends,
I want to write a tool in rexx which will calculate the space occupied by all the jobs present in the spool (S.H).
Can any one help me to get the space occupied by a job.
Will the size of the jobs be stored in any system datasets?
In the avove We can see the the SYSDUMP has occupied alot of space.
So, my basic intention is to get the jobs which occupied more space. so that we can purge those jobs.
How can we extract all these details in a rexx program. Are they stored in any datasets?
Thanks,
Balu
Hi
I am finally succesfull in achieving the requirement.
But when I execute the Rexx command in batch it is throwing the error during the call of 'ISFAFD'
Thanks
I got a Rexx code from this link which creates the jcl
Its working fine.
What I can observe is the time taken when I run through batch is more compared to the direct run as tso rexxcmd.
Is this observation correct or it has nothing to with time?
Hi Ram,
What exactly you are looking for?
The JCL to execute the Rexx code with ISPEXEC in Batch or
The Rexx code to get the Jobs in spool and their sizes in a dataset
Hi,
This is the Rexx code for my requirement which I have mentioned in my first post. This code is slightly big. There might be any other simplar way to get it, but I am quite new to Rexx, so I coded this program with what ever I have learnt by going through this forum and other docs in net.
Code:
/* rexx */
/***************************************************************************/
/**The Rexx Code Will Scan through all the jobs in S.H
JOBNAME = CG* of all owners
and get the details of Byte-Cnt of each step of the job.
If any of the setp of a job has a Byte-Cnt more than '500000'
A message will be send to the user asking to purge the jobs
Message will be send to only those users who are present in the userfil**/
/***************************************************************************/
wrkfil1 = Userid()'.TSO.TEST1'
userfil = 'USR1.TSO.SOURCE(USERIDS)'
/*Contains the user ids to whom the message to be sent */
"ALLOC F(ISFIN) TRACKS SPACE(1) REU" /* Used by SDSF */
"ALLOC DA('"wrkfil1"') F(ISFOUT) NEW DELETE REU " ,
"TRACKS SPACE(100,100) LRECL(133) RECFM(F,B,A) DSORG(PS)" /* work files */
"ALLOC F(TEMPPRT) NEW DELETE REU " ,
"TRACKS SPACE(100,100) LRECL(133) RECFM(F,B,A) DSORG(PS)"
/* read the userfile in to an array */
"ALLOC DA('"userfil"') F(INFILE) SHR REUSE"
"EXECIO * DISKR INFILE (STEM USERIDS. FINIS"
"FREE DDN(infile)"
do usr = 1 to userids.0
userids.usr = SUBSTR(USERIDS.usr,1,4)
end
/* First get the First job in S.H */
QUEUE "PRE CG*"
QUEUE "H"
/* QUEUE "++?" */
QUEUE "END"
"EXECIO" QUEUED()" DISKW ISFIN (FINIS"
ADDRESS ISPEXEC "SELECT PGM(ISFAFD) PARM('++32,255')"
ADDRESS TSO
"ALLOC DA('"wrkfil1"') F(INFILE) SHR REUSE"
"EXECIO * DISKR INFILE (STEM INAR2. FINIS"
"FREE DDN(infile)"
/* to get the no of jobs in the spool Ex: LINE 1-7 (7) */
st_pos = pos('(',INAR2.65,1)
en_pos = pos(')',INAR2.65,1)
job_count = substr(INAR2.65,st_pos+1,en_pos-st_pos-1)
say 'Total No of jobs in spool :' job_count
/* use '?' to get in to each job and extract the byte-Cnt of each line */
tjbs = 0
do cnt = 0 to job_count-1
QUEUE "PRE CG*"
QUEUE "H"
QUEUE "down" cnt
QUEUE "++?"
"EXECIO" QUEUED()" DISKW ISFIN (FINIS"
ADDRESS ISPEXEC "SELECT PGM(ISFAFD) PARM('++32,255')"
stline = inar2.129
st_pos = pos('(',stline,55)
en_pos = pos(')',stline,55) /* To get no of lines in each job*/
job_lct.tjbs = substr(stline,st_pos+1,en_pos-st_pos-1)
Job_name.tjbs= substr(stline,35,8)
Job_id.tjbs = substr(stline,45,8)
job_flag.tjbs = 'N'
job_msize.tjbs = ' '
do cnt1 = 1 to Job_lct.tjbs
tcnt = cnt1 + 131
tot_bytes = substr(inar2.tcnt,87,8) /* Get the byte count */
k = pos('M',tot_bytes)
if k > 0 then
do /* Convert the Mega byte count in to Byte count */
tot_bytes = substr(tot_bytes,1,k-1) * 1000000
job_flag.tjbs = 'y'
end
s1 = space(TRANSLATE(tot_bytes,' ',','),0)
s1 = TRANSLATE(s1,'0',' ')
s2 = TRANSLATE(job_msize.tjbs,'0',' ')
if s1 > s2 then /* Get the max byte count of all steps */
do
job_msize.tjbs = s1
end
end
end
/* Extract only those jobs with byte count more than 500000 */
cnt1 = 0
do cnt = 1 to tjbs
if job_msize.cnt < 500000 then
iterate
cnt1 = cnt1 + 1
DLINES.cnt1 = left(Job_name.cnt,10) || left(Job_id.cnt,10) ,
|| left(job_lct.cnt,10) || left(job_flag.cnt,3) ,
|| right(job_msize.cnt,10)
end
say 'Total no of jobs with more than 500000 byte count' cnt1
CALL SORT_DLINES
"EXECIO * DISKW OUTFIL (STEM DLINES. FINIS"
CALL CREATE_MSG
"EXECIO * DISKW OUTFIL2 (STEM MSGL. FINIS"
DROP DLINES
DROP MSGL
/*ADDRESS TSO "SE '"M2"',USER("USER.1"),LOGON" */
EXIT
/* Sort the jobs based on First 4 bytes of the job name */
SORT_DLINES:
"ALLOC FI(SYSOUT) SYSOUT(X)"
"ALLOC FI(SYSIN) NEW TRACKS SPACE(3 3) RECFM(F B) LRECL(80)"
"ALLOC FI(SORTIN) NEW TRACKS SPACE(133 133) RECFM(F B) LRECL(133)"
"ALLOC FI(SORTOUT) NEW TRACKS SPACE(133 133) RECFM(F B) LRECL(133)"
QUEUE " SORT FIELDS=(1,8,CH,A)"
QUEUE " END"
"EXECIO "QUEUED() "DISKW SYSIN ( FINIS"
"EXECIO * DISKW SORTIN ( STEM DLINES. FINIS"
DROP DLINES
"CALL *(SORT)"
"EXECIO * DISKR SORTOUT ( STEM DLINES. FINIS"
"FREE FI(SYSIN,SYSOUT,SORTIN,SORTOUT)"
SORT_DLINES_EXIT: RETURN
/* Send tso message to those users which are present in the Userfile */
CREATE_MSG:
LINE1 = 'USR1 ************************************
**********'
LINE2 = 'USR1 ********PLEASE PURGE THE FOLLOWING J
OBS*******'
LINE3 = 'USR1 '
MCNT = 0
MCNT = 0
CUR_USER = space
DO CNT = 1 TO CNT1
temp_user = SUBSTR(DLINES.CNT,1,4) /* first 4 bytes of job name = username*/
IF CUR_USER ¬= temp_user THEN
DO
if CHECK_USER() then
do
iterate
end
if CUR_USER ¬= space then
do
MCNT = MCNT + 1
MSGL.MCNT = "SE '"LINE1"',USER("CUR_USER"),LOGON"
end
CUR_USER = temp_user
MCNT = MCNT + 1
MSGL.MCNT = "SE '"LINE1"',USER("CUR_USER"),LOGON"
MCNT = MCNT + 1
MSGL.MCNT = "SE '"LINE2"',USER("CUR_USER"),LOGON"
END
LINE4 = LINE3||LEFT(substr(DLINES.cnt,1,20),38)
MCNT = MCNT + 1
MSGL.MCNT = "SE '"LINE4"',USER("CUR_USER"),LOGON"
IF CNT = CNT1 THEN
DO
MCNT = MCNT + 1
MSGL.MCNT = "SE '"LINE1"',USER("CUR_USER"),LOGON"
END
END
CREATE_MSG_EXIT: RETURN
CHECK_USER:
do usr = 1 to USERIDS.0
if temp_user = userids.usr then
DO
return 0
END
end
CHECK_USER_EXIT: RETURN 1
The code looks slightly big, but that is all i have come up with, if any of you have a better solution, please let me know.
The Code is taking around 4 to 5 mins to scan through 1000 jobs
So, I am executing in batch using the jcl generated by the rexx code in the link which I have given it in my previous post.
The jcl is also slightly big, so I have not posted. Let me know if any one needs the jcl also.