Archived community.zenoss.org | full text search
Skip navigation
17664 Views 9 Replies Latest reply: Mar 19, 2010 11:44 PM by guyverix RSS
kalahari875 ZenossMaster 72 posts since
Oct 16, 2007
Currently Being Moderated

Jan 21, 2008 8:56 AM

Search for event transform statements?

We've been customizing our event class mappings quite a bit. I remember putting a particular Python expression on the Transform (on the event class, drop-down arrow menu | More| Transform) page of an event class, but I can't remember which one.

Is there any way to find the event classes for which we've supplied transform expressions, or search for a particular expression?
  • Chet Luther ZenossEmployee 1,302 posts since
    May 22, 2007
    Currently Being Moderated
    1. Jan 21, 2008 10:41 AM (in response to kalahari875)
    RE: Search for event transform statements?

     

     


    We've been customizing our event class mappings quite a bit. I remember putting a particular Python expression on the Transform (on the event class, drop-down arrow menu | More| Transform) page of an event class, but I can't remember which one.

    Is there any way to find the event classes for which we've supplied transform expressions, or search for a particular expression?



    You could do the following in zendmd:

    
    >>> for ec in dmd.Events.getSubOrganizers():
    ...     if ec.transform:
    ...         print ec.getOrganizerName()
    
  • nemo Rank: White Belt 12 posts since
    Mar 17, 2008
    Currently Being Moderated
    2. Apr 18, 2008 8:59 AM (in response to Chet Luther)
    RE: Search for event transform statements?
    Very handy, thx !
  • mserencha Newbie 3 posts since
    Oct 20, 2009
    Currently Being Moderated
    3. Mar 16, 2010 10:39 AM (in response to Chet Luther)
    Re: RE: Search for event transform statements?

    I  am looking to inspect hundreds of mapping transforms for specific text.  Extending Chet's solution above:

     

       for ec in dmd.Events.getSubOrganizers():

           if( ec.transform and ( ec.transform.find( 'TEXT-TO-FIND' ) >=0 ) ):

               print ec.getOrganizerName()

     

    This is  great for finding forgotten transforms defined on Event Classes, but  what about transforms defined in Event Class Mappings? In zendmd, you  can inspect a single mapping transform directly at (e.g.):

     

         dmd.Events.Event.Class.Path.instances.mappingName.transform

     

    but I have  been playing with zendmd for a while and I am stuck on how to iterate  down this far and check ALL mappings for ALL event classes.

     

    I'm probably  missing something that is obvious to a Python guru (which I am not) and  I am guessing that I am working a problem that has been solved already.  Does anyone in the community have a code fragment that can do what I am  trying to do?

     

    Thanks,

    --Mark

  • phonegi Rank: Brown Belt 446 posts since
    Apr 15, 2009
    Currently Being Moderated
    4. Mar 16, 2010 8:12 PM (in response to mserencha)
    Re: RE: Search for event transform statements?

    Try this:

     

    for subclass in dmd.Events.getSubEventClasses():

       if subclass.transform:

          print subclass.getOrganizerName() + ':\n\n'

          print subclass.transform + '\n\n'

     

    It will print all the EventClass transforms except the one for Events itself, which I figure you can get on your own.

  • mserencha Newbie 3 posts since
    Oct 20, 2009
    Currently Being Moderated
    5. Mar 17, 2010 3:51 PM (in response to phonegi)
    Re: RE: Search for event transform statements?

    Persistence pays off, I figured this out:

    #
    # Print all event class mappings (not event classes) that have transforms with specific text in them:
    #
    for ec in dmd.Events.getSubEventClasses():
        for mapping in ec.instances():
            if mapping.transform and mapping.transform.find('TEXT-TO-FIND')>=0:
                print mapping.absolute_url_path()

    Thanks for your suggestion, phongi!  --Mark S

  • guyverix ZenossMaster 846 posts since
    Jul 10, 2007
    Currently Being Moderated
    6. Mar 19, 2010 6:36 AM (in response to phonegi)
    Re: RE: Search for event transform statements?

    phonegi wrote:

     

    Try this:

     

    for subclass in dmd.Events.getSubEventClasses():

       if subclass.transform:

          print subclass.getOrganizerName() + ':\n\n'

          print subclass.transform + '\n\n'

     

    It will print all the EventClass transforms except the one for Events itself, which I figure you can get on your own.

    How would you be able to use this in getting a dump of every transform on the server?  I have been attempting to use this to retrieve everything, and it is not going well..  Grin..

  • phonegi Rank: Brown Belt 446 posts since
    Apr 15, 2009
    Currently Being Moderated
    7. Mar 19, 2010 10:22 AM (in response to guyverix)
    Re: RE: Search for event transform statements?

    OK, here try this attached file. It will print ALL the transforms from a given starting point, just login as zenoss and execute

    python printTransforms.py [path]

     

    use the following for info:

    python printTransforms -h

    or

    python printTransforms --help

    Attachments:
  • Matt Ray Rank: Zen Master 2,484 posts since
    Apr 5, 2008
    Currently Being Moderated
    8. Mar 19, 2010 2:21 PM (in response to phonegi)
    Re: RE: Search for event transform statements?

    Is this the same as the report in the Event Transforms Report ZenPack?

  • guyverix ZenossMaster 846 posts since
    Jul 10, 2007
    Currently Being Moderated
    9. Mar 19, 2010 11:44 PM (in response to Matt Ray)
    Re: RE: Search for event transform statements?

    Matt Ray wrote:

     

    Is this the same as the report in the Event Transforms Report ZenPack?

    Somehow the word Doh! comes to mind..  I totally forgot about that ZenPack...  Yes, that is exactly what I needed.

More Like This

  • Retrieving data ...