Job History with Timeline

  • Comments posted to this topic are about the item Job History with Timeline

  • Thanks, I like it!

    I did make a couple of minor changes. Our server names are >10 characters and I like to see the run date and run time in descending order.

    SET DATEFORMAT dmy

    SELECT

    convert(varchar(20),his.server) as Server, -- Increased to 20 characters

    convert(varchar(30),job.name) AS job_name,

    CASE his.run_status

    WHEN 0 THEN 'Failed'

    WHEN 1 THEN 'Succeeded'

    ELSE '???'

    END as run_status,

    convert(varchar(4),run_duration/10000) + ':' + convert(varchar(4),run_duration/100%100) + ':' + convert(varchar(4),run_duration%100) as run_duration,

    convert(datetime, convert(varchar(10),run_date%100) + '/' + convert(varchar(10),run_date/100%100) + '/' + convert(varchar(10),run_date/10000) + ' ' + convert(varchar(4),run_time/10000) + ':' + convert(varchar(4),run_time/100%100) + ':' + convert(varchar(4),run_time%100)) as start_date,

    datediff(mi, getdate()-1, convert(datetime, convert(varchar(10),run_date%100) + '/' + convert(varchar(10),run_date/100%100) + '/' + convert(varchar(10),run_date/10000) + ' ' + convert(varchar(4),run_time/10000) + ':' + convert(varchar(4),run_time/100%100) + ':' + convert(varchar(4),run_time%100))) as LeadingMinutes,

    isnull(nullif(convert(int,(run_duration/10000 * 60) + (run_duration/100%100) + (ceiling(run_duration%100/60.0))),0),1) as DurationMinutes,

    REPLICATE(' ', datediff(mi, getdate()-1, convert(datetime, convert(varchar(10),run_date%100) + '/' + convert(varchar(10),run_date/100%100) + '/' + convert(varchar(10),run_date/10000) + ' ' + convert(varchar(4),run_time/10000) + ':' + convert(varchar(4),run_time/100%100) + ':' + convert(varchar(4),run_time%100)))) +

    REPLICATE('x', isnull(nullif(convert(int,(run_duration/10000 * 60) + (run_duration/100%100) + (ceiling(run_duration%100/60.0))),0),1)) as DurationTimeline,

    his.message

    FROM

    msdb.dbo.sysjobhistory his

    INNER JOIN msdb.dbo.sysjobs job ON his.job_id = job.job_id

    WHERE

    convert(datetime, convert(varchar(10),run_date%100) + '/' + convert(varchar(10),run_date/100%100) + '/' + convert(varchar(10),run_date/10000) + ' ' + convert(varchar(4),run_time/10000) + ':' + convert(varchar(4),run_time/100%100) + ':' + convert(varchar(4),run_time%100)) between getdate()-1 and getdate()

    and step_id = 0

    ORDER BY

    his.server,

    his.run_date DESC, -- Added DESC

    his.run_time DESC, -- Added DESC

    job.name

  • Nicely done! I like the graph too.

    I was looking at the graph and thought shouldn't it reset back to left side of the "Duration Timeline" once the the next day's jobs are executed? Currently it looks like (from the graph) that the times of the jobs are changing.

    Just a thought.

    Rudy

  • I'm a newbie. can you explain a little more about leading minutes and duration timeline column? I don't understand. What spaces are you talking about? Please help me to understand.

  • Hi amc. It works like a bar chart. For every minute a job is running, an 'X' is printed. For every minute it is not running, a space is printed. You can compare the lines to see when jobs are running at the same time. So, if you have one row returned where the 'X's line up vertically with the lines above or below it, then it means the jobs were running concurrently.

    Hope that helps,

    Martin

  • Oh--Ok, I got it now. thank you! Becasue I really like this query.

    Uh, one more thing...explain LeadingMinutes, please.

  • Nice Script ...

    I would like to know whats mean of XX in result.

    i can not see last week's jobs result . like today tue morning i am running this script it showing me result on 2011-01-09 and 2011-01-10 what if i want to see results before this duration?

    Thanks

  • Thanks for the script.

Viewing 8 posts - 1 through 7 (of 7 total)

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