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.ZenRRD.CommandParser import getParser 18 from Products.ZenHub.PBDaemon import translateError 19 2022 """Return list of command definitions. 23 """ 24 perfServer = comp.device().getPerformanceServer() 25 for templ in comp.getRRDTemplates(): 26 basepath = comp.rrdPath() 27 for ds in templ.getRRDDataSources('COMMAND'): 28 if not ds.enabled: continue 29 parserName = getattr(ds, "parser", "Auto") 30 parser = getParser(parserName) 31 points = [] 32 for dp in ds.getRRDDataPoints(): 33 dpc = DataPointConfig() 34 dpc.id = dp.id 35 dpc.component = comp.id 36 dpc.rrdPath = "/".join((basepath, dp.name())) 37 dpc.rrdType = dp.rrdtype 38 dpc.rrdCreateCommand = dp.getRRDCreateCommand(perfServer) 39 dpc.rrdMin = dp.rrdmin 40 dpc.rrdMax = dp.rrdmax 41 dpc.data = parser.dataForParser(comp, dp) 42 points.append(dpc) 43 cmd = Cmd() 44 cmd.useSsh = getattr(ds, 'usessh', False) 45 cmd.cycleTime = ds.cycletime 46 cmd.component = ds.getComponent(comp) 47 cmd.eventClass = ds.eventClass 48 cmd.eventKey = ds.eventKey or ds.id 49 cmd.severity = ds.severity 50 cmd.parser = parserName 51 cmd.command = ds.getCommand(comp) 52 cmd = commandCache.setdefault(cmd.commandKey(), cmd) 53 cmd.points.extend(points) 54 commandSet.add(cmd) 55 return comp.getThresholdInstances('COMMAND')56 5759 if not dev.monitorDevice(): 60 return None 61 cache = {} 62 cmds = set() 63 threshs = getComponentCommands(dev, cache, cmds) 64 for o in dev.getMonitoredComponents(collector="zencommand"): 65 threshs.extend(getComponentCommands(o, cache, cmds)) 66 if cmds: 67 d = DeviceConfig() 68 d.lastChange = dev.getLastChange() 69 d.device = dev.id 70 d.ipAddress = dev.getManageIp() 71 d.port = dev.zCommandPort 72 d.username = dev.zCommandUsername 73 d.password = dev.zCommandPassword 74 d.loginTimeout = dev.zCommandLoginTimeout 75 d.commandTimeout = dev.zCommandCommandTimeout 76 d.keyPath = dev.zKeyPath 77 d.maxOids = dev.zMaxOIDPerRequest 78 d.concurrentSessions = dev.zSshConcurrentSessions 79 d.commands = list(cmds) 80 d.thresholds = threshs 81 return d 82 return None83 8486 87 @translateError 90 91 94 95 98 99123101 '''Get the command configuration for all devices. 102 ''' 103 result = [] 104 for dev in self.config.devices(): 105 if devices and dev.id not in devices: continue 106 dev = dev.primaryAq() 107 try: 108 cmdinfo = getDeviceCommands(dev) 109 if not cmdinfo: continue 110 result.append(cmdinfo) 111 except POSError: raise 112 except: 113 self.log.exception("device %s", dev.id) 114 return result115117 from Products.ZenModel.RRDDataSource import RRDDataSource 118 if isinstance(object, RRDDataSource): 119 if object.sourcetype != 'COMMAND': 120 return 121 122 PerformanceConfig.update(self, object)
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Thu May 7 11:46:48 2009 | http://epydoc.sourceforge.net |