Ejemplo n.º 1
0
    def setUp(self):
        self.reporter = LibratoReporter("<email>", "<token>")

        Metrology.meter('meter').mark()
        Metrology.counter('counter').increment()
        Metrology.timer('timer').update(1.5)
        Metrology.utilization_timer('utimer').update(1.5)
Ejemplo n.º 2
0
    def setUp(self):
        self.reporter = GangliaReporter("Group Name", "localhost", 8649)

        Metrology.meter('meter').mark()
        Metrology.counter('counter').increment()
        Metrology.timer('timer').update(5)
        Metrology.utilization_timer('utimer').update(5)
Ejemplo n.º 3
0
    def setUp(self):
        self.reporter = GraphiteReporter('localhost', 3333)

        Metrology.meter('meter').mark()
        Metrology.counter('counter').increment()
        Metrology.timer('timer').update(1.5)
        Metrology.utilization_timer('utimer').update(1.5)
Ejemplo n.º 4
0
    def __init__(self, notificationDao):
        self.notificationDao = notificationDao
        self.signal_timer = Metrology.timer('zenactiond.signals')
        self.notification_timer = Metrology.timer('zenactiond.notifications')

        # set by the constructor of queueConsumer
        self.queueConsumer = None

        self.schema = getUtility(IQueueSchema)
        self.queue = self.schema.getQueue("$Signals")
Ejemplo n.º 5
0
    def setUp(self):
        self.output = StringIO()
        logging.basicConfig(stream=self.output, level=logging.INFO)

        self.reporter = LoggerReporter()

        Metrology.meter('meter').mark()
        Metrology.counter('counter').increment()
        Metrology.timer('timer').update(1.5)
        Metrology.utilization_timer('utimer').update(1.5)
Ejemplo n.º 6
0
    def __init__(self, notificationDao):
        self.notificationDao = notificationDao
        self.signal_timer = Metrology.timer('zenactiond.signals')
        self.notification_timer = Metrology.timer('zenactiond.notifications')

        # set by the constructor of queueConsumer
        self.queueConsumer = None

        self.schema = getUtility(IQueueSchema)
        self.queue = self.schema.getQueue("$Signals")
Ejemplo n.º 7
0
    def test_send_batch(self, mock):
        self.reporter = GraphiteReporter('localhost', 3333, batch_size=2)

        Metrology.meter('meter').mark()
        Metrology.counter('counter').increment()
        Metrology.timer('timer').update(5)
        Metrology.utilization_timer('utimer').update(5)
        Metrology.histogram('histogram').update(5)
        self.reporter.write()
        self.assertTrue(mock.send.assert_called())
        self.assertEqual(25, len(mock.sendall.call_args_list))
        self.reporter.stop()
Ejemplo n.º 8
0
    def test_send_batch(self, mock):
        self.reporter = GraphiteReporter("localhost", 3334, pickle=True, batch_size=2)

        Metrology.meter("meter").mark()
        Metrology.counter("counter").increment()
        Metrology.timer("timer").update(5)
        Metrology.utilization_timer("utimer").update(5)
        Metrology.histogram("histogram").update(5)
        self.reporter.write()
        self.assertTrue(mock.sendall.assert_called())
        self.assertEqual(25, len(mock.sendall.call_args_list))
        self.reporter.stop()
Ejemplo n.º 9
0
    def test_udp_send_batch(self, mock):
        self.reporter = StatsDReporter('localhost', 3333,
                                       batch_size=2, conn_type='udp')

        Metrology.meter('meter').mark()
        Metrology.counter('counter').increment()
        Metrology.timer('timer').update(5)
        Metrology.utilization_timer('utimer').update(5)
        Metrology.histogram('histogram').update(5)
        self.reporter.write()
        self.assertTrue(mock.sendto.called)
        self.assertEqual(3, len(mock.sendto.call_args_list))
        self.reporter.stop()
