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 ZODB.POSException import POSError 16 from Products.ZenRRD.zencommand import Cmd, DeviceConfig, DataPointConfig 17 from Products.ZenHub.PBDaemon import translateError 18 from Products.DataCollector.Plugins import getParserLoader 19 import logging 20 log = logging.getLogger('zen.CommandConfig') 2123 """Return list of command definitions. 24 """ 25 perfServer = comp.device().getPerformanceServer() 26 for templ in comp.getRRDTemplates(): 27 basepath = comp.rrdPath() 28 for ds in templ.getRRDDataSources('COMMAND'): 29 if not ds.enabled: continue 30 parserName = getattr(ds, "parser", "Auto") 31 ploader = getParserLoader(dmd, parserName) 32 if ploader is None: 33 log.error("Could not load %s plugin", parserName) 34 continue 35 parser = ploader.create() 36 points = [] 37 for dp in ds.getRRDDataPoints(): 38 dpc = DataPointConfig() 39 dpc.id = dp.id 40 dpc.component = comp.id 41 dpc.rrdPath = "/".join((basepath, dp.name())) 42 dpc.rrdType = dp.rrdtype 43 dpc.rrdCreateCommand = dp.getRRDCreateCommand(perfServer) 44 dpc.rrdMin = dp.rrdmin 45 dpc.rrdMax = dp.rrdmax 46 dpc.data = parser.dataForParser(comp, dp) 47 points.append(dpc) 48 cmd = Cmd() 49 cmd.useSsh = getattr(ds, 'usessh', False) 50 cmd.cycleTime = ds.cycletime 51 cmd.component = ds.getComponent(comp) 52 cmd.eventClass = ds.eventClass 53 cmd.eventKey = ds.eventKey or ds.id 54 cmd.severity = ds.severity 55 cmd.parser = ploader 56 cmd.command = ds.getCommand(comp) 57 cmd = commandCache.setdefault(cmd.commandKey(), cmd) 58 cmd.points.extend(points) 59 commandSet.add(cmd) 60 return comp.getThresholdInstances('COMMAND')61 6264 if not dev.monitorDevice(): 65 return None 66 cache = {} 67 cmds = set() 68 threshs = getComponentCommands(dev, cache, cmds, dev.getDmd()) 69 for o in dev.getMonitoredComponents(collector="zencommand"): 70 threshs.extend(getComponentCommands(o, cache, cmds, dev.getDmd())) 71 if cmds: 72 d = DeviceConfig() 73 d.lastChange = dev.getLastChange() 74 d.device = dev.id 75 d.ipAddress = dev.getManageIp() 76 d.port = dev.zCommandPort 77 d.username = dev.zCommandUsername 78 d.password = dev.zCommandPassword 79 d.loginTimeout = dev.zCommandLoginTimeout 80 d.commandTimeout = dev.zCommandCommandTimeout 81 d.keyPath = dev.zKeyPath 82 d.maxOids = dev.zMaxOIDPerRequest 83 d.concurrentSessions = dev.zSshConcurrentSessions 84 d.commands = list(cmds) 85 d.thresholds = threshs 86 return d 87 return None88 8991 92 @translateError 95 96 99 100 103 104128106 '''Get the command configuration for all devices. 107 ''' 108 result = [] 109 for dev in self.config.devices(): 110 if devices and dev.id not in devices: continue 111 dev = dev.primaryAq() 112 try: 113 cmdinfo = getDeviceCommands(dev) 114 if not cmdinfo: continue 115 result.append(cmdinfo) 116 except POSError: raise 117 except: 118 self.log.exception("device %s", dev.id) 119 return result120122 from Products.ZenModel.RRDDataSource import RRDDataSource 123 if isinstance(object, RRDDataSource): 124 if object.sourcetype != 'COMMAND': 125 return 126 127 PerformanceConfig.update(self, object)
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Fri Aug 28 03:05:14 2009 | http://epydoc.sourceforge.net |