Beispiel #1
0
    def processMessage(self, message):
        """Parse a message and post it as a metric."""

        if self.factory.verbose:
            log.listener("Message received: %s" % (message,))

        metric = message.routing_key

        for line in message.content.body.split("\n"):
            try:
                if settings.get("AMQP_METRIC_NAME_IN_BODY", False):
                    metric, value, timestamp = line.strip().split()
                else:
                    value, timestamp = line.strip().split()
                datapoint = ( float(timestamp), float(value) )
            except ValueError:
                log.listener("invalid message line: %s" % (line,))
                continue

            increment('metricsReceived')
            metricReceived(metric, datapoint)

            if self.factory.verbose:
                log.listener("Metric posted: %s %s %s" %
                             (metric, value, timestamp,))
    def processMessage(self, message, channel):
        """Parse a message and post it as a metric."""

        if self.factory.verbose:
            log.listener("Message received: %s" % (message,))

        metric = message.routing_key

        for line in message.content.body.split("\n"):
            line = line.strip()
            if not line:
                continue
            try:
                #log.listener("Trying...")
            #    if settings.get("AMQP_METRIC_NAME_IN_BODY", False):
            #        metric, value, timestamp = line.split()
            #        log.listener("Metric in body")
            #    else:
            #        log.listener("Metric not in body") 
                value, timestamp = line.split()
                #log.listener("Value:%f   Timestamp:%f"%(float(value),float(timestamp))) 
                datapoint = ( float(timestamp), float(value) )
            except ValueError:
                log.listener("invalid message line: %s" % (line,))
                continue

            events.metricReceived(metric, datapoint)

            if self.factory.verbose:
                log.listener("Metric posted: %s %s %s" %
                             (metric, value, timestamp,))
        log.msg("Acking...")  
        channel.basic_ack(delivery_tag = message.delivery_tag, multiple = False)
        log.msg("Ack Done!!")
Beispiel #3
0
    def processMessage(self, message, channel):
        """Parse a message and post it as a metric."""

        if self.factory.verbose:
            log.listener("Message received: %s" % (message,))

        metric = message.routing_key

        for line in message.content.body.split("\n"):
            line = line.strip()
            if not line:
                continue
            try:
                #log.listener("Trying...")
            #    if settings.get("AMQP_METRIC_NAME_IN_BODY", False):
            #        metric, value, timestamp = line.split()
            #        log.listener("Metric in body")
            #    else:
            #        log.listener("Metric not in body") 
                value, timestamp = line.split()
                #log.listener("Value:%f   Timestamp:%f"%(float(value),float(timestamp))) 
                datapoint = ( float(timestamp), float(value) )
            except ValueError:
                log.listener("invalid message line: %s" % (line,))
                continue

            events.metricReceived(metric, datapoint)

            if self.factory.verbose:
                log.listener("Metric posted: %s %s %s" %
                             (metric, value, timestamp,))
        channel.basic_ack(delivery_tag = message.delivery_tag, multiple = False)
Beispiel #4
0
    def processMessage(self, message):
        """Parse a message and post it as a metric."""

        if self.factory.verbose:
            log.listener("Message received: %s" % (message, ))

        metric = message.routing_key

        for line in message.content.body.split("\n"):
            line = line.strip()
            if not line:
                continue
            try:
                if settings.get("AMQP_METRIC_NAME_IN_BODY", False):
                    metric, value, timestamp = line.split()
                else:
                    value, timestamp = line.split()
                datapoint = (float(timestamp), float(value))
                if datapoint[1] != datapoint[1]:  # filter out NaN values
                    continue
            except ValueError:
                log.listener("invalid message line: %s" % (line, ))
                continue

            events.metricReceived(metric, datapoint)

            if self.factory.verbose:
                log.listener("Metric posted: %s %s %s" % (
                    metric,
                    value,
                    timestamp,
                ))
Beispiel #5
0
 def metricReceived(self, metric, datapoint):
     if BlackList and metric in BlackList:
         instrumentation.increment('blacklistMatches')
         return
     if WhiteList and metric not in WhiteList:
         instrumentation.increment('whitelistRejects')
         return
     if datapoint[1] == datapoint[1]:  # filter out NaN values
         events.metricReceived(metric, datapoint)
Beispiel #6
0
  def lineReceived(self, line):
    try:
      metric, value, timestamp = line.strip().split()
      datapoint = ( float(timestamp), float(value) )
    except:
      log.listener('invalid line received from client %s, ignoring' % self.peerName)
      return

    events.metricReceived(metric, datapoint)
Beispiel #7
0
 def metricReceived(self, metric, datapoint):
   if BlackList and metric in BlackList:
     instrumentation.increment('blacklistMatches')
     return
   if WhiteList and metric not in WhiteList:
     instrumentation.increment('whitelistRejects')
     return
   if datapoint[1] == datapoint[1]: # filter out NaN values
     events.metricReceived(metric, datapoint)
Beispiel #8
0
  def lineReceived(self, line):
    try:
      metric, value, timestamp = line.strip().split()
      datapoint = ( float(timestamp), float(value) )
    except:
      log.listener('invalid line received from client %s, disconnecting' % self.peerAddr)
      self.transport.loseConnection()
      return

    increment('metricsReceived')
    metricReceived(metric, datapoint)
