/monitoringappschedulerexamples.htm" />

Please enable JavaScript to view this site.

The following scripts can be used by the applications scheduler and will return an error code depending on whether they ran successfully or not. Variables that need to be adjusted are highlighted in green below. All examples below use Visual Basic Script. Additional example scripts are available in the Scripts sub folder of the EventSentry installation directory.

 

info_24

This script counts the number of files in a folder and can return 1 if the number of files exceeds a threshold.

' ----------------------

' --- file_count.vbs ---

' ----------------------

' Counts the number of files in a folder (without traversing subfolders)

'

' Returns 1 if the number of files is larger than MyLimit or 0 if the number

' of files is equal or less than MyLimit

 

Dim FS, FO, FC

Dim MyFolder, MyLimit

 

' Set your values here

MyFolder        = "C:\Batch"

MyLimit        = 200

 

Set FS = CreateObject("Scripting.FileSystemObject")

Set FO = FS.GetFolder(MyFolder)

Set FC = FO.Files

 

WScript.Echo "Folder " & MyFolder & " contains " & FC.Count & " files."

 

If FC.Count > MyLimit Then

 WScript.Quit(1)

Else

 WScript.Quit(0)

End If

 

info_32

This script enumerates all fans in the system that can be monitored through WMI (if supported). If one or more of the monitored fans report a status other than "Other", "Unknown" or "Running", then the script will return 1.

' --------------------------

' --- system_faninfo.vbs ---

' --------------------------

On Error Resume Next

Dim GlobalError

 

GlobalError = 0

 

Function ExplainAvailability(Availability)

 Select Case Availability

         Case 1:  ExplainAvailability = "Other"

         Case 2:  ExplainAvailability = "Unknown"

         Case 3:  ExplainAvailability = "Running / Full Power"

         Case 4:  ExplainAvailability = "Warning"

         Case 5:  ExplainAvailability = "In Test"

         Case 6:  ExplainAvailability = "Not Applicable"

         Case 7:  ExplainAvailability = "Power Off"

         Case 8:  ExplainAvailability = "Off Line"

         Case 9:  ExplainAvailability = "Off Duty"

         Case 10: ExplainAvailability = "Degraded"

         Case 11: ExplainAvailability = "Not Installed"

         Case 12: ExplainAvailability = "Install Error"

         Case 13: ExplainAvailability = "Power Save - Unknown"

         Case 14: ExplainAvailability = "Power Save - Low Power Mode"

         Case 15: ExplainAvailability = "Power Save - Standby"

         Case 16: ExplainAvailability = "Power Cycle"

         Case 17: ExplainAvailability = "Power Save - Warning"

 End Select

End Function

 

Function ExplainStatus(Status)

 Select Case Status

         Case 1: ExplainStatus = "Other"

         Case 2: ExplainStatus = "Unknown"

         Case 3: ExplainStatus = "Enabled"

         Case 4: ExplainStatus = "Disabled"

         Case 5: ExplainStatus = "Not Applicable"

 End Select

End Function

 

strComputer = "."

Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

 

Set colItems = objWMIService.ExecQuery("Select * from Win32_Fan")

 

For Each objItem in colItems

   Wscript.Echo "Name:           " & objItem.Name

   Wscript.Echo "Active Cooling: " & objItem.ActiveCooling

   Wscript.Echo "Availability:   " & ExplainAvailability(objItem.Availability) & " (" & objItem.Availability & ")"

   Wscript.Echo "Device ID:      " & objItem.DeviceID

   Wscript.Echo "Status Info:    " & ExplainStatus(objItem.StatusInfo) & " (" & objItem.StatusInfo & ")"

   Wscript.Echo

   

   ' Analyze

   If objItem.Availability > 3 Then

         GlobalError = 1

   End If

Next

 

Wscript.Quit(GlobalError)