Script monitor for Mounted volumes - Windows

Script monitor for Mounted volumes - Windows

This script can be added as a script monitor and can be used to monitor the mounted volumes, this can display graphs as well -

#######################################################################
Command line -
cscript ${FileName}.vbs ${DeviceName} ${UserName} ${Password} "M:\SQLDATA\DATA"

Script body -
On Error Resume Next
Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
if Err.Number Then
WScript.Echo "Message:" & Err.Description
WScript.Quit(1)
End If

Select Case WScript.Arguments.Count
Case 4
strComputer = Wscript.Arguments(0)
strUsername = Wscript.Arguments(1)
strPassword = Wscript.Arguments(2)
strMountName = Wscript.Arguments(3)
Set wbemServices = objWbemLocator.ConnectServer(strComputer,"Root\CIMV2",strUsername,strPassword)

Case Else
WScript.Echo "Message:Error in number of parametes passed"
WScript.Quit(1)
End Select

If Err.Number Then
WScript.Echo "Message:" & Err.Description
WScript.Quit(1)
End If

'strMountName = strMountName.Replace("\\", "\\\\\\\\");
Set colItems = wbemServices.ExecQuery( _
    "SELECT * FROM Win32_Volume  where DriveLetter IS NULL",,48)
if Err.Number Then
WScript.Echo "Message:" & Err.Description
WScript.Quit(1)
End If

intPerFree=0

WScript.Echo "Data:"
For Each objItem in colItems
If objItem.Name = strMountName Then
    intPerFree = round (objItem.FreeSpace / objItem.Capacity * 100)
    Wscript.Echo "DATA"&vbTab&intPerFree
End If
Next

WScript.Quit(0)

#######################################################################

P.S - The text in BOLD has to be replaced according to your setup.

Set this to be executed from Local server and the Execution directory is ${TempDir}


                  New to ADSelfService Plus?