How do I use or configure caWmiAgent to monitor a Scheduled Job or Task in Windows?

Document ID : KB000054810
Last Modified Date : 14/02/2018
Show Technical Document Details

Description:

The caWmiAgent can be used to monitor Windows WMI Resources, such as files, scheduled tasks, processes, and so forth. You must first identify those jobs that were created using the AT command, and then add a watcher in Agent Technology. For more information about the agent-specific options of caWmiAgent, see the guide Inside Systems Monitoring , which you can find either on the product media or online at
https://support.ca.com/irj/portal/DocumentationResults?productID=130639&releaseID=ALL&languageID=ENU&actionID=2

Solution:

You can configure caWmiAgent to monitor Windows Scheduled Jobs if the jobs or tasks are created using AT command.

Note: If a Task was created manually from Control Panel -> Scheduled Tasks, the WMI agent cannot recognize it. See below for information on how to monitor the status of these tasks.

To run a WMI query to see all the Scheduled Jobs

  1. From the Desktop, select Start,
    The Run dialog appears.

  2. Enter WBEMTest and click OK.
    The Windows Management Instrumentation Tester window appears.

  3. Click Connect.
    The Connect window appears.

    Figure 1

  4. Enter the following for the first field Namespace and then click Connect:
    root\CIMV2
    The Windows Management Instrumentation Tester appears again.

    Figure 2

  5. Under the IWbemServices section, click Query.
    The Query dialog appears.

    Figure 3

  6. Enter the following WMI Query to list all Scheduled Jobs/Tasks
    select * from Win32_ScheduledJob

  7. Click Apply.
    The query displays all the Jobs that were created using AT command only.

    Figure 4

To monitor the Status of a Job created using the AT command

  1. Go to %AGENTWORKS_DIR%\AGENTS\BIN.

  2. Double-click cawmicnf.exe, enter ?Username = caunint' and provide the password.

  3. Launch Agent View for WMI Agent from the 2D Map, from Management Command Center (MCC), or from Node View.

  4. From the WMI Watcher interface, click Add Watcher.

  5. Enter the following details, and then click Apply to finish.
FieldEntry
Watcher NameTestJob
NameSpaceroot\cimv2
Class NameWin32_ScheduledJob
Where ClauseJobId=7
(Specifies the JobId you want to monitor)
Property NameJobStatus
(Click Property List to select a Property)
ExistsShould Exist
(Action: Down Critical)
String MatchSuccess
(Action: Down Critical)

Note: String Match indicates the WMI property value which is returned by the WQL query.

Figure 5

The Watcher will query against ?JobId=7? (example: select JobStatus from Win32_ScheduledJob where JobId=7). If the Watcher returns Success (Job Status is Success), then the Watcher status will be Normal; if the Watcher returns Fail, then the Watcher status will show Critical status.

To monitor Scheduled Jobs created from Control Panel -> Scheduled Tasks

Scheduled Jobs or Tasks created manually cannot be found by WMI. Therefore, the caWmiAgent cannot monitor a Job property such as Status. However, Microsoft's Scheduled Tasks writes its results to a file : %SystemRoot%\SchedLgU.Txt.

With this text file you can use the Log Agent (caiLogA2) to monitor that file for certain job failures or errors.

For more information about how to use the Log Agent, see the chapter Monitoring System Resources in Inside Systems Monitoring.