Setting return code on warning greate than 10
Moderators: chulett, rschirm, roy
Setting return code on warning greate than 10
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...
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...
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.
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
"You can never have too many knives" -- Logan Nine Fingers
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.
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.
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.
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
"You can never have too many knives" -- Logan Nine Fingers
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.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).
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
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.
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.
viewtopic.php?t=100745
If the threshold is exceeded, adjust the status you return to Control-M.
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?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'.
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...
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
chulett wrote:
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.
No that is not what I said. It's the 'and is t hus aborted' that causes the problems.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?
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.