Archived community.zenoss.org | full text search
Skip navigation
10938 Views 12 Replies Latest reply: Aug 23, 2012 11:59 PM by kiiwii RSS
zarxcky Rank: White Belt 77 posts since
Apr 15, 2008
Currently Being Moderated

Sep 7, 2008 6:10 PM

How to reset IP using zendmd?

Hello,

Been searching answer for this for quite a while and nobody seem to answer it within this forum so I think I should create new topic for this.

Can anyone enlighten me on how to reset device IP using zendmd or event transform or in any other programmatically way instead of using Web UI (Device -> More -> Manage IP). I will need to do this for <100 servers, so looking for another way than the UI way apparently..

Thanks in advance.
  • slmiller Rank: White Belt 53 posts since
    Jun 27, 2008
    Currently Being Moderated
    1. Sep 7, 2008 10:20 PM (in response to zarxcky)
    How to reset IP using zendmd?
    Take a look at this:
    http://www.zenoss.com/community/docs/howtos/scotts-batch-loader

    This is a way to load the servers into zenoss, and as part of that, I'm setting the manageIP property of each server, so, I assume you could change the manageIP property in the same way. Create a text file with this format: server, current IP, new IP and then modify that script to fix the addresses for you...


    -Scott

    On Sun, Sep 7, 2008 at 5:10 PM, zarxcky <z4rxcky@yahoo.co.uk ([email]z4rxcky@yahoo.co.uk[/email])> wrote:

     

     

    Hello,

    Been searching answer for this for quite a while and nobody seem to answer it within this forum so I think I should create new topic for this.

    Can anyone enlighten me on how to reset device IP using zendmd or event transform or in any other programmatically way instead of using Web UI (Device -> More -> Manage IP). I will need to do this for <100 servers, so looking for another way than the UI way apparently..

    Thanks in advance.







    _______________________________________________
    zenoss-users mailing list
    zenoss-users@zenoss.org ([email]zenoss-users@zenoss.org[/email])
    http://lists.zenoss.org/mailman/listinfo/zenoss-users

  • Chet Luther ZenossEmployee 1,302 posts since
    May 22, 2007
    Currently Being Moderated
    3. Sep 8, 2008 8:09 AM (in response to zarxcky)
    How to reset IP using zendmd?
    On Sep 8, 2008, at 1:30 AM, zarxcky wrote:

     

     

    Sorry for typo on my first post. Instead of More -> Manage IP, the
    post should say Manage -> Reset IP.

    Thanks for quick reply. And your scripts kind of promising too. But
    then, I was looking for ways to emulate the UI way to reset the IP
    to get new one from DNS, but within command line or python scripts,
    since the devices I am monitoring now use dynamic line which get
    their dynamic IP from ISP. The device currently run ddclient which
    will updating the IP changes to the dyndns.org server name that I
    have created before.

    Every time the dynamic IP changes, the device send event 'ip <ip
    number> has down' to Zenoss server, and the way I always did to
    clear that event out is through UI, which is:

    1- Go to device page
    2- Click Manage -> Reset IP
    3- Leave blank to use DNS (which will get new IP from DNS)
    4- Go to Device Events & Acknowledge/push the red alert events to
    history
    5- Push changes
    6- Remodel the device.

    But for < 100 servers run on dynamic IP and increasing, I wish there
    are far more practical way to do that..

    Not really good in Python, so struggling a bit to get this thing done.
    I bet the keys is within the zendmd, So first thing on my list to
    emulate in zendmd is the 2nd and 3rd step shown above which will be
    Click Manage -> Reset IP & Leave blank to use DNS. How to emulate
    that in zendmd..

    Will play a lot more with zendmd, but I welcome those who can help
    with this problem.

    Thanks Scott, will study your code and perhaps tweak little bit here
    and there if you wont mind.


    If you run the setManageIp method of a device with no parameters it
    will use DNS to figure it out.

    for d in dmd.Devices.getSubDevices():
    d.setManageIp()

    commit()

    Be aware that this will blank out the IP address for devices that
    can't be resolved with DNS. You may want to do the following
    afterwards to find any devices with a blank manageIp so that you can
    get them added to DNS.

    pprint([ d.id for d in dmd.Devices.getSubDevices() if d.manageIp ==
    "" ])
    _______________________________________________
    zenoss-users mailing list
    zenoss-users@zenoss.org
    http://lists.zenoss.org/mailman/listinfo/zenoss-users
  • Chet Luther ZenossEmployee 1,302 posts since
    May 22, 2007
    Currently Being Moderated
    5. Sep 9, 2008 9:18 AM (in response to zarxcky)
    How to reset IP using zendmd?
    On Sep 9, 2008, at 5:18 AM, zarxcky wrote:

     

     

    The pointer that you gave me really helpful. Following this link:
    http://www.zenoss.com/community/docs/zenoss-api-docs/2.2/, I now
    manage to identify the steps that should be taken within zendmd.

    Testing with one device first:

    Manual UI way:
    1- Go to device page
    2- Click Manage -> Reset IP & Leave blank to use DNS (which will get
    new IP from DNS)
    3- Go to Device Events & Acknowledge/push the red alert events to
    history
    4- Clear Heartbeats
    5- Push changes
    6- Remodel the device.

    Zendmd way:
    1- find('clf*')
    Returns:
    <Device at /zport/dmd/Devices/Server/Dumas/devices/
    clfantasy.dyndns.org>

    d = find('clf*')

    2- d.getManageIp()
    'xx.xx.2.183' <--- OLD IP
    d.setManageIp()
    'xx.xxx.48.189' <--- NEW IP from DNS

    commit()

    3- I dont see what class should I used to push red alert event down
    to history, perhaps the Zen Master could enlighten me on this one.
    [Wink]


    Now you're really getting into it.

    evids = [ e.evid for e in dmd.ZenEventManager.getEventListME(d) ]
    dmd.ZenEventManager.manage_deleteEvents(evids)

     

     

    4- Clear Heartbeats


    dmd.ZenEventManager.clearHeartbeats()

     

     

    5- Push changes
    d.pushConfig()

    6- Remodel the device.
    d.collectDevice()

    Refreshing my zenoss page, I can see the the IP has change,
    everything green coming back again EXCEPT the red alert event still
    inside the Event tab since I haven't do anything about that one
    inside the zendmd.

    Thanks Chet!! Really appreciate it.. If only you can tell me what
    class to use to push the red event down to history... that will make
    much more cool! I start to like zendmd now..

    Okay, with my limited knowledge in Python, I will now try to write
    some script for mass-resetting devices DNS.. [Idea]

    _______________________________________________
    zenoss-users mailing list
    zenoss-users@zenoss.org
    http://lists.zenoss.org/mailman/listinfo/zenoss-users
  • chduncan Rank: White Belt 6 posts since
    Apr 10, 2008
    Currently Being Moderated
    8. May 11, 2009 5:37 PM (in response to zarxcky)
    RE: mass-DNS-resetter.py
    i really need to query on a given ip, check to ensure that its the current managedip for that device and if so set a new mgmt ip

    also the devices are not in dns

    any ideas?
  • chduncan Rank: White Belt 6 posts since
    Apr 10, 2008
    Currently Being Moderated
    10. May 13, 2009 6:18 PM (in response to zarxcky)
    RE: Refer to API doc
    Thank you i have a working script now to change the ManagedIp.

    I'm having problems renaming a device in zendmd I should be able to do the like this it think? Python/Programming newbie so i'm learning

    find('router')
    <results returned>
    renameDevice('router2')
    commit()
  • kiiwii Newbie 1 posts since
    Aug 4, 2010
    Currently Being Moderated
    12. Aug 23, 2012 11:59 PM (in response to zarxcky)
    Re: mass-DNS-resetter.py

    great !!! men!

     

    Consider the former ip may not that quitely be assigned to some other machine that allows ping and snmp.

    (even worse like that, some specific http service should come into consideration.)

    and since the event related to dynamic ip change should have the eventclass of "/Status/Ping".

    I made some modification base on your script, as follow, which I think makes more sense:

     

     

     

    #!/usr/bin/env python
    import Globals
    from Products.ZenUtils.ZenScriptBase import ZenScriptBase
    from transaction import commit
    
    
    dmd = ZenScriptBase(connect=True).dmd
    
    
    for d in dmd.Devices.getSubDevices():
    ## if you have them grouped
    #for d in getattr(dmd.Groups, 'Group name').getSubDevices():
        for e in dmd.ZenEventManager.getEventListME(d):
            if e.eventClass == "/Status/Ping" or e.eventClass == "/Status/Snmp":
                d.setManageIp()
                commit()
    
    
                dmd.ZenEventManager.manage_ackEvents(e.evid)
                dmd.ZenEventManager.manage_deleteEvents(e.evid)
                commit()
    
    
                dmd.ZenEventManager.manage_clearHeartbeats()
                commit()
    
    
                d.checkRelations(repair=True)
                commit()
    
    
                d.pushConfig()
                commit()
    
    
                d.collectDevice()
                commit()
    
    

More Like This

  • Retrieving data ...