Difference between revisions of "Newsletter:2/Event Transforms More Than Meets The Eye"

From Zenoss Wiki
Jump to: navigation, search
Line 1: Line 1:
 
{{Article
 
{{Article
 +
 
|Author=Hydruid
 
|Author=Hydruid
 +
 
|Abstract=Transforms allow an event to be manipulated, to achieve a desired result. In layman's terms this means that if an event matches the criteria specified, the preset “manipulation” will be applied. The definition of a transform, directly from the Zenoss Core Administration PDF, “Transform - Takes Python code that will be executed on the event only if it matches this mapping.”
 
|Abstract=Transforms allow an event to be manipulated, to achieve a desired result. In layman's terms this means that if an event matches the criteria specified, the preset “manipulation” will be applied. The definition of a transform, directly from the Zenoss Core Administration PDF, “Transform - Takes Python code that will be executed on the event only if it matches this mapping.”
 +
 
|Cover image=Hacking-event-notification.jpg
 
|Cover image=Hacking-event-notification.jpg
 +
 
}}
 
}}
Transforms allow an event to be manipulated, to achieve a desired result. In layman's terms this means that if an event matches the criteria specified, the preset “manipulation” will be applied.  
+
 
 +
Transforms allow an event to be manipulated, to achieve a desired result. In layman's terms this means that if an event matches the criteria specified, the preset “manipulation” will be applied.
  
 
The definition of a transform, directly from the Zenoss Core Administration PDF, “Transform - Takes Python code that will be executed on the event only if it matches this mapping.”
 
The definition of a transform, directly from the Zenoss Core Administration PDF, “Transform - Takes Python code that will be executed on the event only if it matches this mapping.”
Line 13: Line 18:
  
 
===== Whoa...where do I input a transform? =====
 
===== Whoa...where do I input a transform? =====
 +
 
# Login to the Zenoss Web UI
 
# Login to the Zenoss Web UI
 +
 
# Click on the Events tab
 
# Click on the Events tab
 +
 
# Click Event Classes
 
# Click Event Classes
 +
 
# Click on the desired SubClasses (e.g. /Unknown)
 
# Click on the desired SubClasses (e.g. /Unknown)
 +
 
# Click on the Action Menu → Transform
 
# Click on the Action Menu → Transform
 +
 
# Enter the Python code → Save
 
# Enter the Python code → Save
  
 
===== Create a transform =====
 
===== Create a transform =====
A transform that matches the beginning text of an event's summary and performs a desired action.
 
  
<br />Filter events to get a match
+
A transform that matches the beginning text of an event's summary and performs a desired action.
if evt.summary.startswith(“Some Text”)
+
+
<br />Perform desired action
+
if evt.summary.startswith(“Some Text”)
+
    evt._action = “drop”
+
  
 +
<br />Filter events to get a match and perform the desired action
 +
 +
if evt.summary.startswith(“Some Text”)
 +
 +
evt._action = “drop”
  
 
== Conclusion ==
 
== Conclusion ==
Line 36: Line 46:
  
 
{{ArticleFooter}}
 
{{ArticleFooter}}
 +
 
{{ArticleFooter}}
 
{{ArticleFooter}}

Revision as of 18:17, 25 September 2013

Event Transforms More Than Meets The Eye

Transforms allow an event to be manipulated, to achieve a desired result. In layman's terms this means that if an event matches the criteria specified, the preset “manipulation” will be applied. The definition of a transform, directly from the Zenoss Core Administration PDF, “Transform - Takes Python code that will be executed on the event only if it matches this mapping.”
Hacking-event-notification.jpg


Transforms allow an event to be manipulated, to achieve a desired result. In layman's terms this means that if an event matches the criteria specified, the preset “manipulation” will be applied.

The definition of a transform, directly from the Zenoss Core Administration PDF, “Transform - Takes Python code that will be executed on the event only if it matches this mapping.”

The Basics

Now that we're past the ever intriguing technical definitions, let us experience the power and versatility of transforms with a few examples!

Whoa...where do I input a transform?
  1. Login to the Zenoss Web UI
  1. Click on the Events tab
  1. Click Event Classes
  1. Click on the desired SubClasses (e.g. /Unknown)
  1. Click on the Action Menu → Transform
  1. Enter the Python code → Save
Create a transform

A transform that matches the beginning text of an event's summary and performs a desired action.


Filter events to get a match and perform the desired action

if evt.summary.startswith(“Some Text”)

evt._action = “drop”

Conclusion

This article introduced you to the basics on how to create a transform. Transforms are a key element to managing your events and generating notifications. They will save you a lot of time and headaches! See the following link for more advanced examples! Category:Transforms