Ejemplo n.º 10
0
    def test_udp_send_batch(self, mock):
        self.reporter = StatsDReporter('localhost',
                                       3333,
                                       batch_size=2,
                                       conn_type='udp')

        Metrology.meter('meter').mark()
        Metrology.counter('counter').increment()
        Metrology.timer('timer').update(5)
        Metrology.utilization_timer('utimer').update(5)
        Metrology.histogram('histogram').update(5)
        self.reporter.write()
        self.assertTrue(mock.sendto.called)
        self.assertEqual(3, len(mock.sendto.call_args_list))
        self.reporter.stop()
Ejemplo n.º 11
0
    def __init__(self,
                 name,
                 configId=None,
                 scheduleIntervalSeconds=None,
                 taskConfig=None):
        super(ConfigurationLoaderTask, self).__init__()
        self._fetchConfigTimer = Metrology.timer('collectordaemon.configs')

        # Needed for interface
        self.name = name
        self.configId = configId if configId else name
        self.state = TaskStates.STATE_IDLE

        self._dataService = zope.component.queryUtility(IDataService)
        self._eventService = zope.component.queryUtility(IEventService)

        if taskConfig is None:
            raise TypeError("taskConfig cannot be None")
        self._prefs = taskConfig
        self.interval = self._prefs.configCycleInterval * 60
        self.options = self._prefs.options

        self._daemon = zope.component.getUtility(ICollector)
        self._daemon.heartbeatTimeout = self.options.heartbeatTimeout
        log.debug("Heartbeat timeout set to %ds", self._daemon.heartbeatTimeout)

        frameworkFactory = zope.component.queryUtility(IFrameworkFactory, self._frameworkFactoryName)
        self._configProxy = frameworkFactory.getConfigurationProxy()

        self.devices = []
        self.startDelay=0
Ejemplo n.º 12
0
    def __init__(self, dmd):
        self.dmd = dmd
        self._manager = Manager(self.dmd)
        self._pipes = (EventPluginPipe(self._manager, IPreEventPlugin,
                                       'PreEventPluginPipe'),
                       CheckInputPipe(self._manager),
                       IdentifierPipe(self._manager),
                       AddDeviceContextAndTagsPipe(self._manager),
                       TransformAndReidentPipe(
                           self._manager, TransformPipe(self._manager), [
                               UpdateDeviceContextAndTagsPipe(self._manager),
                               IdentifierPipe(self._manager),
                               AddDeviceContextAndTagsPipe(self._manager),
                           ]),
                       AssignDefaultEventClassAndTagPipe(self._manager),
                       FingerprintPipe(self._manager),
                       SerializeContextPipe(self._manager),
                       EventPluginPipe(self._manager, IPostEventPlugin,
                                       'PostEventPluginPipe'),
                       ClearClassRefreshPipe(self._manager),
                       CheckHeartBeatPipe(self._manager))
        self._pipe_timers = {}
        for pipe in self._pipes:
            timer_name = pipe.name
            self._pipe_timers[timer_name] = Metrology.timer(timer_name)

        self.reporter = MetricReporter(prefix='zenoss.zeneventd.')
        self.reporter.start()

        if not self.SYNC_EVERY_EVENT:
            # don't call sync() more often than 1 every 0.5 sec
            # helps throughput when receiving events in bursts
            self.nextSync = time()
            self.syncInterval = 0.5
Ejemplo n.º 13
0
    def __init__(self,
                 name,
                 configId=None,
                 scheduleIntervalSeconds=None,
                 taskConfig=None):
        super(ConfigurationLoaderTask, self).__init__()
        self._fetchConfigTimer = Metrology.timer('collectordaemon.configs')

        # Needed for interface
        self.name = name
        self.configId = configId if configId else name
        self.state = TaskStates.STATE_IDLE

        self._dataService = zope.component.queryUtility(IDataService)
        self._eventService = zope.component.queryUtility(IEventService)

        if taskConfig is None:
            raise TypeError("taskConfig cannot be None")
        self._prefs = taskConfig
        self.interval = self._prefs.configCycleInterval * 60
        self.options = self._prefs.options

        self._daemon = zope.component.getUtility(ICollector)
        self._daemon.heartbeatTimeout = self.options.heartbeatTimeout
        log.debug("Heartbeat timeout set to %ds",
                  self._daemon.heartbeatTimeout)

        frameworkFactory = zope.component.queryUtility(
            IFrameworkFactory, self._frameworkFactoryName)
        self._configProxy = frameworkFactory.getConfigurationProxy()

        self.devices = []
        self.startDelay = 0
