Setting return code on warning greate than 10

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

atulghate
Participant
Posts: 10
Joined: Sat Jul 09, 2005 8:28 am

Setting return code on warning greate than 10

Post by atulghate »

I am running my job via the dsjob -run command
and for status put a command like
RETURN_VALUE=$?

Now wahaterver is number provided in parametre the -warn 20.
Return code = 2.

What I am looking for here is:

If job has warning but wihin limits its okay for me i would like to set final return code to 0 (goo retunr).

But if warnings cross the limit provided I would like to send bad return code in script.

This is required so that my third party scheduling tool (TNG or Control M understand this correctly).

Any suggestion...
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Use the -jobstatus option with 'dsjob'. It returns the internal return codes as the status of the job. You can then declare it a 'good return' if the status is a 1 or a 2: 'Finished Ok' or 'Finished (see log)'. Anthing else would be a 'bad return' in your script.

You don't really need to add this extra level of 'translation' to the messages, Control-M is perfectly capable of understanding that 1 = Good and 2 = Good (or not) and 3 = Bad, (etc) for instance. We use the -jobstatus option and pass the resulting status directly back to Control-M, it takes it from there.
-craig

"You can never have too many knives" -- Logan Nine Fingers
atulghate
Participant
Posts: 10
Joined: Sat Jul 09, 2005 8:28 am

Post by atulghate »

Thanks chulett .

Problem I am facing is when job finishes with finhed (See log).
As far as number of warnings are within limit specified in job run script I want final return code to be set up good.

So in above case there are 15 warning generated and permissible limit for me is 10 then I want bad code to be forced out. However good return code should be sent when the warning are within limit for example say if I get 7 warnings.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

If the 'permissable limit' of warnings is only 10, then why are you allowing the job to generate 15? :?

My assumption was you set your warning limit when running the job to 10, thus when it attempted to exceed that threshold the job would abort - not continue on. Then you can check the return status directly.

If you are going to allow more warnings than your 'threshold' then you will have to use other 'dsjob' commands post run to query the job's log and determine the number of warning in the most recent run. Then you can compare that number to your limit and decide what to report back.

The dsjob command and its various options are fully documented in the Command Line Interface chapter of the Server Jobs Developer's Guide, from what I recall.
-craig

"You can never have too many knives" -- Logan Nine Fingers
atulghate
Participant
Posts: 10
Joined: Sat Jul 09, 2005 8:28 am

Post by atulghate »

Thank much chulet.
I am probably not writting communication clear.

The return code is always set to 2 by dsjob command even though the job is aborted (if it is dues to excceded limit of warnings).

I will definitly check the manually, thanks agin for pointing exact chapter on it...
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

atulghate wrote:The return code is always set to 2 by dsjob command even though the job is aborted (if it is dues to excceded limit of warnings).
No, it's not - not if you use the -jobstatus option with dsjob. It will be a 2 if the job finished with warnings and a 3 if the job aborted.
-craig

"You can never have too many knives" -- Logan Nine Fingers
atulghate
Participant
Posts: 10
Joined: Sat Jul 09, 2005 8:28 am

Post by atulghate »

$? from dsjob run list...
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Just intercept the job status and feed either 0 or a non-zero value to the exit command in your script.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
atulghate
Participant
Posts: 10
Joined: Sat Jul 09, 2005 8:28 am

Post by atulghate »

Right but return code is 2 when there are warning even if it is 10 or 15. and when I run job I have to run with -war 10.
This makes actual job abort.


I do I distinguise between these two.
thompsonp
Premium Member
Premium Member
Posts: 205
Joined: Tue Mar 01, 2005 8:41 am

Post by thompsonp »

I just tried the same thing.
Unsurprisingly it doesn't matter if you use the -jobstatus option or issue a separate -jobinfo command. The status is returned as 2 whether the job has more than the threshld number of warnings or not.

If you look in Director the job logs a FATAL message 'issuing abort' after the number of warnings is exceeded but a few lines later is an INFO message stating the 'Parallel job reports successful completion'.

I wondered if this was a timing issue - i.e. although the abort is issued the job finishes processing all the records before it can act on the abort. As my test job just uses a row generator I increased the number of rows so that it takes a while to complete. The result is that the job terminates with a SIGINT. It is a timing issue.

Accessing the status of this job returns status of 3 - RUN FAILED.

Looks like you'll have to rethink your approach. Are the warnings you are trying to detect as a result of 'errors' in the data? If so can't you capture them in the job via some validation and send down a link. You could then count the records on the link and adjust the status you return to Control-M if it exceeded your threshold.
thompsonp
Premium Member
Premium Member
Posts: 205
Joined: Tue Mar 01, 2005 8:41 am

Post by thompsonp »

You could also follow the suggestion for counting the number fo warnings after the job has finished as in this post

viewtopic.php?t=100745

If the threshold is exceeded, adjust the status you return to Control-M.
thompsonp
Premium Member
Premium Member
Posts: 205
Joined: Tue Mar 01, 2005 8:41 am

Post by thompsonp »

Or you could check if there is a FATAL message in the log and examine whether it is of the format 'Issuing abort after [n] warnings logged.' or not.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

thompsonp wrote:The status is returned as 2 whether the job has more than the threshld number of warnings or not.

If you look in Director the job logs a FATAL message 'issuing abort' after the number of warnings is exceeded but a few lines later is an INFO message stating the 'Parallel job reports successful completion'.
So, you are saying that a job with a warning limit of 10 that has 8 warnings during its run and that finishes with a status in the Director of 'Finished (see log)' returns a status code of 2, as expected. But that also a job with a warning limit of 10 that attempts to issue more than that and is thus aborted for its troubles, showing a final status of 'Aborted' in Director also returns a status code of 2? :?

If so, this must be something unique to PX jobs as I don't recall that being the case with Server jobs when we setup and tested our Control-M architecture. Now, that was under a different version, perhaps I need to go back and double-check... :lol:
-craig

"You can never have too many knives" -- Logan Nine Fingers
thompsonp
Premium Member
Premium Member
Posts: 205
Joined: Tue Mar 01, 2005 8:41 am

Post by thompsonp »

chulett wrote:
So, you are saying that a job with a warning limit of 10 that has 8 warnings during its run and that finishes with a status in the Director of 'Finished (see log)' returns a status code of 2, as expected. But that also a job with a warning limit of 10 that attempts to issue more than that and is thus aborted for its troubles, showing a final status of 'Aborted' in Director also returns a status code of 2?
No that is not what I said. It's the 'and is t hus aborted' that causes the problems.
Director shows that the warning limit has been reached and an abort is issued. If the job finishes before the abort is actioned - it's just a SIGINT - then the status will not be aborted.
If the SIGINT is received the status is correctly set as Aborted.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Interesting... thanks for the clarification. Still seems to be something unique to PX jobs, but I'll keep my eye out for that behaviour over in my Server world. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply