Trees | Indices | Help |
|
---|
|
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 from Products.ZenHub.PBDaemon import translateError 16 17 from sets import Set 18 19 from Products.ZenRRD.zenperfsnmp import SnmpConfig 20 21 import logging 22 log = logging.getLogger('zen.SnmpPerfConfig') 2325 oids = [] 26 if comp.snmpIgnore(): return None 27 basepath = comp.rrdPath() 28 perfServer = comp.device().getPerformanceServer() 29 for templ in comp.getRRDTemplates(): 30 for ds in templ.getRRDDataSources("SNMP"): 31 if not ds.enabled: continue 32 oid = ds.oid 33 if not oid: continue 34 snmpindex = getattr(comp, "ifindex", comp.snmpindex) 35 if snmpindex: oid = "%s.%s" % (oid, snmpindex) 36 for dp in ds.getRRDDataPoints(): 37 cname = comp.meta_type != "Device" \ 38 and comp.viewName() or dp.id 39 oids.append((cname, 40 oid, 41 "/".join((basepath, dp.name())), 42 dp.rrdtype, 43 dp.getRRDCreateCommand(perfServer), 44 (dp.rrdmin, dp.rrdmax))) 45 return (oids, comp.getThresholdInstances('SNMP'))46 4749 dev = dev.primaryAq() 50 if not dev.snmpMonitorDevice(): 51 log.debug("skipping %s SNMP monitoring disabled", dev.id) 52 return None 53 result = SnmpConfig() 54 oids, threshs = getComponentConfig(dev) 55 for comp in dev.os.getMonitoredComponents(collector="zenperfsnmp"): 56 cfg = getComponentConfig(comp) 57 if cfg: 58 oids.extend(cfg[0]) 59 threshs.extend(cfg[1]) 60 result.lastChangeTime = float(dev.getLastChange()) 61 result.device = dev.id 62 result.connInfo = dev.getSnmpConnInfo() 63 result.thresholds = threshs 64 result.oids = oids 65 return result6668 69 @translateError13771 """Return the subset of devices that should be monitored. 72 73 If devices is empty, then all the monitored devices are given. 74 """ 75 if devices: 76 if not isinstance(devices, list): 77 devices = Set([devices]) 78 else: 79 devices = Set(devices) 80 snmp = [] 81 for dev in self.config.devices(): 82 if devices and dev.id not in devices: continue 83 dev = dev.primaryAq() 84 if dev.snmpMonitorDevice(): 85 snmp.append(dev.id) 86 return snmp87 88 92 93 94 @translateError96 "Fetch the configs for the given devices" 97 result = [] 98 for d in devices: 99 device = self.getPerformanceMonitor().findDevice(d) 100 if device: 101 config = self.getDeviceConfig(device) 102 if config: 103 result.append(config) 104 return result105 106 107 @translateError109 """Return a list of devices that have changed. 110 Takes a list of known devices and the time of last known change. 111 The result is a list of devices that have changed, 112 or not in the list.""" 113 lastChanged = dict(devices) 114 new = Set() 115 all = Set() 116 for dev in self.config.devices(): 117 dev = dev.primaryAq() 118 if dev.snmpMonitorDevice(): 119 all.add(dev.id) 120 if lastChanged.get(dev.id, 0) < float(dev.getLastChange()): 121 new.add(dev.id) 122 deleted = Set(lastChanged.keys()) - all 123 return list(new | deleted)124 125127 "Template method helper for PerformanceConfig.pushConfig" 128 return listener.callRemote('updateDeviceConfig', config)129 130132 from Products.ZenModel.RRDDataSource import RRDDataSource 133 if isinstance(object, RRDDataSource): 134 if object.sourcetype != 'SNMP': 135 return 136 PerformanceConfig.update(self, object)
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Thu May 7 11:46:43 2009 | http://epydoc.sourceforge.net |