Clustering with Access-Based Enumeration (Part 2)
In Part 1 of this article we wrote a short script to re-enable Access-Based Enumeration on a clustered file share. In part 2, we'll dissect the script and make some improvements to the code so that the status of ABE can be checked. This will allow the Cluster Administrator console to show the true current state of Access-Based Enumeration to administrative users.
Here's the original script:
Function Online( ) on error resume next ' Call the ABECMD.EXE /Enable command for each share Set oShell = CreateObject("WScript.Shell") oShell.Run "H:\ABECMD.EXE /enable ABEShare", 1, true if (Err.Number <> 0) then Online = 1 end if Online = 0 End Function Function LooksAlive( ) LooksAlive = True End Function Function IsAlive( ) IsAlive = True End Function
The script is divided into 3 separate functions.
The Online() Function
The Online() function is called when the cluster resource monitor attempts to bring the Generic Script resource online. This function is responsible for taking any action that enables the required functionality for the script. In our case, we want to use the ABE command line utility ABECMD.EXE to enable ABE on the clustered share. It's important to note the return values from the Online() function; if it returns zero (0) the function was successful and the resource is placed online. Other values will cause repeated attempts to bring the resource online, possibly followed by a failover.
The LooksAlive() Function
The LooksAlive() function is called at intervals determined by the cluster resource configuration. Microsoft says the following about the LooksAlive() function:
Perform one or more very fast, cursory checks of the specified instance with the emphasis on detecting potential problems rather than verifying operational status. IsAlive will determine whether the instance is really operational. Take no more than 300 milliseconds to return a value. Resource Monitor calls LooksAlive repeatedly at a specified time interval (for example, once every five seconds).
The default time interval for LooksAlive calls is 5 seconds but it is configurable by the administrator.
We return True in this function to tell the Resource Monitor that ABE is probably active.
The IsAlive() Function
The IsAlive() function is called at intervals determined by the cluster resource configuration. Microsoft says the following about the IsAlive() function:
Perform a complete check of the resource to see if it is functioning properly. The set of procedures you need to use depends on your resource. For example, a database resource should check to see that the database can write to the disk and perform queries and updates to the disk. If the resource has definitely failed, return FALSE. The Resource Monitor immediately sets the status of the resource to "ClusterResourceFailed" and calls the Terminate entry point function. Resource Monitor calls IsAlive repeatedly at a specified time interval (for example, once every sixty seconds).
The default time interval for IsAlive calls is 60 seconds but it is configurable by the Administrator.
We return True in this function to tell the Resource Monitor that ABE is definitely active.
Improving the IsAlive() function
In part 1 we noted that we're not really telling the truth about the ABE resource. We're telling Resource Monitor that ABE is enabled, but we're not checking it. So we change the IsAlive() function as follows:
Function IsAlive( ) Set oShell = CreateObject("WScript.Shell") set wshRun = oShell.Exec ("H:\ABECMD.EXE ABEShare") if (Err.Number <> 0) or (wshRun.Status <> 0) then IsAlive = False
sABEOutput = wshRun.StdOut.ReadAll() if InStr(sABEOutput, "enabled") then
end if End Function
Now we're really checking that ABE is enabled for the share. If an administrator comes along and disables ABE, the cluster Resource Monitor will know about it and we can take corrective action.