Newsletter:2/Event Transforms More Than Meets The Eye

From Zenoss Wiki
< Newsletter:2
Revision as of 18:45, 25 September 2013 by Hydruid (Talk | contribs)

Jump to: navigation, search

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.”

Do you remember Dick from a previous previous Newsletter:1/Hacking_Event_Notifications? Lets help him fight sleep deprivation by using transform to manage his events. We certainly don't want a zombie uprise!

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
  2. Click on the Events tab
  3. Click Event Classes
  4. Click on the desired SubClasses (e.g. /Unknown)
  5. Click on the Action Menu → Transform
  6. Enter the Python code → Save
Basic Transform

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

if evt.summary.startswith(“Some Text”)
   evt._action = “drop”

Examples Dick Can Use

Change an event's Severity for devices in /Network/Switch/Edge (this way he can focus on his Apache httpd server)

if "/Network/Switch/Edge" in getattr(evt, 'DeviceClass', ):
   evt.severity = 2

Change an event's EventClass to /Ignore if the Component contains "Printer" (lets put these somewhere safe to ignore)

if "Printer" in getattr(evt, 'component', ):
   evt.eventClass = "/Ignore"

Conclusion

Whew...all done and hopefully Dick can get a few extra minutes of sleep!

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