Monitor large directories using the Windows Script Monitor
Before coding and testing your script, review Windows scripting details in the SAM Custom Application Monitor Template Guide and Best Practices for SAM templates.
-
Click Settings > All Settings > SAM Settings > SAM Settings > Create a New Template.
-
Name the template, click Add Component Monitor, select Windows Script Monitor, and click Add.
-
Provide a brief Description.
-
Select credentials with appropriate permissions to run the script on the target server.
-
In the Script Arguments field, type the Universal Naming Convention (UNC) path name for the directory to monitor.
Use the variable ${IP} for the IP address of the target node to which the monitor is assigned when the Windows Script Monitor runs.
-
Copy the following Visual Basic script, which retrieves the directory size, into the Script Body field:
Dim folderPath
folderPath = WScript.Arguments(0)
Set fs=WScript.CreateObject ("Scripting.FileSystemObject")
Set folder= fs.GetFolder(folderPath)
WScript.Echo "Message: Folder " &folderPath & " is " & folder.Size & " bytes large"
WScript.Echo "Statistic: " & folder.Size -
Specify the critical and warning thresholds for the desired directory size, and then click Submit.
-
Create an assigned Application Monitor by assigning the Large Directory Monitor template to the node.
-
In the SolarWinds Platform Web Console, click Settings > All Settings > SAM Settings > Manually Assign Application Monitors.
-
Select All in the Show only list.
-
Click Large Directory Monitor and then click Next.
-
Locate and select the desired node, and then click Next.
-
Enter
itadmin
in the Credential Name field and then enter your credentials. -
Click Test, click Assign Application Monitors, and then click Done.
-
When monitoring occurs, the Visual Basic code in the template will:
-
Read the first argument passed to the UNC path name for the directory to monitor and store it in FolderPath.
-
Create the
Scripting.FileSystemObject
and store it infs
. -
Retrieve the folder name from the saved command line argument and store it in
FolderPath
. -
Display the folder name and folder size as output.
-
Display the folder size, measured in bytes.
The script does not perform error checking.