SCOME - Part 3: The Failed Jobs Report

  • Comments posted to this topic are about the item SCOME - Part 3: The Failed Jobs Report

  • Hi all,

    There appears to be a dead image in the article, so I've posted the image here. This is what our Failed Jobs report will eventually look like. It has three buttons that will retrieve the relevant logs on the server. Remember, all the work in the previous articles is not just for the one report. It's just part of the initial setup. After this, you'll be able to create a report from anything SQL Server holds in it's system tables for all your servers, with minimal effort.

  • We've been using a different variant on this, first there's a job that runs every hour that mails us the results of the following view:

    SELECT CONVERT(DATETIME, RTRIM(H.run_date)) + ((H.run_time * 9 + H.run_time % 10000 * 6) + H.run_time % 100 * 10) / 216e4 AS run_date, J.name,

    H.message, H.run_duration, H.server

    FROM LINKED_SERVER_NAME.msdb.dbo.sysjobhistory AS H INNER JOIN

    [SRV-NAV01].msdb.dbo.sysjobs AS J ON H.job_id = J.job_id

    WHERE (H.step_id = 0) AND (H.run_status = 0)

    This also works like a charm and is easy to set up. You can either pro-actively monitor the view, or have a job schedule mail these results to you (like we did). You can simply UNION select any production server (linked) that you'd like or take it one step further and use CLR to enumerate through all available servers.

  • Shameless plug : please see the project on http://www.codeplex.com/sqlconsolidate - it does the same on a console application * and can export data to csv/xml/ email / database

  • COOL STUFF SO FAR. WHEN WILL YOU GET INTO THE .NET STUFF

  • LostFromTheStart (4/24/2009)


    COOL STUFF SO FAR. WHEN WILL YOU GET INTO THE .NET STUFF

    Was going to do it in article 5, but people are getting restless, so going to try and do it next.

  • Excellent series! I especially like that I can build on this type of infrastructure and extend it further (and don't have to pay for expensive 3rd party tools :-)).

  • Great stuff so far. When will part 4 be posted?

  • Hi Gary,

    I'll try and finish the next three articles this weekend and publish them on my site thebuddingdba.com, Monday. I'll send them off to SQLServerCentral.com but I think there is a three or four week wait.

    Kind regards

    Drew

  • Thanks Drew, we're looking forward to the new articles.

    Quick question: We have set up links to several servers that just have the default instance installed and it works great...however, how can we set up servers with named instances? For example, we have a SQL Server farm with 9 named instances. How can we link to each of the named instances for monitoring?

    Thanks.

    Gary and Ann

  • I also had to exclude 5 (unknown) from last_run_outcome in usp_getFailedJob. Had a bunch of 0's in the last_run_date in this case and broke the convert.

  • dwithroder (5/5/2009)


    I also had to exclude 5 (unknown) from last_run_outcome in usp_getFailedJob. Had a bunch of 0's in the last_run_date in this case and broke the convert.

    Hi

    Are you refering to last_run_date/last_run_time or last_run_outcome? last_run_outcome should not be effected by last_run_outcome.

    If you're refering to the latter, you can customise last_run_outcome. I chose it to fail whenever it was unsuccessful. "last_run_outcome 1" but you don't have to. There's a number for each status in books online such as Running, Disabled etc

    If you are refering to the date, all my jobs have run dates, as they've all been run at sometime, so I rarely have this problem, but if you have a job has never had a run date, then you can give it one manually in the system table or by setting it to report successful when it fails (in the advanced tab of the job). Then run the job once. It will then fail, but report as being successful and give it a proper last_run_outcome date. Then change it back to report failure on failure. From then on, your convert wont break.

  • gary.dunn (4/30/2009)


    Thanks Drew, we're looking forward to the new articles.

    Quick question: We have set up links to several servers that just have the default instance installed and it works great...however, how can we set up servers with named instances? For example, we have a SQL Server farm with 9 named instances. How can we link to each of the named instances for monitoring?

    Thanks.

    Gary and Ann

    Hi Garry,

    Did you get this working in the end? I've never tried it with named instance, but I can give it a shot tomorrow if you haven't.

    Drew

  • I haven't gotten into all the existing jobs yet, but have a bunch with

    last_run_outcome = 5

    last_outcome_message = NULL

    last_run_date = 0

    and was tinkering with code (and commenting on the fact) just to get things to run and follow along with your articles. Have enjoyed the read.

  • Fair enough. Here are the last_run_outcomes:

    http://msdn.microsoft.com/en-us/library/ms187387.aspx

    I hope to finish article 4 tonight. Thanks for joining in and the feedback.

    Drew

Viewing 15 posts - 1 through 15 (of 30 total)

You must be logged in to reply to this topic. Login to reply