The Universal Check
Since version 3.0 PC-Check has a new check type: The universal check.
What can the Universal check do?
The universal check is able to execute any command line command and to evaluate and display the result. Whether simple operating system commands, chaining of commands, batch, VBS or PowerShell files: The universal check checks everything.
Simply specify which command is to be executed and which text is expected. Here you can use a normal text or a regular expression. You can even determine which text is displayed in the PC-Check client in the positive case (green) and in the negative case (red).
Examples
Example 1: Use the "dir" command to check if a file exists
Example 2: Use the "netsh" command to check if a certain WLAN is available
Example 3: Use a VBScript to check the age of a log file
Example 1: Using the dir command to check whether a file exists.
This task could also be solved with the check "File exists", but only in a fixed directory. We want to check if the file is located in a directory or in one of its subdirectories. So use the "dir /s" command, which also shows files in subdirectories.
We check for the presence of the file MyFile.txt in the directory C:\MyData and all subdirectories. If the file exists, the PC-Check Client should show "File exists" (green). If it doesn't exist, it should display "File missing" (red).
To do this, create a new universal check in PC-Check Designer and configure it as follows:
The result in the PC-Check client is as expected:
If the file exists, the text "File exists" appears. If it does not exist, the red X appears with the text "File missing".
Example 2: Using the netsh command to check whether a specific WLAN is available
We want to check whether the WLAN with the SSID "Production_WLAN" is available. If it is available, the PC-Check client should display "WLAN available" (green). If it is not available, it should display "WLAN missing" (red).
To display a list of all available WLANs, use the netsh wlan show networks command. This will give you an output like this:
Create a new universal check in PC-Check designer and configure it as follows:
Title: Production WLAN available
Command: netsh wlan show networks
Expected text: Production_WLAN
Alternate OK text: WLAN available
Alternative error text: WLAN missing
This is what the result looks like if the WLAN is available:
If you want to check whether at least one of two WLANs is present, you can use the OR operation. If the check is to be considered successful if at least one of the WLANs "Production_WLAN" and "Company_WLAN" is available, use the expression Production_WLAN||Company_WLAN for Expected text.
Example 3: Using a VBScript to check the age of a log file
We want to make sure that a log file is not older than 5 minutes. More precisely, we look at the modification date (LastModified) of the Application.log file. If the file was modified within the last 5 minutes, the PC-Check client should display the file age and a green OK message. If the file is older (or does not exist), it should display a red error message.
We use a small VBScript FileAge.vbs for this. You can put the script centrally in the network (%files% folder) or on the computers where it is needed. We put it in the %files% folder. This is the files folder in your ConfigShare share, which is synchronized with the local client every time PC-Check is started. Locally, the files are then located under %appdata%\PC-Check\Files.
Create a new universal check in PC-Check designer and configure it as follows:
Title: Application.log file up to date
Command: cscript /nologo "%appdata%\PC-Check\Files\FileAge.vbs" "C:\Application\Application.log" 5
Expected text: File is up to date
Alternative OK text: %output%.
Alternative error text: %output%
The VBScript prints the age of the file in minutes and the text "File is up to date" or "File is old". By using the variables %output% in the OK text and in the error text, the PC-Check Client displays the file age as the result.
The VBScript:
' Syntax:
' cscript /nologo FileAge.vbs <fileName> <file age in minutes>.
MyFilename = WScript.Arguments(0)
MyAgeInMinutes = CInt(WScript.Arguments(1))
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(MyFilename) Then
WScript.Echo "File is missing".
WScript.Quit
End If
Set MyFile = fso.GetFile(MyFilename)
diff = DateDiff("n", MyFile.DateLastModified, Now) ' n = minutes
If diff >= MyAgeInMinutes Then output = diff & " Minute(n) --> file is old".
If diff < MyAgeInMinutes Then output = diff & " Minute(n) --> file is up to date".
WScript.Echo output
This is what the result looks like if the file was modified less than 5 minutes ago:
The use of scripts of all kinds allows you to check and visualize any condition with PC-Check.
If you get stuck at any point: Ask us, we will help you --> Contact