You are here: Home > Products > Network Monitor (Pro) > User Manual > Network Monitoring Checks > Visual Basic Script (VBScript) Result Monitoring

Visual Basic Script (VBScript) Result Monitoring

The program allows you to monitor results of a Visual Basic Script (VBScript) function.

On the analogy with the "External Application" check, the "VBScript" and "Java-script" checks allow the application user to create custom, specific tests in these languages. In the settings for these checks, write the source code of the test script and specify which function in it is the main one (executable). For the positive result of its operation, the test script must always return the "OK" string value . If the test script returns a value different from this one, the check is considered failed, and the application issues an alert. It is recommended to check the operability of the test scripts with the operating system's standard means before configuring the checks.

The “VBScript” and “Java-Script” checks significantly expand the application's network and network hardware monitoring capabilities.

 

Useful VB Script Examples for Monitoring

1. Receiving the folder size including all sub-folders

2. Checking dates of files in a folder (useful for monitoring CCTV records on a file server)

3. Receiving the RAM usage in percent

4. Getting the average usage of all hard drives in percent

5. Executing a GET or POST request (using HTTP)

6. Sending a message to Slack

 

1. Receiving the folder size including all sub-folders

function Main

'Specify the folder path here:
Main = GetFolderSize("C:\\Logs\\")
'Use \\ instead of \ in the path

end function

Function GetFolderSize(Path)
Dim fso, fsize
Dim ctFolder, cFile, cFolder
Set fso=CreateObject("Scripting.FileSystemObject")
fsize = 0
Set ctFolder = fso.GetFolder(Path)
On Error Resume Next
For Each cFile In ctFolder.Files
fsize = fsize + cFile.Size
Next
For Each cFolder In ctFolder.SubFolders
fsize = fsize + GetFolderSize(cFolder.Path)
Next
GetFolderSize = fsize
End Function

 

2. Checking dates of files in a folder. If all files have the current date, then 1 is returned, otherwise 0. You can specify a network folder instead of a local path.

function Main
Dim fso, fsize
Dim ctFolder, cFile, AR, sdate, sdate2, sdate3
Set fso = CreateObject("Scripting.FileSystemObject")

'Specify the folder path here:
Set ctFolder = fso.GetFolder("C:\\Logs\\")
'Use \\ instead of \ in the path

AR = 1
sdate = CStr(Day(Date) & "." & Month(Date) & "." & Year(Date))
For Each cFile In ctFolder.Files
sdate2 = CStr(cFile.datelastmodified)
sdate3 = CStr(Day(sdate2) & "." & Month(sdate2) & "." & Year(sdate2))
If sdate <> sdate3 Then AR = 0
Next
Main=AR
End Function

 

3. Receiving the RAM usage in percent. Instead of the %A key, the program will automatically substitute the host address from the check parameters. The script uses a WMI query - you can run other queries based on this example.

function Main

strHostAddr = "%A"
strLogin = ""
strPassword = ""
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objSWbemLocator.ConnectServer(strHostAddr, "root\cimv2", strLogin, strPassword)
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem",,48)
For Each objItem in colItems
Main = Int((int(objItem.TotalVisibleMemorySize) - int(objItem.FreePhysicalMemory))/int(objItem.TotalVisibleMemorySize)*100)
Next
end function

 

4. Getting the average usage of all hard drives in percent

function Main

strHostAddr = "%A"
strLogin = ""
strPassword = ""
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objSWbemLocator.ConnectServer(strHostAddr, "root\cimv2", strLogin, strPassword)
Set colItems = objWMIService.ExecQuery("SELECT PercentIdleTime FROM Win32_PerfFormattedData_PerfDisk_PhysicalDisk where Name='_Total'",,48)
For Each objItem in colItems
Main = 100 - (int(objItem.PercentIdleTime))
Next
end function

 

5. Executing a GET or POST request (using HTTP). You can use this as an action in response on a failed alert.

function Main
Dim o
Set o = CreateObject("MSXML2.XMLHTTP")
o.open "GET", "https://send.cpsms.dk/sendsms?to:79991234567?from:79991234567?msg:test", False
o.send
Main = ""
end function

6. Sending a message to Slack via webhook URL (using the POST request example)

function Main
Dim request
Set request = CreateObject("MSXML2.XMLHTTP")
request.open "POST", "https://hooks.slack.com/services/AJHGK45J4/FTS5NFG73/UDz30ftMMzinOgFxhTx2zBBB", false
request.send "{""text"": ""It is a test! ""}"
Main = ""
end function

 

Requirements: Windows XP/Vista/7/8.1/10/11, Server 2003/2008/2012/2016/2019/2022 supported.

 

All products
network inventory program
Network Inventory Explorer
Inventory Hardware and Software on Network Computers
network monitoring program
Network Monitor
Monitor Network Servers, Services, Managed Switches, etc.
visual network mapper and monitor
LANState
Monitor and Manage Network Hosts on a Visual Map, Create Network Maps
bandwidth monitoring program
Bandwidth Monitor
Monitor Network Bandwidth and the Internet Traffic Usage
network diagramming program
Network Diagram
Create Network Diagrams, Discover Network Topology
file searching program for network shares and FTP
Network File Search
Search Files on Network Shares and FTP Servers
share access monitoring program
Connection Monitor
Audit Remote User Access to Shares (Folders and Files)
free port scanner
Network Scanner (NEW!)
Free Program for Scanning Networks, Hosts, and TCP Ports