def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) # for now, every device gets a single configCycleInterval based upon # the collector's winCycleInterval configuration which is typically # located at dmd.Monitors.Performance._getOb('localhost'). # TODO: create a zProperty that allows for individual device schedules proxy.configCycleInterval = self._prefs.winCycleInterval proxy.services = {} for service in genServices(device): if service.isMonitored: running = None if service.getStatus() > 0: running = False else: running = True proxy.services[service.name] = ( running, service.severity, None, service.getMonitoredStartModes()) # don't bother adding this device proxy if there aren't any services # to monitor if not proxy.services: log.debug("Device %s skipped because there are no services", proxy.id) return None return proxy
def _createDeviceProxy(self, device, manage_ip=None, components=(), components_only=False): proxy = SnmpDeviceProxy() proxy = CollectorConfigService._createDeviceProxy(self, device, proxy) proxy.snmpConnInfo = device.getSnmpConnInfo() if manage_ip is not None and manage_ip != device.manageIp: proxy._config_id = device.id + "_" + manage_ip proxy.snmpConnInfo.manageIp = manage_ip # framework expects a value for this attr but snmp task uses cycleInterval defined below proxy.configCycleInterval = getattr(device, 'zSnmpCollectionInterval', 300) # this is the attr zenperfsnmp actually uses proxy.cycleInterval = proxy.configCycleInterval proxy.name = device.id proxy.device = device.id proxy.lastmodeltime = device.getLastChangeString() proxy.lastChangeTime = float(device.getLastChange()) # Gather the datapoints to retrieve perfServer = device.getPerformanceServer() proxy.oids = {} proxy.thresholds = [] if not components_only: # First for the device.... threshs = self._getComponentConfig(device, perfServer, proxy.oids) if threshs: proxy.thresholds.extend(threshs) # And now for its components for comp in components: threshs = self._getComponentConfig(comp, perfServer, proxy.oids) if threshs: proxy.thresholds.extend(threshs) if proxy.oids: return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = self._prefs.perfsnmpCycleInterval proxy.name = device.id proxy.device = device.id proxy.lastmodeltime = device.getLastChangeString() proxy.lastChangeTime = float(device.getLastChange()) perfServer = device.getPerformanceServer() datasources = set() # First for the device.... proxy.thresholds = [] self._safeGetComponentConfig(device, device, perfServer, datasources, proxy.thresholds) # And now for its components for comp in device.getMonitoredComponents(): self._safeGetComponentConfig(comp, device, perfServer, datasources, proxy.thresholds) if datasources: proxy.datasources = list(datasources) return proxy return None
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = max(device.zWinPerfCycleSeconds, 1) proxy.cyclesPerConnection = max(device.zWinPerfCyclesPerConnection, 2) proxy.timeoutSeconds = max(device.zWinPerfTimeoutSeconds, 1) proxy.dpInfo = [] proxy.thresholds = [] perfServer = device.getPerformanceServer() # get the datapoints & thresholds first for the device itself self._getDataPointInfo(proxy, device, device.id, None, perfServer) proxy.thresholds += device.getThresholdInstances(WINPERF_DSTYPE) # and then for all of the monitored components that have them for comp in device.getMonitoredComponents(): self._getDataPointInfo(proxy, comp, comp.device().id, comp.id, perfServer) proxy.thresholds += comp.getThresholdInstances(WINPERF_DSTYPE) # if there are no datapoints to be monitored then we don't need a # proxy to monitor this device if not proxy.dpInfo: self.log.debug("Device %s has no datapoints to be monitored", device.id) return None return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = 3600 proxy.name = "SEF Configuration" proxy.device = device.id return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) # Framework expects a default value but zencommand uses cycles per datasource instead proxy.configCycleInterval = 0 proxy.name = device.id proxy.device = device.id proxy.lastmodeltime = device.getLastChangeString() proxy.lastChangeTime = float(device.getLastChange()) # Only send one event per warning type self._sentNoUsernameSetWarning = False self._sentNoUsernameSetClear = False perfServer = device.getPerformanceServer() commands = set() # First for the device.... proxy.thresholds = [] self._safeGetComponentConfig(device, device, perfServer, commands, proxy.thresholds) # And now for its components for comp in device.getMonitoredComponents(collector='zencommand'): self._safeGetComponentConfig(comp, device, perfServer, commands, proxy.thresholds) if commands: proxy.datasources = list(commands) return proxy return None
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = max( device.getProperty('zWinPerfCycleSeconds', 1), 1) proxy.cyclesPerConnection = max( device.getProperty('zWinPerfCyclesPerConnection', 2), 2) proxy.timeoutSeconds = max( device.getProperty('zWinPerfTimeoutSeconds', 1), 1) proxy.dpInfo = [] proxy.thresholds = [] perfServer = device.getPerformanceServer() # get the datapoints & thresholds first for the device itself self._getDataPointInfo(proxy, device, device.id, None, perfServer) proxy.thresholds += device.getThresholdInstances(WINPERF_DSTYPE) # and then for all of the monitored components that have them for comp in device.getMonitoredComponents(): self._getDataPointInfo(proxy, comp, comp.device().id, comp.id, perfServer) proxy.thresholds += comp.getThresholdInstances(WINPERF_DSTYPE) # if there are no datapoints to be monitored then we don't need a # proxy to monitor this device if not proxy.dpInfo: self.log.debug("Device %s has no datapoints to be monitored", device.id) return None return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) # for now, every device gets a single configCycleInterval based upon # the collector's winCycleInterval configuration which is typically # located at dmd.Monitors.Performance._getOb('localhost'). # TODO: create a zProperty that allows for individual device schedules proxy.configCycleInterval = self._prefs.winCycleInterval proxy.services = {} for service in genServices(device): if service.isMonitored: running = None if service.getStatus() > 0: running = False else: running = True proxy.services[service.name] = ( running, service.severity, None, service.getMonitoredStartModes()) # don't bother adding this device proxy if there aren't any services # to monitor if not proxy.services: log.debug("Device %s skipped because there are no services", proxy.id) return None return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = self._prefs.perfsnmpCycleInterval proxy.name = device.id proxy.device = device.id proxy.lastmodeltime = device.getLastChangeString() proxy.lastChangeTime = float(device.getLastChange()) perfServer = device.getPerformanceServer() datasources = set() # First for the device.... proxy.thresholds = [] self._safeGetComponentConfig(device, device, perfServer, datasources, proxy.thresholds) # And now for its components for comp in device.getMonitoredComponents(): self._safeGetComponentConfig(comp, device, perfServer, datasources, proxy.thresholds) if datasources: proxy.datasources = list(datasources) return proxy return None
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) # Framework expects a default value but zencommand uses cycles per datasource instead proxy.configCycleInterval = 0 proxy.name = device.id proxy.device = device.id proxy.lastmodeltime = device.getLastChangeString() proxy.lastChangeTime = float(device.getLastChange()) # Only send one event per warning type self._sentNoUsernameSetWarning = False self._sentNoUsernameSetClear = False perfServer = device.getPerformanceServer() commands = set() # First for the device.... proxy.thresholds = [] self._safeGetComponentConfig(device, device, perfServer, commands, proxy.thresholds) # And now for its components for comp in device.getMonitoredComponents(collector='zencommand'): self._safeGetComponentConfig(comp, device, perfServer, commands, proxy.thresholds) if commands: proxy.datasources = list(commands) return proxy return None
def _createDeviceProxy(self, device, manage_ip=None, components=(), components_only=False): proxy = SLADeviceProxy() proxy = CollectorConfigService._createDeviceProxy(self, device, proxy) proxy.snmpConnInfo = device.getSnmpConnInfo() if manage_ip is not None and manage_ip != device.manageIp: proxy._config_id = device.id + "_" + manage_ip proxy.snmpConnInfo.manageIp = manage_ip proxy.configCycleInterval = self._prefs.perfsnmpCycleInterval proxy.cycleInterval = getattr(device, "zSnmpCollectionInterval", 300) proxy.name = device.id proxy.device = device.id proxy.lastmodeltime = device.getLastChangeString() proxy.lastChangeTime = float(device.getLastChange()) # Gather the datapoints to retrieve perfServer = device.getPerformanceServer() proxy.oids = {} proxy.thresholds = [] if not components_only: # First for the device.... threshs = self._getComponentConfig(device, perfServer, proxy.oids) if threshs: proxy.thresholds.extend(threshs) # And now for its components for comp in components: threshs = self._getComponentConfig(comp, perfServer, proxy.oids) if threshs: proxy.thresholds.extend(threshs) if proxy.oids: return proxy
def _createDeviceProxy(self, device): procs = device.getMonitoredComponents(collector='zenprocess') if not procs: log.debug("Device %s has no monitored processes -- ignoring", device.titleOrId()) return None proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = self._prefs.processCycleInterval proxy.name = device.id proxy.lastmodeltime = device.getLastChangeString() proxy.thresholds = [] proxy.processes = {} proxy.snmpConnInfo = device.getSnmpConnInfo() for p in procs: # Find out which datasources are responsible for this process # if SNMP is not responsible, then do not add it to the list snmpMonitored = False for rrdTpl in p.getRRDTemplates(): if len(rrdTpl.getRRDDataSources("SNMP")) > 0: snmpMonitored = True break # In case the process is not SNMP monitored if not snmpMonitored: log.debug( "Skipping process %r - not an SNMP monitored process", p) continue # In case the catalog is out of sync above if not p.monitored(): log.debug("Skipping process %r - zMonitor disabled", p) continue regex = getattr(p.osProcessClass(), 'regex', False) if regex: try: re.compile(regex) except sre_constants.error, ex: log.warn( "OS process class %s has an invalid regex (%s): %s", p.getOSProcessClass(), regex, ex) continue else: log.warn( "OS process class %s has no defined regex, this process not being monitored", p.getOSProcessClass()) continue proc = ProcessProxy() proc.regex = regex proc.name = p.id proc.originalName = p.name() proc.ignoreParameters = (getattr(p.osProcessClass(), 'ignoreParameters', False)) proc.restart = p.alertOnRestart() proc.severity = p.getFailSeverity() proc.processClass = p.getOSProcessClass() proxy.processes[p.id] = proc proxy.thresholds.extend(p.getThresholdInstances('SNMP'))
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) log.debug("creating proxy for device %s" % device.id) proxy.configCycleInterval = 300 proxy.device = device.id proxy.tsdbServer = device.zOpenTSDBServer proxy.tsdbPort = device.zOpenTSDBPort return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = 3600 proxy.name = "Syslog Configuration" proxy.device = device.id proxy.defaultPriority = self.zem.defaultPriority return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) # for now, every device gets a single configCycleInterval based upon # the collector's eventlogCycleInterval configuration. # TODO: create a zProperty that allows for individual device schedules proxy.configCycleInterval = self._prefs.eventlogCycleInterval return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) # for now, every device gets a single configCycleInterval based upon # the collector's eventlogCycleInterval configuration. # TODO: create a zProperty that allows for individual device schedules proxy.configCycleInterval = self._prefs.eventlogCycleInterval return proxy
def _createDeviceProxy(self, device): procs = device.getMonitoredComponents(collector='zenprocess') if not procs: log.debug("Device %s has no monitored processes -- ignoring", device.titleOrId()) return None proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = self._prefs.processCycleInterval proxy.name = device.id proxy.lastmodeltime = device.getLastChangeString() proxy.thresholds = [] proxy.processes = {} proxy.snmpConnInfo = device.getSnmpConnInfo() for p in procs: # Find out which datasources are responsible for this process # if SNMP is not responsible, then do not add it to the list snmpMonitored = False for rrdTpl in p.getRRDTemplates(): if len(rrdTpl.getRRDDataSources("SNMP")) > 0: snmpMonitored = True break # In case the process is not SNMP monitored if not snmpMonitored: log.debug("Skipping process %r - not an SNMP monitored process", p) continue # In case the catalog is out of sync above if not p.monitored(): log.debug("Skipping process %r - zMonitor disabled", p) continue regex = getattr(p.osProcessClass(), 'regex', False) if regex: try: re.compile(regex) except sre_constants.error, ex: log.warn("OS process class %s has an invalid regex (%s): %s", p.getOSProcessClass(), regex, ex) continue else: log.warn("OS process class %s has no defined regex, this process not being monitored", p.getOSProcessClass()) continue proc = ProcessProxy() proc.regex = regex proc.name = p.id proc.originalName = p.name() proc.ignoreParameters = ( getattr(p.osProcessClass(), 'ignoreParameters', False)) proc.restart = p.alertOnRestart() proc.severity = p.getFailSeverity() proc.processClass = p.getOSProcessClass() proxy.processes[p.id] = proc proxy.thresholds.extend(p.getThresholdInstances('SNMP'))
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = 5 * 60 # 5 minutes proxy.datapoints = [] perfServer = device.getPerformanceServer() self._getPowerDp(proxy, device, device.id, None, perfServer) return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = 5 * 60 # 5 minutes proxy.datapoints = [] perfServer = device.getPerformanceServer() self._getPowerDp(proxy, device, device.id, None, perfServer) return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = 3600 proxy.name = "SNMP Trap Configuration" proxy.device = device.id # Gather all OID -> Name mappings from /Mibs catalog proxy.oidMap = dict( (b.oid, b.id) for b in self.dmd.Mibs.mibSearch() if b.oid) return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = 3600 proxy.name = "SNMP Trap Configuration" proxy.device = device.id # Gather all OID -> Name mappings from /Mibs catalog proxy.oidMap = dict( (b.oid, b.id) for b in self.dmd.Mibs.mibSearch() if b.oid ) return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) log.debug("creating Pagerduty proxy for device %s" % device.id) proxy.configCycleInterval = 120 proxy.device = device.id proxy.zenhost = device.zPDZenossServer proxy.zenuser = device.zPDZenossUser proxy.zenpass = device.zPDZenossPass proxy.pdhost = device.zPDDomain proxy.pdtoken = device.zPDToken proxy.pduser = device.zPDUser return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.datasources = [] for template in device.getRRDTemplates(): for ds in template.getRRDDataSources(): if ds.sourcetype == 'MAILTX' and \ self._checkMailTxDs(device.id, template, ds): proxy.datasources.append(Config(device, template, ds)) if proxy.datasources: return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) # for now, every device gets a single configCycleInterval based upon # the collector's winCycleInterval configuration which is typically # located at dmd.Monitors.Performance._getOb('localhost'). # TODO: create a zProperty that allows for individual device schedules proxy.configCycleInterval = self._prefs.perfsnmpCycleInterval proxy.queries, proxy.datapoints, proxy.thresholds = getWbemDeviceConfig(self.cimtransport, device) if not proxy.queries: log.debug("Device %s skipped because there are no datasources", device.getId()) return None return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) # for now, every device gets a single configCycleInterval based upon # the collector's winCycleInterval configuration which is typically # located at dmd.Monitors.Performance._getOb('localhost'). # TODO: create a zProperty that allows for individual device schedules proxy.configCycleInterval = self._prefs.perfsnmpCycleInterval proxy.queries, proxy.datapoints, proxy.thresholds = getWbemDeviceConfig( self.cimtransport, device) if not proxy.queries: log.debug("Device %s skipped because there are no datasources", device.getId()) return None return proxy
def _createDeviceProxy(self, device): log.debug('creating proxy for %s' % device.id) proxy = CollectorConfigService._createDeviceProxy(self, device,) proxy.configCycleInterval = 600 proxy.datapoints = [] proxy.tsdbServer = device.zOpenTSDBServer proxy.tsdbPort = device.zOpenTSDBPort perfServer = device.getPerformanceServer() proxy.mqServer = perfServer.id proxy.primary_url_path = device.getPrimaryUrlPath() self._getDataPoints(proxy, device, device.id, None, perfServer) for component in device.getMonitoredComponents(): self._getDataPoints( proxy, component, component.device().id, component.id, perfServer) log.debug("found %d datapoints" % len(proxy.datapoints)) return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) # The event daemon keeps a persistent connection open, so this cycle # interval will only be used if the connection is lost... for now, it # doesn't need to be configurable. proxy.configCycleInterval = 5 * 60 # seconds proxy.datapoints = [] proxy.thresholds = [] for component in [device] + device.getMonitoredComponents(): try: self._getDataPoints(proxy, component, component.device().id, component.id) except Exception, ex: log.warn("Skipping %s component %s because %s", device.id, component.id, str(ex)) continue proxy.thresholds += component.getThresholdInstances(DSTYPE)
def _createDeviceProxy(self, device): collector = device.getPerformanceServer() proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.datasources = list(self.device_datasources(device, collector)) # getTresholdInstances needs the datasource sourcetype string. proxy.thresholds = self._thresholds(device) for component in device.getMonitoredComponents(): proxy.datasources += list(self.component_datasources(component, collector)) proxy.thresholds += self._thresholds(component) if len(proxy.datasources) > 0: return proxy return None
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = 5 * 60 proxy.dsConfigs = list(self._dsConfigs(device)) proxy.thresholds = device.getThresholdInstances( MonitoredPropertyDataSource.sourcetype) proxy.thresholds += device.getThresholdInstances( MonitoredPropertyDataSource.sourcetype) # We only worry about monitoring templates against components right now. for component in device.getMonitoredComponents(): proxy.dsConfigs.extend(self._dsConfigs(component)) proxy.thresholds.extend(component.getThresholdInstances( MonitoredPropertyDataSource.sourcetype)) return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.name = device.id proxy.device = device.id proxy.lastmodeltime = device.getLastChangeString() proxy.lastChangeTime = float(device.getLastChange()) perfServer = device.getPerformanceServer() proxy.thresholds = [] proxy.monitoredIps = [] connectedIps = [] for iface in device.os.interfaces(): self._getComponentConfig(iface, perfServer, proxy.monitoredIps) threshs = iface.getThresholdInstances('PING') if threshs: proxy.thresholds.extend(threshs) for ipAddress in iface.ipaddresses(): ip = ipAddress.id if ip and ip not in ('127.0.0.1', '0.0.0.0', '::', '::1') and ip != device.manageIp: # tuple of ip, interface id connectedIps.append(( ip, iface.id, )) proxy.connectedIps = connectedIps if not proxy.monitoredIps: log.debug( "%s has no interface templates -- just using management IP %s", device.titleOrId(), device.manageIp) self._addManageIp(device, perfServer, proxy) elif device.manageIp not in [x.ip for x in proxy.monitoredIps]: # Note: most commonly occurs for SNMP fakeout devices which replay # data from real devices, but from a different IP address # than what captured the data log.debug("%s doesn't have an interface for management IP %s", device.titleOrId(), device.manageIp) self._addManageIp(device, perfServer, proxy) return proxy
def _createDeviceProxy(self, device): collector = device.getPerformanceServer() proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.datasources = [] proxy.thresholds = [] proxy.zOpenStackProcessEventTypes = device.zOpenStackProcessEventTypes proxy.zOpenStackIncrementalShortLivedSeconds = device.zOpenStackIncrementalShortLivedSeconds proxy.zOpenStackIncrementalBlackListSeconds = device.zOpenStackIncrementalBlackListSeconds proxy.zOpenStackIncrementalConsolidateSeconds = device.zOpenStackIncrementalConsolidateSeconds for component in device.getMonitoredComponents(): proxy.datasources += list( self.component_datasources(component, collector)) proxy.thresholds += component.getThresholdInstances( PerfAMQPDataSource.sourcetype) return proxy
def _createDeviceProxy(self, device): collector = device.getPerformanceServer() proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.datasources = list(self.device_datasources(device, collector)) # getTresholdInstances needs the datasource sourcetype string. proxy.thresholds = self._thresholds(device) for component in device.getMonitoredComponents(): proxy.datasources += list( self.component_datasources(component, collector)) proxy.thresholds += self._thresholds(component) if len(proxy.datasources) > 0: return proxy return None
def _createDeviceProxy(self, device): collector = device.getPerformanceServer() proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.datasources = [] proxy.thresholds = [] proxy.zOpenStackProcessEventTypes = device.zOpenStackProcessEventTypes proxy.zOpenStackIncrementalShortLivedSeconds = device.zOpenStackIncrementalShortLivedSeconds proxy.zOpenStackIncrementalBlackListSeconds = device.zOpenStackIncrementalBlackListSeconds proxy.zOpenStackIncrementalConsolidateSeconds = device.zOpenStackIncrementalConsolidateSeconds for component in device.getMonitoredComponents(): proxy.datasources += list( self.component_datasources(component, collector)) proxy.thresholds += component.getThresholdInstances( PerfAMQPDataSource.sourcetype) return proxy
def _createDeviceProxy(self, device, proxy=None): proxy = CollectorConfigService._createDeviceProxy( self, device, proxy=proxy) proxy.datapoints = [] proxy.thresholds = [] perfServer = device.getPerformanceServer() self._getDataPoints(proxy, device, device, perfServer) proxy.thresholds += device.getThresholdInstances('Example Protocol') for component in device.getMonitoredComponents(): self._getDataPoints(proxy, device, component, perfServer) proxy.thresholds += component.getThresholdInstances( 'Example Protocol') return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = 5 * 60 proxy.datapoints = [] proxy.thresholds = [] perfServer = device.getPerformanceServer() compName = device.id basepath = device.rrdPath() for templ in device.getRRDTemplates(): dpnames = [] for ds in filter(lambda ds: isinstance(ds, LdapDataSource), templ.getRRDDataSources()): try: proxy.ldapuri = ds.ldapURI(device) proxy.credentials = device.getProperty('zLDAPDN'), device.getProperty('zLDAPPW') proxy.searchFilter = ds.searchFilter except: log.error('Device not LDAP: %s' % device) continue for dp in ds.getRRDDataPoints(): dpname = dp.name() dpnames.append(dpname) proxy.datapoints.append((dp.id, compName, "/".join((basepath, dpname)), dp.rrdtype, dp.getRRDCreateCommand(perfServer), dp.rrdmin, dp.rrdmax)) dpn = set(dpnames) for thr in templ.thresholds(): if not (thr.enabled and dpn & set(thr.dsnames)): continue proxy.thresholds.append(thr.createThresholdInstance(device)) return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = self._prefs.statusCycleInterval # add each component proxy.components = [] for svc in device.getMonitoredComponents(collector='zenstatus'): if svc.getProtocol() == 'tcp': # get component status status = svc.getStatus(Status_IpService) proxy.components.append(ServiceProxy(svc, status)) # don't bother adding this device proxy if there aren't any services # to monitor if not proxy.components: log.debug("Device %s skipped because there are no components", proxy.id) return None return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = self._prefs.statusCycleInterval # add each component proxy.components = [] for svc in device.getMonitoredComponents(collector='zenstatus'): if svc.getProtocol() in TCP_PROTOCOLS: # get component status status = svc.getStatus(Status_IpService) proxy.components.append(ServiceProxy(svc, status)) # don't bother adding this device proxy if there aren't any services # to monitor if not proxy.components: log.debug("Device %s skipped because there are no components", proxy.id) return None return proxy
def _createDeviceProxy(self, device, proxy=None): proxy = CollectorConfigService._createDeviceProxy(self, device, proxy=proxy) proxy.datapoints = [] proxy.thresholds = [] perfServer = device.getPerformanceServer() self._getDataPoints(proxy, device, device, perfServer) proxy.thresholds += device.getThresholdInstances('Example Protocol') for component in device.getMonitoredComponents(): self._getDataPoints(proxy, device, component, perfServer) proxy.thresholds += component.getThresholdInstances( 'Example Protocol') return proxy
def _createDeviceProxy(self, device, proxy=None): proxy = CollectorConfigService._createDeviceProxy( self, device, proxy=proxy) proxy.name = device.id proxy.device = device.id proxy.lastmodeltime = device.getLastChangeString() proxy.lastChangeTime = float(device.getLastChange()) perfServer = device.getPerformanceServer() proxy.thresholds = [] proxy.monitoredIps = [] connectedIps = [] for iface in device.os.interfaces(): self._getComponentConfig(iface, perfServer, proxy.monitoredIps) threshs = iface.getThresholdInstances('PING') if threshs: proxy.thresholds.extend(threshs) for ipAddress in iface.ipaddresses(): ip = ipAddress.id if ip and ip not in ('127.0.0.1', '0.0.0.0', '::', '::1') and ip != device.manageIp: # tuple of ip, interface id connectedIps.append((ip, iface.id,)) proxy.connectedIps = connectedIps if not proxy.monitoredIps: log.debug("%s has no interface templates -- just using management IP %s", device.titleOrId(), device.manageIp) self._addManageIp(device, perfServer, proxy) elif device.manageIp not in [x.ip for x in proxy.monitoredIps]: # Note: most commonly occurs for SNMP fakeout devices which replay # data from real devices, but from a different IP address # than what captured the data log.debug("%s doesn't have an interface for management IP %s", device.titleOrId(), device.manageIp) self._addManageIp(device, perfServer, proxy) return proxy
def _createDeviceProxy(self, device): '''''' log.debug('getting proxy for device %s' % device.id) proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = max(device.zSiebelPerfCycleSeconds,300) proxy.cyclesPerConnection = max(device.zSiebelPerfCyclesPerConnection, 288) proxy.timeoutSeconds = max(device.zSiebelPerfTimeoutSeconds, 30) #proxy.shareGateway = device.zSiebelShareGateway proxy.datasources = {} proxy.dpInfo = [] proxy.datapoints = [] proxy.thresholds = [] perfServer = device.getPerformanceServer() log.debug("device %s has perfServer %s" % (device.id, perfServer) ) self._getDataPoints(proxy, device, device.id, None, perfServer) proxy.thresholds += device.getThresholdInstances(self.definition.component) for component in device.getMonitoredComponents(): self._getDataPoints(proxy, component, component.device().id, component.id, perfServer) proxy.thresholds += component.getThresholdInstances(self.definition.component) return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) # for now, every device gets a single configCycleInterval based upon # the collector's winCycleInterval configuration which is typically # located at dmd.Monitors.Performance._getOb('localhost'). # TODO: create a zProperty that allows for individual device schedules proxy.configCycleInterval = self._prefs.perfsnmpCycleInterval proxy.datapoints = [] proxy.thresholds = [] queries = {} log.debug('device: %s', device) try: perfServer = device.getPerformanceServer() except: return None evtOrgNames = self.dmd.Events.Status.getOrganizerNames() for comp in [device] + device.getMonitoredComponents(): compName = "" compType = "" if not isinstance(comp, Device): compName = comp.id if comp.__class__.__name__ in evtOrgNames: compType = comp.__class__.__name__ elif comp.meta_type in evtOrgNames: compType = comp.meta_type try: basepath = comp.rrdPath() except: continue for templ in comp.getRRDTemplates(): dpnames = [] for ds in templ.getRRDDataSources(): if not (isinstance(ds, DataSource) and ds.enabled):continue sql, sqlp, kbs, cs = ds.getQueryInfo(comp) if not sql: continue if sqlp and '_process where' in sql.lower(): sql = sqlp tn = '/'.join([device.id, comp.id, templ.id, ds.id]) aliases = set() sortkey = (cs,) for dp in ds.getRRDDataPoints(): dpname = dp.name() dpnames.append(dpname) alias = (dp.aliases() or [dp])[0] aname = alias.id.strip().lower() formula = getattr(alias, 'formula', None) expr = formula and talesEval("string:%s"%alias.formula, comp, extra={'now':'now'}) or None aliases.add(aname) proxy.datapoints.append((sortkey, tn, dp.id, aname, (compName, compType), expr, "/".join((basepath, dpname)), dp.rrdtype, dp.getRRDCreateCommand(perfServer), (dp.rrdmin, dp.rrdmax))) queries.setdefault(sortkey, {})[tn] = (sqlp, kbs, cs, dict(zip(aliases,aliases)), sql) dpn = set(dpnames) for thr in templ.thresholds(): if not (thr.enabled and dpn & set(thr.dsnames)): continue proxy.thresholds.append(thr.createThresholdInstance(comp)) proxy.queries = queries if not queries: log.debug("Device %s skipped because there are no datasources", device.getId()) return None return proxy
def _createDeviceProxy(self, device, proxy=None): procs = device.getMonitoredComponents(collector='zenprocess') if not procs: log.debug("Device %s has no monitored processes -- ignoring", device.titleOrId()) return None proxy = CollectorConfigService._createDeviceProxy( self, device, proxy=proxy) proxy.configCycleInterval = self._prefs.processCycleInterval proxy.name = device.id proxy.lastmodeltime = device.getLastChangeString() proxy.thresholds = [] proxy.processes = {} proxy.snmpConnInfo = device.getSnmpConnInfo() for p in procs: tags = {} # Find out which datasources are responsible for this process # if SNMP is not responsible, then do not add it to the list snmpMonitored = False for rrdTpl in p.getRRDTemplates(): for datasource in rrdTpl.getRRDDataSources("SNMP"): snmpMonitored = True # zenprocess doesn't consider each datapoint's # configuration. It assumes a static list of datapoints. So # we will combine tags from all datapoints and use them for # all datapoints. for datapoint in datasource.getRRDDataPoints(): tags.update(datapoint.getTags(p)) # In case the process is not SNMP monitored if not snmpMonitored: log.debug("Skipping process %r - not an SNMP monitored process", p) continue # In case the catalog is out of sync above if not p.monitored(): log.debug("Skipping process %r - zMonitor disabled", p) continue includeRegex = getattr(p.osProcessClass(), 'includeRegex', False) excludeRegex = getattr(p.osProcessClass(), 'excludeRegex', False) replaceRegex = getattr(p.osProcessClass(), 'replaceRegex', False) replacement = getattr(p.osProcessClass(), 'replacement', False) generatedId = getattr(p, 'generatedId', False) primaryUrlPath = getattr(p.osProcessClass(), 'processClassPrimaryUrlPath', False) if primaryUrlPath: primaryUrlPath = primaryUrlPath() if not includeRegex: log.warn("OS process class %s has no defined regex, this process not being monitored", p.getOSProcessClass()) continue bad_regex = False for regex in [includeRegex, excludeRegex, replaceRegex]: if regex: try: re.compile(regex) except re.error as ex: log.warn( "OS process class %s has an invalid regex (%s): %s", p.getOSProcessClass(), regex, ex) bad_regex = True break if bad_regex: continue proc = ProcessProxy() proc.metadata = p.getMetricMetadata() proc.tags = tags proc.includeRegex = includeRegex proc.excludeRegex = excludeRegex proc.replaceRegex = replaceRegex proc.replacement = replacement proc.primaryUrlPath = primaryUrlPath proc.generatedId = generatedId proc.name = p.id proc.originalName = p.name() proc.restart = p.alertOnRestart() proc.severity = p.getFailSeverity() proc.processClass = p.getOSProcessClass() proxy.processes[p.id] = proc proxy.thresholds.extend(p.getThresholdInstances('SNMP')) if proxy.processes: return proxy
def _createDeviceProxy(self, device): procs = device.getMonitoredComponents(collector='zenprocess') if not procs: log.debug("Device %s has no monitored processes -- ignoring", device.titleOrId()) return None proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = self._prefs.processCycleInterval proxy.name = device.id proxy.lastmodeltime = device.getLastChangeString() proxy.thresholds = [] proxy.processes = {} proxy.snmpConnInfo = device.getSnmpConnInfo() for p in procs: # Find out daemon is responsible for this process # by counting the number of SNMP data sources in the template # if SNMP is not responsible, then do not add it to the list snmpMonitored = False for rrdTpl in p.getRRDTemplates(): if len(rrdTpl.getRRDDataSources("SNMP")) > 0: snmpMonitored = True break # In case the process is not SNMP monitored if not snmpMonitored: log.debug( "Skipping process %r - not an SNMP monitored process", p) continue # In case the catalog is out of sync above if not p.monitored(): log.debug("Skipping process %r - zMonitor disabled", p) continue includeRegex = getattr(p.osProcessClass(), 'includeRegex', False) excludeRegex = getattr(p.osProcessClass(), 'excludeRegex', False) replaceRegex = getattr(p.osProcessClass(), 'replaceRegex', False) replacement = getattr(p.osProcessClass(), 'replacement', False) generatedId = getattr(p, 'generatedId', False) primaryUrlPath = getattr(p.osProcessClass(), 'processClassPrimaryUrlPath', False) if primaryUrlPath: primaryUrlPath = primaryUrlPath() if not includeRegex: log.warn( "OS process class %s has no defined regex, this process not being monitored", p.getOSProcessClass()) continue bad_regex = False for regex in [includeRegex, excludeRegex, replaceRegex]: if regex: try: re.compile(regex) except re.error as ex: log.warn( "OS process class %s has an invalid regex (%s): %s", p.getOSProcessClass(), regex, ex) bad_regex = True break if bad_regex: continue proc = ProcessProxy() proc.includeRegex = includeRegex proc.excludeRegex = excludeRegex proc.replaceRegex = replaceRegex proc.replacement = replacement proc.primaryUrlPath = primaryUrlPath proc.generatedId = generatedId proc.name = p.id proc.originalName = p.name() proc.restart = p.alertOnRestart() proc.severity = p.getFailSeverity() proc.processClass = p.getOSProcessClass() proxy.processes[p.id] = proc proxy.thresholds.extend(p.getThresholdInstances('SNMP')) if proxy.processes: return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = 5 * 60 return proxy
def _createDeviceProxy(self, device): proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = 5 * 60 return proxy
def _createDeviceProxy(self, device): procs = device.getMonitoredComponents(collector='zenprocess') if not procs: log.debug("Device %s has no monitored processes -- ignoring", device.titleOrId()) return None proxy = CollectorConfigService._createDeviceProxy(self, device) proxy.configCycleInterval = self._prefs.processCycleInterval proxy.name = device.id proxy.lastmodeltime = device.getLastChangeString() proxy.thresholds = [] proxy.processes = {} proxy.snmpConnInfo = device.getSnmpConnInfo() for p in procs: # Find out daemon is responsible for this process # by counting the number of SNMP data sources in the template # if SNMP is not responsible, then do not add it to the list snmpMonitored = False for rrdTpl in p.getRRDTemplates(): if len(rrdTpl.getRRDDataSources("SNMP")) > 0: snmpMonitored = True break # In case the process is not SNMP monitored if not snmpMonitored: log.debug("Skipping process %r - not an SNMP monitored process", p) continue # In case the catalog is out of sync above if not p.monitored(): log.debug("Skipping process %r - zMonitor disabled", p) continue includeRegex = getattr(p.osProcessClass(), 'includeRegex', False) excludeRegex = getattr(p.osProcessClass(), 'excludeRegex', False) replaceRegex = getattr(p.osProcessClass(), 'replaceRegex', False) replacement = getattr(p.osProcessClass(), 'replacement', False) generatedId = getattr(p, 'generatedId', False) primaryUrlPath = getattr(p.osProcessClass(), 'processClassPrimaryUrlPath', False) if primaryUrlPath: primaryUrlPath = primaryUrlPath() if not includeRegex: log.warn("OS process class %s has no defined regex, this process not being monitored", p.getOSProcessClass()) continue bad_regex = False for regex in [includeRegex, excludeRegex, replaceRegex]: if regex: try: re.compile(regex) except re.error as ex: log.warn( "OS process class %s has an invalid regex (%s): %s", p.getOSProcessClass(), regex, ex) bad_regex = True break if bad_regex: continue proc = ProcessProxy() proc.includeRegex = includeRegex proc.excludeRegex = excludeRegex proc.replaceRegex = replaceRegex proc.replacement = replacement proc.primaryUrlPath = primaryUrlPath proc.generatedId = generatedId proc.name = p.id proc.originalName = p.name() proc.restart = p.alertOnRestart() proc.severity = p.getFailSeverity() proc.processClass = p.getOSProcessClass() proxy.processes[p.id] = proc proxy.thresholds.extend(p.getThresholdInstances('SNMP')) if proxy.processes: return proxy