Package ZenHub :: Package services :: Module PingConfig
[hide private]
[frames] | no frames]

Source Code for Module ZenHub.services.PingConfig

 1  ########################################################################### 
 2  # 
 3  # This program is part of Zenoss Core, an open source monitoring platform. 
 4  # Copyright (C) 2007, Zenoss Inc. 
 5  # 
 6  # This program is free software; you can redistribute it and/or modify it 
 7  # under the terms of the GNU General Public License version 2 as published by 
 8  # the Free Software Foundation. 
 9  # 
10  # For complete information please visit: http://www.zenoss.com/oss/ 
11  # 
12  ########################################################################### 
13   
14  from Products.ZenStatus import pingtree 
15  from Products.ZenHub.services.PerformanceConfig import PerformanceConfig 
16  from Products.ZenHub.PBDaemon import translateError 
17   
18 -class PingConfig(PerformanceConfig):
19 "Support zenping configuration loading" 20 21 @translateError
22 - def remote_getPingTree(self, root, fallbackIp):
23 return self.getPingTree(self.dmd, root, fallbackIp)
24
25 - def getPingTree(self, dmd, root, fallbackIp):
26 pm = dmd.Monitors.getPerformanceMonitor(self.instance) 27 me = pm.findDevice(root) 28 if not me: 29 me = self.lookupByIp(dmd, fallbackIp) 30 if me: 31 self.log.info("building pingtree from %s", me.id) 32 tree = pingtree.buildTree(me) 33 else: 34 self.log.critical("ZenPing '%s' not found, " 35 "ignoring network topology.", 36 root) 37 tree = pingtree.PingTree(fallbackIp) 38 tree.root = pingtree.RouterNode(fallbackIp, root, 0) 39 tree.root.addNet(tree, "default", "default") 40 config = dmd.Monitors.Performance._getOb(self.instance) 41 devices = config.getPingDevices() 42 self.prepDevices(tree, devices) 43 return tree.root
44 45
46 - def getDeviceConfig(self, device):
47 return device
48 49
50 - def lookupByIp(self, dmd, fallbackIp):
51 """Try to find the root device by our IP 52 """ 53 ip = dmd.Networks.findIp(fallbackIp) 54 if ip and ip.device(): 55 return ip.device()
56 57
58 - def prepDevices(self, pingtree, devices):
59 """resolve dns names and make StatusTest objects""" 60 for device in devices: 61 if not pingtree.hasDev(device): 62 pingtree.addDevice(device)
63
64 - def sendDeviceConfig(self, listener, config):
65 return listener.callRemote('updateConfig')
66