Ejemplo n.º 14
0
    def __init__(self, application, reporter=None, **kwargs):
        self.application = application
        self.request = Metrology.meter('request')
        self.request_time = Metrology.timer('request_time')

        # Start reporter
        if reporter:
            reporter.start()
Ejemplo n.º 15
0
    def __init__(self, zenhub, service):
        self.zenhub = zenhub
        self.service = service
        self._serviceCalls = Metrology.meter("zenhub.serviceCalls")
        self.log = logging.getLogger('zen.zenhub.WorkerInterceptor')
        self._admTimer = Metrology.timer('zenhub.applyDataMap')
        self._eventsSent = Metrology.meter("zenhub.eventsSent")

        self.meters = {
            'sendEvent': self.mark_send_event_timer,
            'sendEvents': self.mark_send_events_timer,
            'applyDataMaps': self.mark_apply_datamaps_timer,
        }
Ejemplo n.º 16
0
 def __init__(self, options, log):
     self.options = options
     self.transformers = _load_utilities(ICollectorEventTransformer)
     self.log = log
     self.discarded_events = 0
     # TODO: Do we want to limit the size of the clear event dictionary?
     self.clear_events_count = {}
     self._initQueues()
     self._eventsSent = Metrology.meter("collectordaemon.eventsSent")
     self._discardedEvents = Metrology.meter("collectordaemon.discardedEvent")
     self._eventTimer = Metrology.timer('collectordaemon.eventTimer')
     metricNames = {x[0] for x in registry}
     if 'collectordaemon.eventQueue' not in metricNames:
         queue = self
         class EventQueueGauge(Gauge):
             @property
             def value(self):
                 return queue.event_queue_length
         Metrology.gauge('collectordaemon.eventQueue', EventQueueGauge())
Ejemplo n.º 17
0
    def __init__(self, dmd):
        self.dmd = dmd
        self._manager = Manager(self.dmd)
        self._pipes = (
            EventPluginPipe(
                self._manager, IPreEventPlugin, 'PreEventPluginPipe'
            ),
            CheckInputPipe(self._manager),
            IdentifierPipe(self._manager),
            AddDeviceContextAndTagsPipe(self._manager),
            TransformAndReidentPipe(
                self._manager,
                TransformPipe(self._manager),
                [
                    UpdateDeviceContextAndTagsPipe(self._manager),
                    IdentifierPipe(self._manager),
                    AddDeviceContextAndTagsPipe(self._manager),
                ]
            ),
            AssignDefaultEventClassAndTagPipe(self._manager),
            FingerprintPipe(self._manager),
            SerializeContextPipe(self._manager),
            EventPluginPipe(
                self._manager, IPostEventPlugin, 'PostEventPluginPipe'
            ),
            ClearClassRefreshPipe(self._manager),
            CheckHeartBeatPipe(self._manager)
        )
        self._pipe_timers = {}
        for pipe in self._pipes:
            timer_name = pipe.name
            self._pipe_timers[timer_name] = Metrology.timer(timer_name)

        self.reporter = MetricReporter(prefix='zenoss.zeneventd.')
        self.reporter.start()

        if not self.SYNC_EVERY_EVENT:
            # don't call sync() more often than 1 every 0.5 sec
            # helps throughput when receiving events in bursts
            self.nextSync = time()
            self.syncInterval = 0.5
