<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.technet.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>JIMMY HARPER'S OPERATIONS MANAGER BLOG : Type Mismatch</title><link>http://blogs.technet.com/jimmyharper/archive/tags/Type+Mismatch/default.aspx</link><description>Tags: Type Mismatch</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>SQL Agent Job Discovery not working?</title><link>http://blogs.technet.com/jimmyharper/archive/2009/06/05/sql-agent-job-discovery-not-working.aspx</link><pubDate>Fri, 05 Jun 2009 05:36:00 GMT</pubDate><guid isPermaLink="false">d5e57398-b9ef-4490-9955-07cbb4e4a80d:3250573</guid><dc:creator>jimmyharper</dc:creator><slash:comments>4</slash:comments><comments>http://blogs.technet.com/jimmyharper/comments/3250573.aspx</comments><wfw:commentRss>http://blogs.technet.com/jimmyharper/commentrss.aspx?PostID=3250573</wfw:commentRss><description>&lt;P&gt;The SQL Server Management Pack includes an option to discover and monitor SQL Server Agent Jobs for SQL 2000/2005/2008.&amp;nbsp; The Discovery for this is disabled by default:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.technet.com/blogfiles/jimmyharper/WindowsLiveWriter/SQLAgentJobDiscoverynotworking_13BF7/image_2.png" mce_href="http://blogs.technet.com/blogfiles/jimmyharper/WindowsLiveWriter/SQLAgentJobDiscoverynotworking_13BF7/image_2.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.technet.com/blogfiles/jimmyharper/WindowsLiveWriter/SQLAgentJobDiscoverynotworking_13BF7/image_thumb.png" width=697 height=240 mce_src="http://blogs.technet.com/blogfiles/jimmyharper/WindowsLiveWriter/SQLAgentJobDiscoverynotworking_13BF7/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;I ran into an issue recently where all Agent Jobs for specific SQL Servers were not being discovered.&amp;nbsp; Examining the event logs on the SQL Server, we see the following in the OpsMgr Event Log:&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#ff0000 size=1&gt;Log Name:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Operations Manager &lt;BR&gt;Source:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Health Service Modules &lt;BR&gt;Date:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6/4/2009 8:36:19 PM &lt;BR&gt;Event ID:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 21406 &lt;BR&gt;Task Category: None &lt;BR&gt;Level:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Warning &lt;BR&gt;Keywords:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Classic &lt;BR&gt;User:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; N/A &lt;BR&gt;Computer:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OMDW.opsmgr.net &lt;BR&gt;Description: &lt;BR&gt;The process started at 8:36:18 PM failed to create System.Discovery.Data. Errors found in output: &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#ff0000 size=1&gt;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 &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#ff0000 size=1&gt;Command executed:&amp;nbsp;&amp;nbsp;&amp;nbsp; "C:\Windows\system32\cscript.exe" /nologo "SQLAgentJobDiscovery.vbs" {974F57A5-5705-B6B2-B8DC-1CA0B433DCD4} {46913442-CAC1-7E38-89B4-1A6B462ED0D0} OMDW.opsmgr.net OMDW.opsmgr.net&amp;nbsp; OMDW\I01 I01 SQLAgent$I01" &lt;BR&gt;Working Directory:&amp;nbsp;&amp;nbsp;&amp;nbsp; C:\Program Files\System Center Operations Manager 2007\Health Service State\Monitoring Host Temporary Files 1\4595\ &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#ff0000 size=1&gt;One or more workflows were affected by this.&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#ff0000 size=1&gt;Workflow name: Microsoft.SQLServer.2008.AgentJobDiscoveryRule &lt;BR&gt;Instance name: SQLAgent$I01 &lt;BR&gt;Instance ID: {46913442-CAC1-7E38-89B4-1A6B462ED0D0} &lt;BR&gt;Management group: PROD1&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The “Type mismatch” error typically means that some variable in the script is returning with an incorrect data type.&amp;nbsp; 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.&amp;nbsp; 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:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.technet.com/blogfiles/jimmyharper/WindowsLiveWriter/SQLAgentJobDiscoverynotworking_13BF7/image_4.png" mce_href="http://blogs.technet.com/blogfiles/jimmyharper/WindowsLiveWriter/SQLAgentJobDiscoverynotworking_13BF7/image_4.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.technet.com/blogfiles/jimmyharper/WindowsLiveWriter/SQLAgentJobDiscoverynotworking_13BF7/image_thumb_1.png" width=913 height=307 mce_src="http://blogs.technet.com/blogfiles/jimmyharper/WindowsLiveWriter/SQLAgentJobDiscoverynotworking_13BF7/image_thumb_1.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will also happen if any of the following properties of the job are NULL:&lt;/P&gt;
&lt;P&gt;job_id &lt;BR&gt;originating_server &lt;BR&gt;name &lt;BR&gt;description &lt;BR&gt;category &lt;BR&gt;owner &lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;To correct this, we can simply enter some text in the description field of the Agent Job:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.technet.com/blogfiles/jimmyharper/WindowsLiveWriter/SQLAgentJobDiscoverynotworking_13BF7/image_6.png" mce_href="http://blogs.technet.com/blogfiles/jimmyharper/WindowsLiveWriter/SQLAgentJobDiscoverynotworking_13BF7/image_6.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.technet.com/blogfiles/jimmyharper/WindowsLiveWriter/SQLAgentJobDiscoverynotworking_13BF7/image_thumb_2.png" width=945 height=658 mce_src="http://blogs.technet.com/blogfiles/jimmyharper/WindowsLiveWriter/SQLAgentJobDiscoverynotworking_13BF7/image_thumb_2.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Note that the problem described above (Agent Job discovery failing when properties are NULL) happens on SQL 2005 and 2008 Agent Jobs.&amp;nbsp; 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.&lt;/P&gt;
&lt;P&gt;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?&amp;nbsp; 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.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Import the “Microsoft.SQLServer.200x.Discovery.CustomAgentJobDiscovery.xml” management pack &lt;BR&gt;&lt;/LI&gt;
&lt;LI&gt;Disable the original Agent Job Discovery and enable the new one (“SQL Server 200x Custom Agent Job Discovery”):&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;A href="http://blogs.technet.com/blogfiles/jimmyharper/WindowsLiveWriter/SQLAgentJobDiscoverynotworking_13BF7/image_8.png" mce_href="http://blogs.technet.com/blogfiles/jimmyharper/WindowsLiveWriter/SQLAgentJobDiscoverynotworking_13BF7/image_8.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.technet.com/blogfiles/jimmyharper/WindowsLiveWriter/SQLAgentJobDiscoverynotworking_13BF7/image_thumb_3.png" width=750 height=184 mce_src="http://blogs.technet.com/blogfiles/jimmyharper/WindowsLiveWriter/SQLAgentJobDiscoverynotworking_13BF7/image_thumb_3.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Verify that the Agent Jobs are discovered:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.technet.com/blogfiles/jimmyharper/WindowsLiveWriter/SQLAgentJobDiscoverynotworking_13BF7/image_10.png" mce_href="http://blogs.technet.com/blogfiles/jimmyharper/WindowsLiveWriter/SQLAgentJobDiscoverynotworking_13BF7/image_10.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.technet.com/blogfiles/jimmyharper/WindowsLiveWriter/SQLAgentJobDiscoverynotworking_13BF7/image_thumb_4.png" width=663 height=376 mce_src="http://blogs.technet.com/blogfiles/jimmyharper/WindowsLiveWriter/SQLAgentJobDiscoverynotworking_13BF7/image_thumb_4.png"&gt;&lt;/A&gt;&lt;/P&gt;&lt;img src="http://blogs.technet.com/aggbug.aspx?PostID=3250573" width="1" height="1"&gt;</description><enclosure url="http://blogs.technet.com/jimmyharper/attachment/3250573.ashx" length="11913" type="application/x-zip-compressed" /><category domain="http://blogs.technet.com/jimmyharper/archive/tags/Discovery/default.aspx">Discovery</category><category domain="http://blogs.technet.com/jimmyharper/archive/tags/SQL/default.aspx">SQL</category><category domain="http://blogs.technet.com/jimmyharper/archive/tags/Type+Mismatch/default.aspx">Type Mismatch</category><category domain="http://blogs.technet.com/jimmyharper/archive/tags/Agent+Job/default.aspx">Agent Job</category><category domain="http://blogs.technet.com/jimmyharper/archive/tags/Management+Pack/default.aspx">Management Pack</category></item></channel></rss>