Missing OS Update KB957065

AK54381.MissingKB957065 (UnitMonitor)

Missing OS Update KB957065 to prevent file fragmenetation errors

Knowledge Base article:

External

http://go.microsoft.com/fwlink/?LinkId=199714

Element properties:

TargetMicrosoft.KnowledgeServices.SQLServer.DBEngine
Parent MonitorSystem.Health.ConfigurationState
CategoryConfigurationHealth
EnabledTrue
Alert GenerateTrue
Alert SeverityError
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.KnowledgeServices.Library.ScriptMonitorEx
RemotableTrue
AccessibilityPublic
Alert Message
Windows operating system missing update KB957065 to prevent NTFS sparse file fragmentation errors

<Details>
<Content>You are missing Windows Update KB957065. This update prevents operating system error 665, which is reported through SQL Event ID 823 when you execute the DBCC CHECKDB command on large databases or when extensive data updates are performed on large databases for which database snapshots are created. You are most likely to encounter this error on large and heavily fragmented files.</Content>
<CollectedInformation>
<Info>
<Name>Current NTFS.SYS file version</Name>
<Value>{0}</Value>
</Info>
<Info>
<Name>Required NTFS.SYS file version</Name>
<Value>6.0.6001.22272</Value>
</Info>
<Info>
<Name>Database files greater than 64 GB in size</Name>
<Value>{1}</Value>
</Info>
</CollectedInformation>
</Details>
RunAsDefault
CommentSupportTopic=SQL Server Crashes/Failures/Errors\Other;VersionNumber=1.0.0.10;

Source Code:

<UnitMonitor ID="AK54381.MissingKB957065" Comment="SupportTopic=SQL Server Crashes/Failures/Errors\Other;VersionNumber=1.0.0.10;" Accessibility="Public" Enabled="true" Target="KnowledgeServicesSQLServerLibrary!Microsoft.KnowledgeServices.SQLServer.DBEngine" ParentMonitorID="Health!System.Health.ConfigurationState" Remotable="true" Priority="Normal" TypeID="KnowledgeServicesLibrary!Microsoft.KnowledgeServices.Library.ScriptMonitorEx" ConfirmDelivery="true">
<Category>ConfigurationHealth</Category>
<AlertSettings AlertMessage="AlertMessageID07d9f0d2d0874d5eb3e31d40fe9a1498">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Error</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Data/Context/Property[@Name='DriverVersion']$</AlertParameter1>
<AlertParameter2>$Data/Context/Property[@Name='64GBDatabase']$</AlertParameter2>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Success" MonitorTypeStateID="Success" HealthState="Success"/>
<OperationalState ID="Error" MonitorTypeStateID="Error" HealthState="Error"/>
</OperationalStates>
<Configuration>
<ScriptName>detectUpdate.vbs</ScriptName>
<Arguments>$Target/Property[Type="MicrosoftSQLServerLibrary!Microsoft.SQLServer.ServerRole"]/InstanceName$ $Target/Property[Type="MicrosoftSQLServerLibrary!Microsoft.SQLServer.DBEngine"]/ConnectionString$</Arguments>
<ScriptBody><Script>
'Copyright (c) Microsoft Corporation. All rights reserved.
' This script takes one parameters of the sql instance
' retuns the bad driver information if found
' 0 SqlInstance

Option Explicit

Dim oAPI, oBag
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()

'Phase 1, detect if version of NTFS.sys is adequate
Dim fileSys
Set fileSys = CreateObject("Scripting.FileSystemObject")

'get the system folder to System32
Dim sysFolder, file, filename
sysFolder = fileSys.GetAbsolutePathName(fileSys.GetSpecialFolder(1) + "\drivers")

filename = sysFolder + "\NTFS.SYS"
if fileSys.FileExists(filename) Then
file = fileSys.GetFile(filename)
Else
Call oBag.AddValue("BadDriver", 0)
Call oAPI.Return(oBag)
WScript.Quit()
End If

'Check that the version is above 6.0.6001.22272
Dim fileVer
fileVer = fileSys.GetFileVersion(file)
Call oBag.AddValue("DriverVersion", CSTR(fileVer))
if Len(fileVer) = 0 Then
'This is unexpected
WScript.Quit -1
End If

Dim versionTokens, majorVersion, minorVersion, buildVersion, buildRevision
versionTokens = Split(fileVer, "." , -1, 1)

