I'm trying to write a little script that will alert me when I have Jobs which are trying to run but who's agent is down.
I know that the status of these Jobs is "Waiting for Host". The status Code for this is 1696.
I'm use a SQL variable that will query the AH table looking for Job with Status = '1696'
For this first thing you are trying to do, as the "Waiting for Host" status, is not an ended status it will still be within the EH tables.
I am also trying to trap "Start Impossible" Job execution errors.
Both these category of Job execution failures are in the same bracket i.e. the Job is trying to run but cant.
The problem with "Start Impossible"(1820) is that these Jobs fail and so don't stay in the Activities window...
As for this one "FAULT_OTHER - Start impossible. Other error." (which is 1820), as its an could not start so the job ended... and since you have it auto-deactivate/not be in the activities window (then it would only be within the AH only - If its has not been deactivated then, it could be found in both the AH/EH for "FAULT_OTHER - Start impossible. Other error.") .
Since you know both of that status you are looking for (1820, 1696) and "Waiting for Host" will always be in the Activities window pending that host (unless you have some other condition that end it). For the 1820, as it is an ended status it can always be found within the AH tables.
I recommend writting two sql, one against the EH for the 1696 and one against the AH for the 1820 (since for the 1820, it will always in the AH, while it will be in the EH -if it has not be deactivated yet).