Newsletter:2/Event Transforms More Than Meets The Eye
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.”
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!
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?
- Login to the Zenoss Web UI
- Click on the Events tab
- Click Event Classes
- Click on the desired SubClasses (e.g. /Unknown)
- Click on the Action Menu → Transform
- Enter the Python code → Save
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"
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