Discussion:
Basic transform issue
themactech
2012-10-11 13:21:59 UTC
Permalink
themactech [http://community.zenoss.org/people/themactech] created the discussion

"Basic transform issue"

To view the discussion, visit: http://community.zenoss.org/message/69021#69021

--------------------------------------------------------------
I want to do the following transform to drop traps from devices in 'maintenance' mode, but this transform causes the zenactions daemon to quit:

if dev.productionState == 300:
          evt._action = "drop"

Is there something wrong in my syntax?

Manuel
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/69021#69021]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Ryan Matte
2012-10-12 09:10:35 UTC
Permalink
Ryan Matte [http://community.zenoss.org/people/rmatte] created the discussion

"Re: Basic transform issue"

To view the discussion, visit: http://community.zenoss.org/message/69074#69074

--------------------------------------------------------------
Try this instead...

if evt.prodState == 300:
    evt._action = 'drop'
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/69074#69074]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
jcurry
2012-10-12 09:31:32 UTC
Permalink
jcurry [http://community.zenoss.org/people/jcurry] created the discussion

"Re: Basic transform issue"

To view the discussion, visit: http://community.zenoss.org/message/69077#69077

--------------------------------------------------------------
Works for me.  Any odd non-printing characters around?  I have used both 'history' and 'drop' actions and both work.  Here is a bit of a combination:

evt.myMappingSummary = "Event class mapping summary " + evt.mySummary
if dev.productionState == 300:
  evt.myAction = 'historify it'
  evt._action = 'drop'

First line is just something I had there anyway.  If you use 'history' rather than 'drop' then you can see it gets closed status (I tested on 4.2).  If you use drop then it vanishes.  The dev.productionState == 300 works fine for me.

Cheers,
Jane
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/69077#69077]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Ryan Matte
2012-10-12 12:10:52 UTC
Permalink
Ryan Matte [http://community.zenoss.org/people/rmatte] created the discussion

"Re: Basic transform issue"

To view the discussion, visit: http://community.zenoss.org/message/69101#69101

--------------------------------------------------------------
Are you actually using 10 spaces as you indentation, or are you using tab?  The recommended indentation is 4 spaces (to make it more readable) or you can use single spaces too.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/69101#69101]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
themactech
2012-10-12 13:48:09 UTC
Permalink
themactech [http://community.zenoss.org/people/themactech] created the discussion

"Re: Basic transform issue"

To view the discussion, visit: http://community.zenoss.org/message/69106#69106

--------------------------------------------------------------
Neither work, here is the log from zenactions (the zenaction daemon stops and won't start).

2012-10-12 09:40:54,305 WARNING zen.Events: Error processing transform/mapping on Event Class /
Problem on line 0: AttributeError: 'NoneType' object has no attribute 'productionState'
if dev.productionState==300:

Transform:
  0 if dev.productionState==300:
  1     evt._action="drop"

2012-10-12 09:41:56,352 WARNING zen.Events: Error processing transform/mapping on Event Class /
Problem on line 0: compile error on line 0
if evt.prodState==300

Transform:
  0 if evt.prodState==300
  1     evt._action='drop'

I think 'AttributeError: 'NoneType' object has not attribute 'productionState' is the key part, but I don't know what defective component it points to.

BTW this is running on 3.1

Manuel
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/69106#69106]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Ryan Matte
2012-10-12 15:36:58 UTC
Permalink
Ryan Matte [http://community.zenoss.org/people/rmatte] created the discussion

"Re: Basic transform issue"

To view the discussion, visit: http://community.zenoss.org/message/69115#69115

--------------------------------------------------------------
You're missing a colon after the if statement that I told you to try.  That's why you're getting a compile error.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/69115#69115]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
themactech
2012-10-12 18:14:53 UTC
Permalink
themactech [http://community.zenoss.org/people/themactech] created the discussion

"Re: Basic transform issue"

To view the discussion, visit: http://community.zenoss.org/message/69133#69133

--------------------------------------------------------------
I've corrected that typo, now I get this error message:

2012-10-12 14:10:02,057 WARNING zen.Events: Error processing transform/mapping on Event Class /
Problem on line 0: AttributeError: Event instance has no attribute 'prodState'
if evt.prodState == 300:

Transform:
  0 if evt.prodState == 300:
  1     evt._action = 'drop'

How can I get an event with no 'prodState' attribute?

Manuel
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/69133#69133]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Ryan Matte
2012-10-12 18:28:24 UTC
Permalink
Ryan Matte [http://community.zenoss.org/people/rmatte] created the discussion

"Re: Basic transform issue"

To view the discussion, visit: http://community.zenoss.org/message/69120#69120

--------------------------------------------------------------
Something I've noticed in Zenoss 4 is that some of the system events come in missing properties.  I've actually been meaning to log a Jira ticket about that.  You'll want to add some validation like...

if hasattr("prodState", evt):
    if evt.prodState == 300:
        evt._action = 'drop'
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/69120#69120]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
themactech
2012-10-12 18:32:36 UTC
Permalink
themactech [http://community.zenoss.org/people/themactech] created the discussion

"Re: Basic transform issue"

To view the discussion, visit: http://community.zenoss.org/message/69134#69134

--------------------------------------------------------------
The saga continues...

2012-10-12 14:29:26,965 WARNING zen.Events: Error processing transform/mapping on Event Class /
Problem on line 0: TypeError: hasattr(): attribute name must be string
if hasattr("prodState",evt):

Transform:
  0 if hasattr("prodState",evt):
  1     if evt.prodState == 300:
  2         evt._action = 'drop'

Manuel
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/69134#69134]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Ryan Matte
2012-10-12 19:35:37 UTC
Permalink
Ryan Matte [http://community.zenoss.org/people/rmatte] created the discussion

"Re: Basic transform issue"

To view the discussion, visit: http://community.zenoss.org/message/69121#69121

--------------------------------------------------------------
Sorry, that's what I get for rushing my reply lol.  I reversed the options.

It should be:

if hasattr(evt, 'prodState'):
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/69121#69121]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
themactech
2012-10-12 20:22:29 UTC
Permalink
themactech [http://community.zenoss.org/people/themactech] created the discussion

"Re: Basic transform issue"

To view the discussion, visit: http://community.zenoss.org/message/69136#69136

--------------------------------------------------------------
BTW this was under zenoss 3.1, but the:

if hasattr(evt,'prodState'):
    if evt.prodState == 300:
        evt._action = 'drop'

did the trick.  I will use this attribute checking step in most of my transforms now, great idea.

Your brain should get preserved in a jar after your passing (which hopefully will take a very long time).

Manuel
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/69136#69136]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Ryan Matte
2012-10-12 20:26:37 UTC
Permalink
Ryan Matte [http://community.zenoss.org/people/rmatte] created the discussion

"Re: Basic transform issue"

To view the discussion, visit: http://community.zenoss.org/message/69122#69122

--------------------------------------------------------------
Thanks :)

Cheers.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/69122#69122]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Loading...