Panel | ||||
---|---|---|---|---|
|
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. Specifically, the Universal Extension API has been enhanced to supported publishing events using the publish method from the event module.
...
- Set up the new UE Publisher template
- Add a directory field to the UE Publisher template
- Enhance the UE Publisher's local event template
- Modify the ue-publisher Extension
- Create a task for the UE Publisher template
- Create a Universal Monitor task and trigger
- Run the Universal Monitor Trigger
- 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:
On the following prompt, select the "sample-publisher" folder:
Then, select the "ue-publisher" starter template:
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.
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:
If successful, you should see the "UE Publisher" template in the "Universal Templates" list:
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:
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:
Double click the publisher_event entry, and modify it as shown below:
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:
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:
Then under the Services menu, click UE Publisher Tasks under the Integrations section:
Create a new task called sample-publisher-task:
- 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:
Create a new Universal Monitor task as shown below:
- 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:
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:
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:
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:
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
Expand | ||
---|---|---|
| ||
Step Supplemental - CLI |
Now, both the local and Controller's version of the Universal Template are the same.
...