Got a strange one that I can't get figured out. The script works great on several other machines but for some reason won't on one machine where I need to run it. I get the "Not enough server storage to process that command"
Thanks in advance.
The line it errors on is highlighted in red.
Here is the script
Thanks in advance.
The line it errors on is highlighted in red.
Here is the script
Code:
sConnection = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=blah; PORT=blah; DATABASE=blah; UID=blah; PASSWORD=blah; OPTION=3"
Set objConn = CreateObject("ADODB.Connection")
objConn.Open(sConnection)
Set objFSO = CreateObject("Scripting.FileSystemObject")
strPath = objFSO.GetParentFolderName(WScript.ScriptFullName)
strDateTime = GetDateTimeStamp
If objFSO.FileExists(strPath & "\log.txt") Then
objFSO.MoveFile strPath & "\log.txt", strPath & "\logs\log_" & strDateTime & ".txt"
Set objLogFile = objFSO.CreateTextFile(strPath & "\log.txt")
Else
Set objLogFile = objFSO.CreateTextFile(strPath & "\log.txt")
End If
objLogFile.WriteLine "--------------- Started: " & Now() & "---------------"
Set objDictionary = CreateObject("Scripting.Dictionary")
GetServerList()
objLogFile.WriteLine("# of virtual windows names in db: " & UBound(objDictionary.Items))
colDicItems = objDictionary.Items
For Each strItem in colDicItems
objLogFile.WriteLine ("Pinging: " & strItem)
If IsPingable(strItem) Then
strSQL = "DELETE from cluster_resource where virtual = '" & strItem & "'"
Set objRSDelete = objConn.Execute(strSQL)
objLogFile.WriteLine("Getting Cluster Resources for: " & strItem)
GetClusterResources(strItem)
End If
Next
objLogFile.WriteLine "--------------- Finished: " & Now() & "---------------"
objLogFile.Close
Set objLogFile = Nothing
Set objRSDelete = Nothing
objConn.Close
Set objConn = Nothing
Function GetClusterName(vServer)
Set objClus = CreateObject("MSCluster.Cluster")
objClus.Open vServer
GetClusterName = objClus.Name
End Function
Function GetClusterNodes(vCluster)
Set objClus = CreateObject("MSCluster.Cluster")
objClus.Open vCluster
vNodes = ""
For Each itmNode in objClus.Nodes
vNodes = vNodes & itmNode.Name & " "
Next
GetClusterNodes = vNodes
End Function
Function isClusterNode(vServer)
On Error Resume Next
Set objClus = CreateObject("MSCluster.Cluster")
objClus.Open vServer
If Err.Number <> 0 Then
isClusterNode = False
Else
isClusterNode = True
End If
End Function
Function GetClusterResources(vCluster)
Set objClus = CreateObject("MSCluster.Cluster")
[COLOR=red]objClus.Open vCluster[/color]
vResources = ""
For Each itmResources in objClus.Resources
vRName = itmResources.Name
vState = itmResources.State
vOwner = itmResources.ownernode.name
vEntry = ""
if itmResources.TypeName = "Network Name" then
set colPrivateProps = itmResources.PrivateProperties
vEntry = colPrivateProps.Item("Name").Value
End If
If itmResources.TypeName = "IP Address" then
set colPrivateProps = itmResources.PrivateProperties
vEntry = colPrivateProps.Item("Address").Value
End If
If itmResources.TypeName = "File Share" then
set colPrivateProps = itmResources.PrivateProperties
vEntry = "Share Name:" & colPrivateProps.Item("ShareName").Value & " Share Path:" & replace(colPrivateProps.Item("Path").Value,"\","\\")
End If
Select Case vState
Case 1
vState = "Initializing"
Case 2
vState = "Online"
Case 3
vState = "Offline"
Case 4
vState = "Failed"
Case 128
vState = "Pending"
Case 129
vState = "OnlinePending"
Case 130
vState = "OfflinePending"
Case Else
vState = "Unknown"
End Select
strSQL = "INSERT into cluster_resource (virtual,resource_name,resource_state,resource_owner,last_modified,notes) VALUES ('" & vCluster & "','" & vRName & "','" & vState & "','" & vOwner & "',now(),'" & vEntry & "')"
'objLog.WriteLine strSQL
Set objRS = objConn.Execute(strSQL)
Set objRS = Nothing
Next
End Function
Function IsPingable(vServer)
Const OpenAsDefault = -2
Const FailIfNotExist = 0
Const ForReading = 1
Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
sTemp = oShell.ExpandEnvironmentStrings("%TEMP%")
sTempFile = "runresult.tmp"
oShell.Run "%comspec% /c ping -n 2 -w 1000 " & vServer & ">" & sTempFile, 0, True
Set fFile = oFSO.OpenTextFile(sTempFile, ForReading, FailIfNotExist, OpenAsDefault)
sResults = fFile.ReadAll
fFile.Close
oFSO.DeleteFile (sTempFile)
IsPingable = (InStr(sResults, "TTL=") > 0)
Set oShell = Nothing
Set oFSO = Nothing
End Function
Function GetServerList()
Set objServers = CreateObject("ADODB.Recordset")
vSQL = "select distinct virtual from server_cluster where Cluster_type ='Windows'"
objServers.Open vSQL, objConn
While Not objServers.EOF
strServer = Ucase(objServers("virtual"))
objDictionary.Add strServer, strServer
objServers.MoveNext
Wend
objServers.close
Set Servers = Nothing
End Function
Function GetDateTimeStamp
Dim strNow
strNow = Now()
GetDateTimeStamp = Year(strNow) & "-" & Pad2(Month(strNow)) & "-" & Pad2(Day(StrNow))
End Function
Function Pad2(strIn)
Do While Len(strIn) < 2
strIn = "0" & strIn
Loop
Pad2 = strIn
End Function