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

Source Code for Module ZenHub.services.SnmpPerfConfig

 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 PerformanceConfig import PerformanceConfig 
15   
16  from sets import Set 
17  from ZODB.POSException import POSError 
18   
19   
20   
21 -class SnmpPerfConfig(PerformanceConfig):
22
23 - def remote_getDevices(self, devices=None):
24 """Return information for snmp collection on all devices.""" 25 if devices: 26 if not isinstance(devices, list): 27 devices = Set([devices]) 28 else: 29 devices = Set(devices) 30 snmp = [] 31 for dev in self.config.devices(): 32 if devices and dev.id not in devices: continue 33 dev = dev.primaryAq() 34 if dev.snmpMonitorDevice(): 35 snmp.append(dev.id) 36 return snmp
37 38
39 - def remote_getDeviceConfigs(self, devices):
40 result = [] 41 for d in devices: 42 device = self.dmd.Devices.findDevice(d) 43 if device: 44 config = device.getSnmpOidTargets() 45 if config: 46 result.append(config) 47 return result
48 49
50 - def remote_getDeviceUpdates(self, devices):
51 """Return a list of devices that have changed. 52 Takes a list of known devices and the time of last known change. 53 The result is a list of devices that have changed, 54 or not in the list.""" 55 lastChanged = dict(devices) 56 new = Set() 57 all = Set() 58 for dev in self.config.devices(): 59 dev = dev.primaryAq() 60 if dev.snmpMonitorDevice(): 61 all.add(dev.id) 62 if lastChanged.get(dev.id, 0) < float(dev.getLastChange()): 63 new.add(dev.id) 64 deleted = Set(lastChanged.keys()) - all 65 return list(new | deleted)
66
67 - def getDeviceConfig(self, device):
68 "Template method helper for PerformanceConfig.pushConfig" 69 return device.getSnmpOidTargets()
70 71
72 - def sendDeviceConfig(self, listener, config):
73 "Template method helper for PerformanceConfig.pushConfig" 74 return listener.callRemote('updateDeviceConfig', config)
75 76
77 - def update(self, object):
78 from Products.ZenModel.RRDDataSource import RRDDataSource 79 if isinstance(object, RRDDataSource): 80 if object.sourcetype != 'SNMP': 81 return 82 83 PerformanceConfig.update(self, object)
84