def __init__(self, send_callback, thresholds): self._send_callback = send_callback if isinstance(thresholds, list): self._thresholds = Thresholds() self._thresholds.updateList(thresholds) elif isinstance(thresholds, Thresholds): self._thresholds = thresholds else: self._thresholds = Thresholds()
def __init__(self, dmd, instance): HubService.__init__(self, dmd, instance) # rrd is a dictionary of RRDUtil instances self.rrd = {} self.thresholds = Thresholds() self.rrdimpl = RRDImpl(dmd)
def __init__(self, name, noopts=False): """ Initializer @param name: name of the daemon @type name: string @param noopts: process command-line arguments? @type noopts: boolean """ self.events = [] PBDaemon.__init__(self, noopts, name=name) self.thresholds = Thresholds()
def config(self, name, monitor, thresholds, rrdCreateCommand=None): """Initialize the object. We could do this in __init__, but that would delay creation to after configuration time, which may run asynchronously with collection or heartbeats. By deferring initialization, this object implements the Null Object pattern until the application is ready to start writing real statistics. """ self.name = name self.monitor = monitor if not rrdCreateCommand: from Products.ZenModel.PerformanceConf import PerformanceConf rrdCreateCommand = PerformanceConf.defaultRRDCreateCommand if not isinstance(rrdCreateCommand, basestring): self.createCommand = rrdCreateCommand else: self.createCommand = rrdCreateCommand.split('\n') self.thresholds = Thresholds() self.thresholds.updateList(thresholds)
def getThresholds(self): if not self._thresholds: self._thresholds = Thresholds() return self._thresholds
def __init__(self, preferences, taskSplitter, configurationListener=DUMMY_LISTENER, initializationCallback=None, stoppingCallback=None): """ Constructs a new instance of the CollectorDaemon framework. Normally only a singleton instance of a CollectorDaemon should exist within a process, but this is not enforced. @param preferences: the collector configuration @type preferences: ICollectorPreferences @param taskSplitter: the task splitter to use for this collector @type taskSplitter: ITaskSplitter @param initializationCallback: a callable that will be executed after connection to the hub but before retrieving configuration information @type initializationCallback: any callable @param stoppingCallback: a callable that will be executed first during the stopping process. Exceptions will be logged but otherwise ignored. @type stoppingCallback: any callable """ # create the configuration first, so we have the collector name # available before activating the rest of the Daemon class hierarchy. if not ICollectorPreferences.providedBy(preferences): raise TypeError("configuration must provide ICollectorPreferences") else: self._prefs = ObservableProxy(preferences) self._prefs.attachAttributeObserver('configCycleInterval', self._rescheduleConfig) if not ITaskSplitter.providedBy(taskSplitter): raise TypeError("taskSplitter must provide ITaskSplitter") else: self._taskSplitter = taskSplitter if not IConfigurationListener.providedBy(configurationListener): raise TypeError( "configurationListener must provide IConfigurationListener") self._configListener = ConfigListenerNotifier() self._configListener.addListener(configurationListener) self._configListener.addListener(DeviceGuidListener(self)) self._initializationCallback = initializationCallback self._stoppingCallback = stoppingCallback # register the various interfaces we provide the rest of the system so # that collector implementors can easily retrieve a reference back here # if needed zope.component.provideUtility(self, ICollector) zope.component.provideUtility(self, IEventService) zope.component.provideUtility(self, IDataService) # setup daemon statistics self._statService = StatisticsService() self._statService.addStatistic("devices", "GAUGE") self._statService.addStatistic("cyclePoints", "GAUGE") self._statService.addStatistic("dataPoints", "DERIVE") self._statService.addStatistic("runningTasks", "GAUGE") self._statService.addStatistic("queuedTasks", "GAUGE") self._statService.addStatistic("missedRuns", "GAUGE") zope.component.provideUtility(self._statService, IStatisticsService) # register the collector's own preferences object so it may be easily # retrieved by factories, tasks, etc. zope.component.provideUtility(self.preferences, ICollectorPreferences, self.preferences.collectorName) super(CollectorDaemon, self).__init__(name=self.preferences.collectorName) self._deviceGuids = {} self._devices = set() self._thresholds = Thresholds() self._unresponsiveDevices = set() self._rrd = None self.reconfigureTimeout = None # keep track of pending tasks if we're doing a single run, and not a # continuous cycle if not self.options.cycle: self._completedTasks = 0 self._pendingTasks = [] frameworkFactory = zope.component.queryUtility( IFrameworkFactory, self._frameworkFactoryName) self._configProxy = frameworkFactory.getConfigurationProxy() self._scheduler = frameworkFactory.getScheduler() self._scheduler.maxTasks = self.options.maxTasks self._ConfigurationLoaderTask = frameworkFactory.getConfigurationLoaderTask( ) # OLD - set the initialServices attribute so that the PBDaemon class # will load all of the remote services we need. self.initialServices = PBDaemon.initialServices +\ [self.preferences.configurationService] # trap SIGUSR2 so that we can display detailed statistics signal.signal(signal.SIGUSR2, self._signalHandler) # let the configuration do any additional startup it might need self.preferences.postStartup() self.addedPostStartupTasks = False
def __init__(self): self.name = "" self.monitor = "" self.rrdCreateCommand = "" self.thresholds = Thresholds()