Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Panel

Table of Contents
maxLevel3

Introduction

As part of 7.2.0.0, Universal Extensions can now be used to extend the Controller's monitoring capabilities through Universal Events and Universal Monitors/Universal Monitor Triggers.

...

  1. Set up the new UE Publisher template.
  2. Add a directory field to the UE Publisher template.
  3. Enhance the UE Publisher's local event template.
  4. Modify the ue-publisher Extension.
  5. Create a task for the UE Publisher template.
  6. Create a Universal Monitor task and trigger.
  7. Run the Universal Monitor Trigger.
  8. Update the local template.json.

Step 1 - Set up the new "UE Publisher" template

Up until now, we have been working with the "UE Task" Universal Template. For this tutorial, we will need to use the "UE Publisher" template that was added to the VS Code Extension and UIP-CLI.

Create a new folder ~/dev/extensions/sample-publisher where the new template will be stored. Navigate to that directory and run the UIP: Initialize New Project command as shown below:

Image RemovedImage Added

On the following prompt, select the "sample-publisher" folder:

Image RemovedImage Added

Then, select the "ue-publisher" starter template:

Image RemovedImage Added

In the following prompts that are used to configure the template, everything can be kept as is. Note the
"UE Publisher" template has an additional option called "Local Universal Event name" shown below.

Image RemovedImage Added


Open the ~/dev/extensions/sample-publisher/extension.py if currently not open. Let's examine the file:

...

Now, let's push the extension out to the Controller. Since this is the first time, use the UIP: Push All command:

Image RemovedImage Added

If successful, you should see the "UE Publisher" template in the "Universal Templates" list:

Image RemovedImage Added

Step 2 - Add a directory field to the "UE Publisher" template

Navigate to the Fields tab of the UE Publisher template, and add a new field as shown below:

Image RemovedImage Added

This required field will be used to specify the directory to get the file list of. 

Save the template.

Step 3 - Enhance the "UE Publisher's" local event template

Navigate to the Event Templates tab of the UE Publisher template:

Image RemovedImage Added

Double click the publisher_event entry, and modify it as shown below:

Image RemovedImage Added

A new attribute of type Text called filelist is added which will contain the list of files (formatted as a string) in the directory specified by the directory field added in the last step.

Save the Event Template. 

Step 4 - Modify the ue-publisher extension

Now, we need to enhance ~/dev/extensions/sample-publisher/extension.py to publish the filelist event. Update the file as shown below:

...

Save the changes to extension.py and execute the UIP: Push command as shown below:

Image RemovedImage Added

Recall that the UIP: Push command builds and uploads the Extension zip archive

Step 5 - Create a task for the "UE Publisher" template

Right-click on the navigation tree pane, and click Refresh as shown below:

Image RemovedImage Added

Then under the Services menu, click UE Publisher Tasks under the Integrations section:

Image RemovedImage Added

Create a new task called sample-publisher-task:

Image RemovedImage Added

  • For the directory field, type in a valid path on the system where the selected agent is running

Save the task.

Step 6 - Create a Universal Monitor task and trigger

Now that we have the event publishing logic added, we need to attach the event itself to a Universal Monitor task.

Under the Services menu, click Universal Monitors under the Monitors section as shown below:

Image RemovedImage Added

Create a new Universal Monitor task as shown below:

Image RemovedImage Added

  • Make sure the Event Type is set to Local since the ue_publisher Event Template is (locally) attached to the UE Publisher Universal Template 
  • Make sure the Universal Template is set to UE Publisher
  • Make sure the Event Template is set to Publisher Event (this is the user-friendly name of ue_publisher Event Template)
  • Make sure the Universal Task Publisher is set to sample-publisher-task
  • Make sure there is an entry for Filelist as shown above. As you may have guessed, this Universal Monitor task will check if Filelist contains test.txt

...

Under the Services menu, click Universal Monitor Triggers under the Triggers section. Create a new trigger as shown below:

Image RemovedImage RemovedImage AddedImage Added

The trigger above will launch the Sleep 0 task when the sample-monitor-task's specified criteria is matched.

Save the trigger.

Step 7 - Run the Universal Monitor Trigger

We are finally ready to see the event functionality in action. Navigate to the sample-monitor-trigger, right-click on it, and select Enable:

Image RemovedImage Added

Clicking Enable will launch the sample-monitor-task and sample-publisher-task. To see this, go to the Instances tab of the sample-monitor-trigger. You should see the following:

Image RemovedImage Added

The sample-publisher-task is sending an event every 5 seconds with the filelisting. Since we haven't created the test.txt file in the specified directory, the Sleep 0 task isn't triggered yet.

In your specified directory, create the test.txt file. After about 5 seconds, click the Refresh icon in the Instances tab of the sample-monitor-trigger, and you should see the following:

Image RemovedImage Added

If you delete the test.txt file and create it again, the Sleep 0 Timer task should be launched again by the trigger.

Step 8 - Update the local template.json

Throughout the tutorial, we modified the Universal Template several times. Recall that inside ~/dev/extensions/sample-publisher/src/templates, there is a template.json file. This file should correspond to the Universal Template in the Controller. 

Right now, they are not both the same. To grab those changes, use the pull command as shown below:

UIP VS Code Extension

Image RemovedImage AddedImage Removed

Image Added

Expand
titleClick here to expand uip-cli details...

Step Supplemental - CLI

Image RemovedImage Added


Now, both the local and Controller's version of the Universal Template are the same.

...