Ejemplo n.º 1
0
 def internalPublisher(self):
     if not self._internal_publisher:
         url = os.environ.get("CONTROLPLANE_CONSUMER_URL", None)
         username = os.environ.get("CONTROLPLANE_CONSUMER_USERNAME", "")
         password = os.environ.get("CONTROLPLANE_CONSUMER_PASSWORD", "")
         if url:
             self._internal_publisher = publisher.HttpPostPublisher(
                 username, password, url)
     return self._internal_publisher
Ejemplo n.º 2
0
    def run(self):
        # Configure all actions with the command-line options
        self.abortIfWaiting()
        options_dict = dict(vars(self.options))
        for name, action in getUtilitiesFor(IAction):
            action.configure(options_dict)

        dao = NotificationDao(self.dmd)
        task = ISignalProcessorTask(dao)
        metric_destination = os.environ.get("CONTROLPLANE_CONSUMER_URL", "")
        if metric_destination == "":
            metric_destination = "http://localhost:22350/api/metrics/store"
        username = os.environ.get("CONTROLPLANE_CONSUMER_USERNAME", "")
        password = os.environ.get("CONTROLPLANE_CONSUMER_PASSWORD", "")
        pub = publisher.HttpPostPublisher(username, password,
                                          metric_destination)

        log.debug("Creating async MetricReporter")
        daemonTags = {'zenoss_daemon': 'zenactiond', 'internal': True}
        self.metricreporter = TwistedMetricReporter(
            prefix='zenoss.', metricWriter=MetricWriter(pub), tags=daemonTags)
        self.metricreporter.start()
        reactor.addSystemEventTrigger('before', 'shutdown',
                                      self.metricreporter.stop)

        if self.options.workerid == 0 and (self.options.daemon
                                           or self.options.cycle):
            self._callHomeCycler.start()
            self._schedule.start()  # maintenance windows

        if self.options.daemon or self.options.cycle:
            self._maintenanceCycle.start()  # heartbeats, etc.

        if (self.options.daemon
                or self.options.cycle) and self.options.workers > 1:
            self._workers.startWorkers()

        self._consumer = QueueConsumer(task, self.dmd)
        reactor.callWhenRunning(self._start)
        reactor.run()