majorVersion = versionTokens(0)
minorVersion = versionTokens(1)
buildVersion = versionTokens(2)
buildRevision = versionTokens(3)

Dim BadDriverVersion
BadDriverVersion = false
if (majorVersion &lt; 6) Then
BadDriverVersion = true
End If

if ((majorVersion = 6) and (minorVersion = 0)) Then
if (buildVersion &lt; 6001) Then
BadDriverVersion = true
End If

if ((buildVersion = 6001) and (buildRevision &lt; 22272)) Then
BadDriverVersion = true
End If
End If

if BadDriverVersion Then
Call oBag.AddValue("BadDriver", 1)
else
Call oBag.AddValue("BadDriver", 0)
Call oAPI.Return(oBag)
WScript.Quit()
End If

'phase 2 Add in databases that exceeds 64 GB.
Dim oArgs, oConnection, connString, sqlInstance, instanceName

Set oArgs = WScript.Arguments
If oArgs.Count &lt; 1 Then
WScript.Quit -1
End If
instanceName = oArgs(0)

If oArgs.Count = 2 Then
sqlInstance = oArgs(1)
else
sqlInstance = ""
End If
connString = "Provider=SQLOLEDB;Data Source=" + sqlInstance + "; Initial Catalog=master;Integrated Security=SSPI"

Set oConnection = CreateObject("ADODB.Connection")
oConnection.Open connString

Dim query
query = "SELECT CAST((SELECT [Database].[name], [Database].[FileName], [Database].[FileSize] FROM " &amp; _
"(SELECT DB_NAME(mf.database_id) as [Name], " &amp; _
"mf.[physical_name] as [FileName], " &amp; _
"(CAST(mf.[size] as float)*8)/(1024*1024) as [FileSizeInGB], " &amp; _
"(CAST(CAST(Round(CAST(mf.[size] as decimal) * 8 / (1024*1024), 3) as float) as varchar(50)) + ' GB') as [FileSize] " &amp; _
"FROM sys.master_files mf " &amp; _
"LEFT OUTER JOIN sys.databases db ON mf.database_id = db.database_id " &amp; _
"WHERE mf.type_desc = 'ROWS' and db.source_database_id IS NULL) [Database] " &amp; _
"WHERE [Database].[FileSizeInGB] &gt; 64 FOR XML PATH) " &amp; _
"as nvarchar(max)) as data"

Dim oResults
Set oResults = oConnection.Execute(query)

If (NOT oResults.EOF) AND (NOT IsNull(oResults(0))) Then
Call oBag.AddValue("64GBDatabase", CStr(oResults(0)))
Else
Call oBag.AddValue("64GBDatabase", "")
End If

'Phase 3 Get the OS version and service pack from WMI
Dim oWMIService
Set oWMIService = GetObject("winmgmts:!\\.\root\cimv2")

Dim item, items
Dim version, servicePack
Set items = oWMIService.ExecQuery("SELECT Version,ServicePackMajorVersion FROM Win32_OperatingSystem")
If IsNull(items) = False And items.Count &gt; 0 Then
For Each item In items
If IsNull(item) = False Then
version = item.Version
servicePack = item.ServicePackMajorVersion
Exit For
End If
Next
End If

If IsNull(version) Or version = "" Then
WScript.Quit -1
End If

versionTokens = Split(version, "." , -1, 1)

If UBound(versionTokens) &lt; 2 Then
WScript.Quit -1
End If

Call oBag.AddValue("Version", version)
Call oBag.AddValue("MajorVersion", CInt(versionTokens(0)))
Call oBag.AddValue("MinorVersion", CInt(versionTokens(1)))
Call oBag.AddValue("ServicePack", servicePack)

Call oAPI.Return(oBag)
</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
<ErrorExpression>
<And>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='BadDriver']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">1</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Integer">Property[@Name='MajorVersion']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="Integer">6</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Integer">Property[@Name='ServicePack']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="Integer">1</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</And>
</ErrorExpression>
<SuccessExpression>
<Not>
<Expression>
<And>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='BadDriver']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">1</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Integer">Property[@Name='MajorVersion']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="Integer">6</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Integer">Property[@Name='ServicePack']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="Integer">1</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</And>
</Expression>
</Not>
</SuccessExpression>
<Schedule>86397</Schedule>
</Configuration>
</UnitMonitor>