def buildOptions(self): ServiceTester.buildOptions(self) self.parser.add_option('--resolve', dest='request', help="Specify a specific OID or name to map to the name or OID.") self.parser.add_option('--exactMatch', dest='exactMatch', action='store_true', default=True, help="When resolving to name, use an exact match") self.parser.add_option('--fuzzyMatch', dest='exactMatch', action='store_false', help="When resolving to name, don't use an exact match") self.parser.add_option('--list', dest='list', action='store_true', default=False, help="List all OIDs?")
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 if __name__ == '__main__': from Products.ZenHub.ServiceTester import ServiceTester tester = ServiceTester(SnmpPerformanceConfig) def printer(proxy): for oid in sorted(proxy.oids): print oid tester.printDeviceProxy = printer tester.showDeviceInfo()
@onUpdate(OSProcessOrganizer) def processOrganizerUpdated(self, object, event): catalog = IModelCatalogTool(object.primaryAq()) results = catalog.search(OSProcessClass) if not results.total: return devices = set() for organizer in results: if results.areBrains: organizer = organizer.getObject() for process in organizer.instances(): device = process.device() if not device: continue device = device.primaryAq() device_path = device.getPrimaryUrlPath() if not device_path in devices: self._notifyAll(device) devices.add(device_path) if __name__ == '__main__': from Products.ZenHub.ServiceTester import ServiceTester tester = ServiceTester(ProcessConfig) def printer(config): for proc in config.processes.values(): print '\t'.join([proc.name, str(proc.includeRegex)]) tester.printDeviceProxy = printer tester.showDeviceInfo()
@transact @translateError def remote_setSnmpConnectionInfo(self, device, version, port, community): device = self.getPerformanceMonitor().findDeviceByIdExact(device) device.updateDevice(zSnmpVer=version, zSnmpPort=port, zSnmpCommunity=community) def pushConfig(self, device): from twisted.internet.defer import succeed return succeed(device) if __name__ == '__main__': from Products.ZenHub.ServiceTester import ServiceTester tester = ServiceTester(ModelerService) def configprinter(config): print "%s (%s) Plugins" % (config.id, config.manageIp) print sorted(x.pluginName for x in config.plugins) def showDeviceInfo(): if tester.options.device: name = tester.options.device config = tester.service.remote_getDeviceConfig([name]) if config: print "Config for %s =" % name configprinter(config[0]) else: log.warn("No configs found for %s", name) else:
ds) if ds_conf is not None: deviceConfig.add(ds_conf) # Don't both returning a proxy if there are no datasources. if not len(deviceConfig.jmxDataSourceConfigs.keys()): return None return deviceConfig def _getDataSourcesFromTemplate(self, template): datasources = [] for ds in template.getRRDDataSources('JMX'): if not ds.enabled: continue datasources.append(ds) return datasources if __name__ == '__main__': from Products.ZenHub.ServiceTester import ServiceTester tester = ServiceTester(ZenJMXConfigService) def printer(proxy): print '\t'.join(['', 'Hostname', 'Service name', 'Port']) for component, config in proxy.jmxDataSourceConfigs.items(): print '\t', component tester.printDeviceProxy = printer tester.showDeviceInfo()
dpId=dp.id, path=path, rrdType=dp.rrdtype, rrdCmd=dp.getRRDCreateCommand(perfServer), minv=dp.rrdmin, maxv=dp.rrdmax, metadata=comp.getMetricMetadata(device), tags=dp.getTags(component), exampleProperty=ds.exampleProperty, ) proxy.datapoints.append(dpInfo) # For diagnostic purposes, allow the user to show the results of the # proxy creation. # Run this service as a script to see which devices will be sent to the daemon. # Add the --device=name flag to see the detailed contents of the proxy that # will be sent to the daemon # if __name__ == '__main__': from Products.ZenHub.ServiceTester import ServiceTester tester = ServiceTester(ExampleConfigService) def printer(config): # Fill this out print config.datapoints tester.printDeviceProxy = printer tester.showDeviceInfo()
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 _getNotifiableClasses(self): """ When zProperties are changed on either of these two classes we need to refresh which devices we are monitoring """ return (Service, ServiceOrganizer) if __name__ == '__main__': from Products.ZenHub.ServiceTester import ServiceTester tester = ServiceTester(ZenStatusConfig) def printer(proxy): print '\t'.join(['', 'Hostname', 'Service name', 'Port']) for component in proxy.components: print '\t', component tester.printDeviceProxy = printer tester.showDeviceInfo()
include = False elif not getattr(device, 'zWinEventlog', True): log.debug("Device %s skipped because zWinEventlog is False", device.id) include = False return include 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 if __name__ == '__main__': from Products.ZenHub.ServiceTester import ServiceTester tester = ServiceTester(EventLogConfig) def printer(config): print "zWinEventlogMinSeverity = %s" % config.zWinEventlogMinSeverity print "zWinEventlogClause = '%s'" % config.zWinEventlogClause tester.printDeviceProxy = printer tester.showDeviceInfo()
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 if __name__ == '__main__': from Products.ZenHub.ServiceTester import ServiceTester tester = ServiceTester(WinServiceConfig) def printer(config): print '\t'.join([ 'Start Modes', 'Running?', 'Severity', 'Name', ]) for serviceName, data in sorted(config.services.items()): running, severity, _, startModes = data print '\t'.join( map(str, [startModes, running, '', severity, '', serviceName])) tester.printDeviceProxy = printer tester.showDeviceInfo()
perfServer): try: # Get the ServerDevice RRD Template. Specified by the ServerMonitor ZenPack template = deviceOrComponent.getRRDTemplateByName('ServerDevice') # Get the Power data point for the device. Specified by the ServerMonitor ZenPack dp = template.getRRDDataPoint('Power') dp_value = deviceOrComponent.getRRDValue('Power') dpInfo = dict(devId=deviceId, dpId=dp.getId(), rrdCmd=perfServer.getDefaultRRDCreateCommand(), dpValue=dp_value) proxy.datapoints.append(dpInfo) except Exception as e: print e if __name__ == '__main__': from Products.ZenHub.ServiceTester import ServiceTester tester = ServiceTester(PowerMonConfigService) def printer(config): # Fill this out print config.datapoints tester.printDeviceProxy = printer tester.showDeviceInfo()