Beispiel #9
0
    def lineReceived(self, line):
        try:
            metric, value, timestamp = line.strip().split()
            datapoint = (float(timestamp), float(value))
        except:
            log.listener('invalid line received from client %s, ignoring' %
                         self.peerAddr)
            return

        increment('metricsReceived')
        metricReceived(metric, datapoint)
Beispiel #10
0
    def metricReceived(self, metric, datapoint):
        if BlackList and metric in BlackList:
            instrumentation.increment('blacklistMatches')
            return
        if WhiteList and metric not in WhiteList:
            instrumentation.increment('whitelistRejects')
            return
        if datapoint[1] != datapoint[1]:  # filter out NaN values
            return
        if int(datapoint[0]) == -1:  # use current time if none given
            datapoint = (time.time(), datapoint[1])

        events.metricReceived(metric, datapoint)
Beispiel #11
0
 def metricReceived(self, metric, datapoint):
   if BlackList and metric in BlackList:
     instrumentation.increment('blacklistMatches')
     return
   if WhiteList and metric not in WhiteList:
     instrumentation.increment('whitelistRejects')
     return
   if datapoint[1] != datapoint[1]: # filter out NaN values
     return
   if int(datapoint[0]) == -1: # use current time if none given: https://github.com/graphite-project/carbon/issues/54
     datapoint = (time.time(), datapoint[1])
   
   events.metricReceived(metric, datapoint)
Beispiel #12
0
 def metricReceived(self, metric, datapoint):
   if BlackList and metric in BlackList:
     instrumentation.increment('blacklistMatches')
     return
   if WhiteList and metric not in WhiteList:
     instrumentation.increment('whitelistRejects')
     return
   if datapoint[1] != datapoint[1]: # filter out NaN values
     return
   if int(datapoint[0]) == -1: # use current time if none given: https://github.com/graphite-project/carbon/issues/54
     datapoint = (time.time(), datapoint[1])
   
   events.metricReceived(metric, datapoint)
   self.resetTimeout()
Beispiel #13
0
  def stringReceived(self, data):
    try:
      datapoints = pickle.loads(data)
    except:
      log.listener('invalid pickle received from client %s, disconnecting' % self.peerAddr)
      self.transport.loseConnection()
      return

    for (metric, datapoint) in datapoints:
      datapoint = ( float(datapoint[0]), float(datapoint[1]) ) #force proper types
      if datapoint[1] == datapoint[1]: # filter out NaN values
        metricReceived(metric, datapoint)

    increment('metricsReceived', len(datapoints))
Beispiel #14
0
  def metricReceived(self, metric, datapoint):
    if blocked_metrics and metric in blocked_metrics:
      instrumentation.increment('blocked_metricsMatches')
      return
    if allowed_metrics and metric not in allowed_metrics:
      instrumentation.increment('allowed_metricsRejects')
      return
    if datapoint[1] != datapoint[1]: # filter out NaN values
      return
    if int(datapoint[0]) == -1: # use current time if none given: https://github.com/graphite-project/carbon/issues/54
      datapoint = (time.time(), datapoint[1])

    events.metricReceived(metric, datapoint)
    self.resetTimeout()
Beispiel #15
0
  def stringReceived(self, data):
    try:
      datapoints = pickle.loads(data)
    except:
      log.listener('invalid pickle received from %s, ignoring' % self.peerName)
      return

    for (metric, datapoint) in datapoints:
      try:
        datapoint = ( float(datapoint[0]), float(datapoint[1]) ) #force proper types
      except:
        continue

      if datapoint[1] == datapoint[1]: # filter out NaN values
        events.metricReceived(metric, datapoint)
Beispiel #16
0
 def metricReceived(self, metric, datapoint):
   if BlackList and metric in BlackList:
     instrumentation.increment('blacklistMatches')
     return
   if WhiteList and metric not in WhiteList:
     instrumentation.increment('whitelistRejects')
     return
   if datapoint[1] != datapoint[1]:  # filter out NaN values
     return
   # use current time if none given: https://github.com/graphite-project/carbon/issues/54
   if int(datapoint[0]) == -1:
     datapoint = (time.time(), datapoint[1])
   res = settings.MIN_TIMESTAMP_RESOLUTION
   if res:
     datapoint = (int(datapoint[0]) // res * res, datapoint[1])
   events.metricReceived(metric, datapoint)
   self.resetTimeout()
Beispiel #17
0
    def stringReceived(self, data):
        try:
            datapoints = pickle.loads(data)
        except:
            log.listener('invalid pickle received from client %s, ignoring' %
                         self.peerAddr)
            return

        for (metric, datapoint) in datapoints:
            try:
                datapoint = (float(datapoint[0]), float(datapoint[1])
                             )  #force proper types
            except:
                continue

            if datapoint[1] == datapoint[1]:  # filter out NaN values
                metricReceived(metric, datapoint)

        increment('metricsReceived', len(datapoints))
 def metricReceived(self, metric, datapoint):
   if datapoint[1] == datapoint[1]: # filter out NaN values
     events.metricReceived(metric, datapoint)