Archived community.zenoss.org | full text search
Skip navigation
115803 Views 14 Replies Latest reply: Nov 24, 2009 3:18 PM by Ryan Matte RSS
srhuston Rank: White Belt 60 posts since
Apr 3, 2007
Currently Being Moderated

Nov 17, 2009 3:31 PM

productionState in transform

I've got a transform which is giving me headaches; basically, if a certain trap comes in I want to move the device to maintenance mode (so that other traps which might be coming or might have arrived can be appropriately ignored - a time delay would be on the alert notification).  Eventually I would also fire a clear event that would move it back to production, but the maintenance event is not working anyway:

 

zone = getattr(evt, 'mtrapargsInteger', 0)

if zone == 1:
   evt.component = "block_jumper"
   evt.summary = "Zone #1 Fault - Device in Maintenance"
   if dev.productionState == 1000:
      dev.setProdState(300)

if zone == 2:
   evt.component = "AC8"
   evt.summary = "AC8 Common Alarm"

 

According to applyTransform in $ZENOSS/Products/ZenEvents/EventClassInst.py, 'dev' or 'device' should both map to the device which generated the event, and sure enough the reading of dev.productionState works fine (I tested this by checking for it to be 300, then setting it to Maintenance and verifying that it worked then but not while in Production).  So the only part which is failing - and silently, from what I can tell in the logs - is the dev.setProdState(300) call.

 

I'm currently using 2.5.0, but started trying to make this work while running 2.3.x and upgraded last week in hopes this was a bug that had been fixed.

  • mwcotton Rank: Brown Belt 563 posts since
    Apr 23, 2008
    Currently Being Moderated
    1. Nov 18, 2009 9:26 PM (in response to srhuston)
    Re: productionState in transform

    I dont think you can edit the device from a transform, I dont know if it would be called a bug, its just the way it works

  • jmp242 ZenossMaster 4,060 posts since
    Mar 7, 2007
    Currently Being Moderated
    4. Nov 19, 2009 8:01 AM (in response to srhuston)
    Re: productionState in transform

    I'd add this to the wiki at least.

    --

    James Pulver

    Information Technology Area Supervisor

    LEPP Computer Group

    Cornell University

     

     

     

    srhuston wrote, On 11/19/2009 12:30 AM:

    Found it.

     

    Set on the path that I'd have to do this as an event command, I started looking to see how I could from the command line effect the changes needed.  And I noticed something in the commands listed which looked familiar - a call to "commit()'.  It looked familiar because the EventClassInst.py file lists the objects available to a transform, and one of them is "txnCommit" (mapped to transaction.commit).

     

    Sure enough, adding "txnCommit()" to the block commits the change to the device properly and everything works as originally expected.  So if there's any bug here, it's that there should probably be a mention of this necessity in the documentation.

    >

  • mwcotton Rank: Brown Belt 563 posts since
    Apr 23, 2008
    Currently Being Moderated
    5. Nov 19, 2009 9:01 PM (in response to srhuston)
    Re: productionState in transform

    I am confused, did you successfully do this in the transform or from an event command?

    Either way could you post the code?

  • Ryan Matte ZenossMaster 653 posts since
    Mar 26, 2009
    Currently Being Moderated
    7. Nov 20, 2009 1:46 PM (in response to srhuston)
    Re: productionState in transform
    I remember trying to help you with that transform on IRC, glad you finally got it working.  I've been wrestling with a transform for 2 days now and I'm trying it with txnCommit() now to see if it works.  I tried just standard commit() but it didn't.
  • Ryan Matte ZenossMaster 653 posts since
    Mar 26, 2009
    Currently Being Moderated
    8. Nov 20, 2009 1:59 PM (in response to Ryan Matte)
    Re: productionState in transform

    My transform is:

     

    import Globals
    from Products.ZenUtils.ZenScriptBase import ZenScriptBase
    from transaction import commit


    dmd = ZenScriptBase(connect=True).dmd


    import re


    bsnId = getattr(evt, 'bsnAPName', 'Unknown')
    evt.summary = 'Wireless Interface is UP on %s' % (bsnId)
    for e in dmd.ZenEventManager.getEventList():
      cevt = dmd.ZenEventManager.getEventDetailFromStatusOrHistory(e.evid)
      cbsnId = getattr(cevt, 'bsnAPName', 'Unknown')
      if re.search('Wireless Interface is DOWN', cevt.summary) and re.match(bsnId, cbsnId):
       cevt._action = 'history'

    txnCommit()


    evt.severity = 0
    evt._action = 'history'

     

    It should technically work, but it's not, and the only error in zenhub.log is "error 2" which is colossally unhelpful.

  • mwcotton Rank: Brown Belt 563 posts since
    Apr 23, 2008
    Currently Being Moderated
    9. Nov 20, 2009 5:05 PM (in response to srhuston)
    Re: productionState in transform
    Cool, thanks for the clarification, I am going to give it a shot too  good work!
  • Ryan Matte ZenossMaster 653 posts since
    Mar 26, 2009
    Currently Being Moderated
    10. Nov 20, 2009 5:08 PM (in response to mwcotton)
    Re: productionState in transform
    It didn't work for me, but apparently Zenoss doesn't like the whole dmd.whatever thing done in transforms for whatever reason.  I'll be looking in to it more on Monday.
  • Ryan Matte ZenossMaster 653 posts since
    Mar 26, 2009
    Currently Being Moderated
    12. Nov 20, 2009 5:21 PM (in response to srhuston)
    Re: productionState in transform
    Nah, if I don't define dmd then I get an error in zenhub.log stating that dmd is not defined.  If I define it I get an error of "exit 2", this is a bit ridiculous lol.
  • mwcotton Rank: Brown Belt 563 posts since
    Apr 23, 2008
    Currently Being Moderated
    13. Nov 20, 2009 8:02 PM (in response to srhuston)
    Re: productionState in transform

    WOW thats cool worked for me, this opens up a new world, I had no idea this is possible

    Thanks!!!

  • Ryan Matte ZenossMaster 653 posts since
    Mar 26, 2009
    Currently Being Moderated
    14. Nov 24, 2009 3:18 PM (in response to srhuston)
    Re: productionState in transform

    I found the fix.  dmd in transforms was fixed in 2.5 but I'm still using 2.4.5.  I had to do: "zenpatch 14049" then restart Zenoss.

     

    After that, my transform worked fine without the imports.

More Like This

  • Retrieving data ...

Legend

  • Correct Answers - 4 points
  • Helpful Answers - 2 points