Ejemplo n.º 18
0
    def __init__(self, options, log):
        self.options = options
        self.transformers = _load_utilities(ICollectorEventTransformer)
        self.log = log
        self.discarded_events = 0
        # TODO: Do we want to limit the size of the clear event dictionary?
        self.clear_events_count = {}
        self._initQueues()
        self._eventsSent = Metrology.meter("collectordaemon.eventsSent")
        self._discardedEvents = Metrology.meter(
            "collectordaemon.discardedEvent")
        self._eventTimer = Metrology.timer('collectordaemon.eventTimer')
        metricNames = {x[0] for x in registry}
        if 'collectordaemon.eventQueue' not in metricNames:
            queue = self

            class EventQueueGauge(Gauge):
                @property
                def value(self):
                    return queue.event_queue_length

            Metrology.gauge('collectordaemon.eventQueue', EventQueueGauge())
Ejemplo n.º 19
0
    def __init__(self, modeling_paused=None):
        """Initializes a ZenHubWorklist object.

        If an argument is provided for the modeling_paused parameter,
        it should be function that takes no arguments and returns True
        to exclude modeling related priorities for job selection.
        """
        if modeling_paused is None:
            self.__modeling_paused = bool  # always False
        else:
            self.__modeling_paused = modeling_paused

        # Associate a list with each priority
        self.__worklists = {priority: [] for priority in ZenHubPriority}

        # All jobs priority selection
        self.__alljobs = _PrioritySelection(_all_priorities)

        # No ApplyDataMaps priority selection
        self.__noadmjobs = _PrioritySelection(_no_adm_priorities)

        # Metric for wait time in worklist
        self.__waitTimer = Metrology.timer("zenhub.worklist.wait_time")
Ejemplo n.º 20
0
def _getPrepublishingTimer():
    global _prepublishing_timer
    if not _prepublishing_timer:
        _prepublishing_timer = Metrology.timer("MessagePrePublishingEvents")
    return _prepublishing_timer
Ejemplo n.º 21
0
 def test_request(self):
     self.server.get('/')
     self.assertEqual(1, Metrology.meter('request').count)
     self.assertEqual(1, Metrology.timer('request_time').count)
Ejemplo n.º 22
0
 def test_timer(self):
     self.assertTrue(Metrology.timer('test') is not None)
Ejemplo n.º 23
0
def _getPrepublishingTimer():
    global _prepublishing_timer
    if not _prepublishing_timer:
        _prepublishing_timer =  Metrology.timer("MessagePrePublishingEvents")
    return _prepublishing_timer
Ejemplo n.º 24
0
from Products.ZenUtils.AmqpDataManager import AmqpDataManager
from Products.ZenMessaging.ChangeEvents.events import MessagePrePublishingEvent
from Products.ZenMessaging.queuemessaging.interfaces import IModelProtobufSerializer, IQueuePublisher, IProtobufSerializer, IEventPublisher
from contextlib import closing
from zenoss.protocols.protobufutil import ProtobufEnum
from zenoss.protocols.protobufs import modelevents_pb2
from zenoss.protocols.protobufs.zep_pb2 import Event
from zenoss.protocols.interfaces import IQueueSchema, IAMQPConnectionInfo

import logging

log = logging.getLogger('zen.queuepublisher')

MODEL_TYPE = ProtobufEnum(modelevents_pb2.ModelEvent, 'model_type')

_prepublishing_timer = Metrology.timer("MessagePrePublishingEvents")

class ModelChangePublisher(object):
    """
    Keeps track of all the model changes so far in this
    transaction. Do not instantiate this class directly,
    use "getModelChangePublisher" to receive the singleton
    """

    def __init__(self):
        self._events = []
        self._msgs = []
        self._addedGuids = set()
        self._modifiedGuids = set()
        self._removedGuids = set()
        self._publishable = []
Ejemplo n.º 25
0
 def __init__(self):
     self.timer = Metrology.timer('mytimer')
Ejemplo n.º 26
0
 def __init__(self, processor):
     BaseQueueConsumerTask.__init__(self, processor)
     self.processing_timer = Metrology.timer('processMessage')