Do you use Microsoft Clustering? Are your clusters configured according to the current Microsoft recommended practices? How can you be sure of the configuration? Questions, questions. The first is easy, the second you might be unsure of and the third is somewhat more difficult. If you search around Microsoft.com you will find recommendations on how best to configure your cluster, but the thing is that there is no easy way to double-check everything is as it should be, except by making a tedious manual review of all the settings. While clustering isn't overly complicated, this checking process can be time-consuming, and, as with every manual process, is subject to human error. So, what to do? In this article, I will be developing a script that takes care of part of the checking, namely auditing the status of the updates on each of the nodes.
UPDATE: My colleague, Ben Pearce, has created a PowerShell version of this script. Check it out on his blog.
895092 - Recommended hotfixes for Windows Server 2003-based server clusters 923830 - Recommended hotfixes for Windows Server 2003 Service Pack 1- based server clusters 935640 - Recommended hotfixes for Windows Server 2003 Service Pack 2-based server clusters 895090 - Recommended hotfixes for Windows 2000 Service Pack 4-based server clusters
strClusterName = WScript.Arguments.Named.Item("cluster") strKBList = WScript.Arguments.Named.Item("KBlist") If(("" = strClusterName) OR ("" = strKBList)) Then Wscript.Echo "Error parsing command-line. Check Command-line and try again." wscript.quit End If
cscript ClusterHotfixCheck.vbs /cluster:<cluster_name> /KBlist:<KB_list_text_file>
Set objWMICLuster = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strClusterName & "\root\mscluster") Set collNodeList = objWMICLuster.ExecQuery("Select name from MSCluster_Node")
Set dictFixes = CreateObject("Scripting.Dictionary") For Each objNode in collNodeList intNodeID = intNodeID + 1 Set objWMINode = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & objNode.Name & "\root\cimv2") Set collFixes = objWMINode.ExecQuery("SELECT HotfixID FROM Win32_QuickFixEngineering") For Each objFix in collFixes strTempFix = StripPrefix(objFix.HotfixID) If(dictFixes.Exists(strTempFix)) Then arrTemp = dictFixes(strTempFix ) arrTemp(intNodeID) = "1" dictFixes.Remove(strTempFix) dictFixes.Add strTempFix , arrTemp Else arrNodes(9) = Len(objNode.Name) arrNodes(intNodeID) = "1" dictFixes.Add strTempFix , arrNodes End If Next Next
Exists
StripPrefix()
Function StripPrefix(strHotFixID) If(1 = InStr(strHotFixID, "Q")) Then StripPrefix = Mid(strHotfixID, 2, 6) ElseIf(1 = InStr(strHotfixID, "KB")) Then StripPrefix = Mid(strHotfixID, 3, 6) Else StripPrefix = strHotfixID End If End Function
Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFixList = objFSO.OpenTextFile(strKBList, 1) arrNodes = Array(0,0,0,0,0,0,0,0,0,0) Do While objFixList.AtEndOfStream <> True strHotFix = objFixList.ReadLine If("" <> Trim(strHotfix)) Then If(dictFixes.Exists(strHotfix)) Then arrTemp = dictFixes(strHotfix) arrTemp(0) = "2" dictFixes.Remove(strHotfix) dictFixes.Add strHotfix, arrTemp Else arrNodes(0) = "2" dictFixes.Add strHotfix, arrNodes End If End If Loop objFixlist.Close DisplayOutput()
DisplayOutput()
Typical script output
Recommended Updates "--" is used if an update is on the recommended list and is installed on all nodes. "XX" is used if an update is recommended but is missing from one or more nodes. General Updates "++" is used if an update is not on the recommended list and is installed on all nodes. "**" is used if an update is not on the recommended list and is missing from one or more nodes. Specific Nodes and Updates "0" is used to show that an update is not installed on the given node. "1" is used to show that the update is installed on the given node.
ClusterHotfixCheck.zip [This script is subject to the Microsoft Terms of Use. Essentially, you use it at your own risk!]
ClusterHotfixCheck.zip
[This script is subject to the Microsoft Terms of Use. Essentially, you use it at your own risk!]
PingBack from http://lukenotley.wordpress.com/2007/05/06/speedlinking-104/
So Guys + Gals As well as writing PowerShell scripts and running a PowerShell course here in the UK,