%3CLINGO-SUB%20id%3D%22lingo-sub-365507%22%20slang%3D%22en-US%22%3ESQL%20Agent%20Job%20Discovery%20not%20working%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-365507%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%20First%20published%20on%20TECHNET%20on%20Jun%2004%2C%202009%20%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EThe%20SQL%20Server%20Management%20Pack%20includes%20an%20option%20to%20discover%20and%20monitor%20SQL%20Server%20Agent%20Jobs%20for%20SQL%202000%2F2005%2F2008.%26nbsp%3B%20The%20Discovery%20for%20this%20is%20disabled%20by%20default%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20697px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F86752i02ADD2C17EFE271B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20ran%20into%20an%20issue%20recently%20where%20all%20Agent%20Jobs%20for%20specific%20SQL%20Servers%20were%20not%20being%20discovered.%26nbsp%3B%20Examining%20the%20event%20logs%20on%20the%20SQL%20Server%2C%20we%20see%20the%20following%20in%20the%20OpsMgr%20Event%20Log%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELog%20Name%3A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Operations%20Manager%20%3CBR%20%2F%3ESource%3A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Health%20Service%20Modules%20%3CBR%20%2F%3EDate%3A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%206%2F4%2F2009%208%3A36%3A19%20PM%20%3CBR%20%2F%3EEvent%20ID%3A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%2021406%20%3CBR%20%2F%3ETask%20Category%3A%20None%20%3CBR%20%2F%3ELevel%3A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Warning%20%3CBR%20%2F%3EKeywords%3A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Classic%20%3CBR%20%2F%3EUser%3A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20N%2FA%20%3CBR%20%2F%3EComputer%3A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20OMDW.opsmgr.net%20%3CBR%20%2F%3EDescription%3A%20%3CBR%20%2F%3EThe%20process%20started%20at%208%3A36%3A18%20PM%20failed%20to%20create%20System.Discovery.Data.%20Errors%20found%20in%20output%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EC%3A%5CProgram%20Files%5CSystem%20Center%20Operations%20Manager%202007%5CHealth%20Service%20State%5CMonitoring%20Host%20Temporary%20Files%201%5C4595%5CSQLAgentJobDiscovery.vbs(106%2C%205)%20Microsoft%20VBScript%20runtime%20error%3A%20Type%20mismatch%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECommand%20executed%3A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%22C%3A%5CWindows%5Csystem32%5Ccscript.exe%22%20%2Fnologo%20%22SQLAgentJobDiscovery.vbs%22%20%7B974F57A5-5705-B6B2-B8DC-1CA0B433DCD4%7D%20%7B46913442-CAC1-7E38-89B4-1A6B462ED0D0%7D%20OMDW.opsmgr.net%20OMDW.opsmgr.net%26nbsp%3B%20OMDW%5CI01%20I01%20SQLAgent%24I01%22%20%3CBR%20%2F%3EWorking%20Directory%3A%26nbsp%3B%26nbsp%3B%26nbsp%3B%20C%3A%5CProgram%20Files%5CSystem%20Center%20Operations%20Manager%202007%5CHealth%20Service%20State%5CMonitoring%20Host%20Temporary%20Files%201%5C4595%5C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOne%20or%20more%20workflows%20were%20affected%20by%20this.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWorkflow%20name%3A%20Microsoft.SQLServer.2008.AgentJobDiscoveryRule%20%3CBR%20%2F%3EInstance%20name%3A%20SQLAgent%24I01%20%3CBR%20%2F%3EInstance%20ID%3A%20%7B46913442-CAC1-7E38-89B4-1A6B462ED0D0%7D%20%3CBR%20%2F%3EManagement%20group%3A%20PROD1%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20%E2%80%9CType%20mismatch%E2%80%9D%20error%20typically%20means%20that%20some%20variable%20in%20the%20script%20is%20returning%20with%20an%20incorrect%20data%20type.%26nbsp%3B%20After%20examining%20the%20Discovery%20script%20and%20doing%20to%20troubleshooting%2C%20we%20determined%20that%20the%20problem%20was%20happening%20because%20the%20%E2%80%9CDescription%E2%80%9D%20field%20for%20the%20Agent%20Job%20was%20NULL.%26nbsp%3B%20This%20can%20be%20confirmed%20by%20running%20the%20%E2%80%9Csp_help_job%E2%80%9D%20Stored%20Procedure%20against%20the%20MSDB%20database%20on%20the%20SQL%20Instance%20(which%20is%20exactly%20what%20the%20Discovery%20script%20does%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20913px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F86754i0FED7151DCA4B84A%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20will%20also%20happen%20if%20any%20of%20the%20following%20properties%20of%20the%20job%20are%20NULL%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Ejob_id%20%3CBR%20%2F%3Eoriginating_server%20%3CBR%20%2F%3Ename%20%3CBR%20%2F%3Edescription%20%3CBR%20%2F%3Ecategory%20%3CBR%20%2F%3Eowner%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20probably%20won't%20ever%20see%20this%20with%20the%20job_id%2C%20originating_server%2C%20category%20or%20name%20properties%2C%20but%20we've%20seen%20it%20with%20the%20description%20and%20owner%20properties.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20correct%20this%2C%20we%20can%20simply%20enter%20some%20text%20in%20the%20description%20field%20of%20the%20Agent%20Job%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20945px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F86756i840C2CA2418F09DB%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENote%20that%20the%20problem%20described%20above%20(Agent%20Job%20discovery%20failing%20when%20properties%20are%20NULL)%20happens%20on%20SQL%202005%20and%202008%20Agent%20Jobs.%26nbsp%3B%20SQL%202000%20Agent%20Job%20Discovery%20does%20not%20use%20the%20VBScript%2C%20and%20does%20seem%20to%20work%20in%20this%20scenario%2C%20but%20the%20NULL%20values%20are%20populated%20with%20the%20values%20of%20other%20Agent%20Jobs%2C%20so%20it%20is%20not%20accurate.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%2C%20what%20if%20you%20have%20a%20very%20large%20number%20of%20SQL%20Servers%20and%20Agent%20Jobs%20and%20do%20not%20want%20to%20worry%20about%20making%20sure%20that%20all%20of%20them%20have%20text%20in%20the%20Description%20field%3F%26nbsp%3B%20To%20take%20care%20of%20this%2C%20I%20created%20a%20%E2%80%9Cworkaround%E2%80%9D%20version%20of%20the%20SQL%20Agent%20Job%20Discoveries%20that%20will%20discover%20these%20jobs%20and%20enters%20NULL%20for%20the%20NULL%20propeerty.%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3COL%3E%0A%3COL%3E%0A%3CLI%3EImport%20the%20%E2%80%9CMicrosoft.SQLServer.200x.Discovery.CustomAgentJobDiscovery.xml%E2%80%9D%20management%20pack%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EDisable%20the%20original%20Agent%20Job%20Discovery%20and%20enable%20the%20new%20one%20(%E2%80%9CSQL%20Server%20200x%20Custom%20Agent%20Job%20Discovery%E2%80%9D)%3A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20750px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F86758i939F93A965BCCABA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EVerify%20that%20the%20Agent%20Jobs%20are%20discovered%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20663px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F86761iF060267263511515%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fmsdnshared.blob.core.windows.net%2Fmedia%2FTNBlogsFS%2Fprod.evol.blogs.technet.com%2Ftelligent.evolution.components.attachments%2F01%2F6699%2F00%2F00%2F03%2F25%2F05%2F73%2FCustom_SQL_Agent_Job_Discovery.zip%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3E%20Custom_SQL_Agent_Job_Discovery.zip%20%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-365507%22%20slang%3D%22en-US%22%3E%3CP%3EFirst%20published%20on%20TECHNET%20on%20Jun%2004%2C%202009%20The%20SQL%20Server%20Management%20Pack%20includes%20an%20option%20to%20discover%20and%20monitor%20SQL%20Server%20Agent%20Jobs%20for%20SQL%202000%2F2005%2F2008.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-365507%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EJimmyHarper%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

First published on TECHNET on Jun 04, 2009

The SQL Server Management Pack includes an option to discover and monitor SQL Server Agent Jobs for SQL 2000/2005/2008.  The Discovery for this is disabled by default:

 

 

I ran into an issue recently where all Agent Jobs for specific SQL Servers were not being discovered.  Examining the event logs on the SQL Server, we see the following in the OpsMgr Event Log:

 

Log Name:      Operations Manager
Source:        Health Service Modules
Date:          6/4/2009 8:36:19 PM
Event ID:      21406
Task Category: None
Level:         Warning
Keywords:      Classic
User:          N/A
Computer:      OMDW.opsmgr.net
Description:
The process started at 8:36:18 PM failed to create System.Discovery.Data. Errors found in output:

 

C:\Program Files\System Center Operations Manager 2007\Health Service State\Monitoring Host Temporary Files 1\4595\SQLAgentJobDiscovery.vbs(106, 5) Microsoft VBScript runtime error: Type mismatch

 

Command executed:    "C:\Windows\system32\cscript.exe" /nologo "SQLAgentJobDiscovery.vbs" {974F57A5-5705-B6B2-B8DC-1CA0B433DCD4} {46913442-CAC1-7E38-89B4-1A6B462ED0D0} OMDW.opsmgr.net OMDW.opsmgr.net  OMDW\I01 I01 SQLAgent$I01"
Working Directory:    C:\Program Files\System Center Operations Manager 2007\Health Service State\Monitoring Host Temporary Files 1\4595\

 

One or more workflows were affected by this.

 

Workflow name: Microsoft.SQLServer.2008.AgentJobDiscoveryRule
Instance name: SQLAgent$I01
Instance ID: {46913442-CAC1-7E38-89B4-1A6B462ED0D0}
Management group: PROD1

 

The “Type mismatch” error typically means that some variable in the script is returning with an incorrect data type.  After examining the Discovery script and doing to troubleshooting, we determined that the problem was happening because the “Description” field for the Agent Job was NULL.  This can be confirmed by running the “sp_help_job” Stored Procedure against the MSDB database on the SQL Instance (which is exactly what the Discovery script does:

 

 

 

 

This will also happen if any of the following properties of the job are NULL:

 

job_id
originating_server
name
description
category
owner

 

We probably won't ever see this with the job_id, originating_server, category or name properties, but we've seen it with the description and owner properties.

 

To correct this, we can simply enter some text in the description field of the Agent Job:

 

 

Note that the problem described above (Agent Job discovery failing when properties are NULL) happens on SQL 2005 and 2008 Agent Jobs.  SQL 2000 Agent Job Discovery does not use the VBScript, and does seem to work in this scenario, but the NULL values are populated with the values of other Agent Jobs, so it is not accurate.

 

So, what if you have a very large number of SQL Servers and Agent Jobs and do not want to worry about making sure that all of them have text in the Description field?  To take care of this, I created a “workaround” version of the SQL Agent Job Discoveries that will discover these jobs and enters NULL for the NULL propeerty.



    1. Import the “Microsoft.SQLServer.200x.Discovery.CustomAgentJobDiscovery.xml” management pack

 

  1. Disable the original Agent Job Discovery and enable the new one (“SQL Server 200x Custom Agent Job Discovery”):

 

 

Verify that the Agent Jobs are discovered:

 

 

Custom_SQL_Agent_Job_Discovery.zip