in HM, set up the test as follows (substitute things in []'s for your environment):
Code: Select all
Method = ExternalPrg
;--- Common properties ---
;DestFolder = Root\
RMAgent = [AGENTNAME]
Title = MailboxDB Mount Status
Comment = cscript
RelatedURL =
CmntPattern = %path%
ScheduleMode= OneTestPerDay
ScheduleTime= 05:10:00
Alerts = Send Email
ReverseAlert= No
UnknownIsBad= Yes
WarningIsBad= Yes
UseCommonLog= Yes
PrivateLog = C:\Program Files\HostMonitor7\Logs\mailboxmount.htm
PrivLogMode = Full
CommLogMode = Default
SyncCounters= Yes
SyncAlerts = No
DependsOn = list
MasterTest-Alive = Ping: 4.2.2.2
;--- Test specific properties ---
CommandLine = cscript c:\store.vbs status [SERVERNAME] "[STORAGEGROUP]" "[MAILBOX STORE]"
Condition = MoreThan
ErrorLevel = 0
WindowMode = hide
CommandLine = cscript c:\store.vbs status server2003 "First Storage Group" "Mailbox Store (SERVER2003)"
Here is the VBS script:
Code: Select all
' Name: Store.VBS
' Purpose: To Mount, Dismount, or Delete a Mailbox Store (MDB) on Exchange Server
'
'Written by Leon Funnell
'email me at leon_funnell(At)hotmail(d0t)com
'17/02/2005
'modified by LDean -- ldean[at]quikteks[dot]com
'11/10/2008
quot = chr(34)
Set iServer = CreateObject ("CDOEXM.ExchangeServer")
Set iMDB = CreateObject ("CDOEXM.MailboxStoreDB")
' check command line
GetArgs strMode,strComputerName,strSGName,strMDBName,CorrectSyntax
If CorrectSyntax Then
BindMailboxStore strComputerName,strSGName,strMDBName
Select Case strMode
Case "mount"
wscript.echo "Mounting Database " & strMDBName & " in Storage Group " & strSGName & " on " & strComputerName
iMDB.mount
Case "dismount"
wscript.echo "Dismounting Database " & strMDBName & " in Storage Group " & strSGName & " on " & strComputerName
iMDB.dismount
Case "delete"
wscript.echo "Deleting Database " & strMDBName & " in Storage Group " & strSGName & " on " & strComputerName
iMDB.DataSource.delete
Case "status"
dim sStoreStatus
If iMDB.Status = 0 Then
wscript.quit(0)
ElseIf iMDB.Status = 1 Then
wscript.quit(1)
ElseIf iMDB.Status = 2 Then
wscript.quit(2)
ElseIf iMDB.Status = 3 Then
wscript.quit(3)
Else
wscript.quit(4)
End If
End Select
' Cleanup
Set iServer = Nothing
Set iMDB = Nothing
Else
DisplayHelp
wscript.quit
End If
Sub BindMailboxStore (strComputerName,strSGName,strMDBName)
' Bind to the Exchange Server
iServer.DataSource.Open strComputerName
' Build the first part of the URL to the MailboxStoreDB
strTemp = "LDAP://" & iServer.DirectoryServer & "/" & "cn=" & strMDBName & ","
' Set variant array to the ExchangeServer.StorageGroups
arrStGroup = iServer.StorageGroups
' Look in the StorageGroups array if the StorageGroup with strSGName exists
If strSGName = "" Then
' Add last part to the URL to the MailboxStoreDB
strMDBUrl = strTemp & iServer.StorageGroups(0)
Else
For i = 0 To UBound(arrStGroup)
If InStr(1, UCase(arrStGroup(i)), UCase(strSGName)) <> 0 Then
strMDBUrl = arrStGroup(i)
End If
Next
If strMDBUrl <> "" Then
' Add last part to the URL to the MailboxStoreDB
strMDBUrl = strTemp & strMDBUrl
End If
End If
' Bind to the MailboxStoreDB
iMDB.DataSource.Open strMDBUrl ', , , adCreateOverwrite
End Sub
Sub GetArgs(strMode,strComputerName,strSGName,strMDBName,CorrectSyntax)
Set Args = WScript.Arguments
If args.count = 4 Then
CorrectSyntax = True
strMode = args(0)
strComputerName = args(1)
strSGName = args(2)
strMDBName = args(3)
Else
CorrectSyntax = False
End If
Select Case lcase(strMode)
Case "mount","dismount","delete"
CorrectSyntax = True
Case "/?","/help","?","help"
CorrectSyntax = False
End Select
End Sub
Sub DisplayHelp
wscript.echo "Mounts, Dismounts, or Deletes a Mailbox Store on an Exchange 2000/2003 server"
wscript.echo ""
wscript.echo "cscript Store.vbs /? or /Help ----------------------------------- Displays this help screen"
wscript.echo "cscript Store.vbs Mount Servername StorageGroupName MDBName ----- Mounts Database"
wscript.echo "cscript Store.vbs Dismount Servername StorageGroupName MDBName -- Dismounts Database"
wscript.echo "cscript Store.vbs Delete Servername StorageGroupName MDBName ---- Deletes Database"
wscript.echo "cscript store.vbs status Servername StorageGroupName MDBName ---- Checks status of database"
wscript.echo ""
wscript.echo ""
wscript.echo "Example:"
wscript.echo ""
wscript.echo "cscript Store.vbs Mount SERVER1 ""&"First Storage Group""&" ""&"Mailbox Store (SERVER1)""
wscript.echo ""
End Sub
The script could also be used to remount or dismount the store if needed as an alert action. The script was originally written by someone else, but I modified it to add in the status check. If the store is mounted, it will return 0, if it is dismounted it will return 1, if it is mountING, it will return 2, and if it is dismountING, it will return 3. The alerts can be set up accordingly.
Let me know if there are questions.