Exemplo n.º 1
0
    def read_rules(self):
        if not exists(self.rules_file):
            self.clear()
            return

        # Only read if the rules file has been modified
        try:
            mtime = getmtime(self.rules_file)
        except OSError:
            log.err("Failed to get mtime of %s" % self.rules_file)
            return
        if mtime <= self.rules_last_read:
            return

        # Read new rules
        log.aggregator("reading new aggregation rules from %s" %
                       self.rules_file)
        new_rules = []
        for line in open(self.rules_file):
            line = line.strip()
            if line.startswith('#') or not line:
                continue

            rule = self.parse_definition(line)
            new_rules.append(rule)

        log.aggregator("clearing aggregation buffers")
        BufferManager.clear()
        self.rules = new_rules
        self.rules_last_read = mtime
Exemplo n.º 2
0
  def read_rules(self):
    if not exists(self.rules_file):
      self.clear()
      return

    # Only read if the rules file has been modified
    try:
      mtime = getmtime(self.rules_file)
    except OSError:
      log.err("Failed to get mtime of %s" % self.rules_file)
      return
    if mtime <= self.rules_last_read:
      return

    # Read new rules
    log.aggregator("reading new aggregation rules from %s" % self.rules_file)
    new_rules = []
    for line in open(self.rules_file):
      line = line.strip()
      if line.startswith('#') or not line:
        continue

      rule = self.parse_definition(line)
      new_rules.append(rule)

    log.aggregator("clearing aggregation buffers")
    BufferManager.clear()
    self.rules = new_rules
    self.rules_last_read = mtime
Exemplo n.º 3
0
  def send(self, metric, datapoint):
    if len(self.queue) >= settings.MAX_QUEUE_SIZE:
      log.aggregator('send queue full for %s, dropping data' % self.remoteAddr)

    elif self.connectedProtocol:
      self.connectedProtocol.send(metric, datapoint)

    else:
      self.queue.append( (metric, datapoint) )
Exemplo n.º 4
0
    def send(self, metric, datapoint):
        if len(self.queue) >= settings.MAX_QUEUE_SIZE:
            log.aggregator('send queue full for %s, dropping data' %
                           self.remoteAddr)

        elif self.connectedProtocol:
            self.connectedProtocol.send(metric, datapoint)

        else:
            self.queue.append((metric, datapoint))
Exemplo n.º 5
0
 def clientConnectionFailed(self, connector, reason):
   ReconnectingClientFactory.clientConnectionFailed(self, connector, reason)
   log.aggregator("connection attempt to %s failed: %s" % (self.remoteAddr, reason.value))
Exemplo n.º 6
0
 def clientConnectionLost(self, connector, reason):
   ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
   self.connectedProtocol = None
   log.aggregator("connection to %s lost: %s" % (self.remoteAddr, reason.value))
Exemplo n.º 7
0
 def buildProtocol(self, addr):
   log.aggregator('connection to %s established' % self.remoteAddr)
   self.connectedProtocol = MetricPickleSender()
   self.connectedProtocol.factory = self
   self.connectedProtocol.queue = self.queue
   return self.connectedProtocol
Exemplo n.º 8
0
 def startedConnecting(self, connector):
   log.aggregator('connecting to %s' % self.remoteAddr)
Exemplo n.º 9
0
  def get_buffer(self, metric_path):
    if metric_path not in self.buffers:
      log.aggregator("Allocating new buffer for %s" % metric_path)
      self.buffers[metric_path] = AggregationBuffer(metric_path)

    return self.buffers[metric_path]
Exemplo n.º 10
0
    def get_buffer(self, metric_path):
        if metric_path not in self.buffers:
            log.aggregator("Allocating new metric buffer for %s" % metric_path)
            self.buffers[metric_path] = MetricBuffer(metric_path)

        return self.buffers[metric_path]
Exemplo n.º 11
0
 def clientConnectionFailed(self, connector, reason):
     ReconnectingClientFactory.clientConnectionFailed(
         self, connector, reason)
     log.aggregator("connection attempt to %s failed: %s" %
                    (self.remoteAddr, reason.value))
Exemplo n.º 12
0
 def clientConnectionLost(self, connector, reason):
     ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
     self.connectedProtocol = None
     log.aggregator("connection to %s lost: %s" %
                    (self.remoteAddr, reason.value))
Exemplo n.º 13
0
 def buildProtocol(self, addr):
     log.aggregator('connection to %s established' % self.remoteAddr)
     self.connectedProtocol = MetricPickleSender()
     self.connectedProtocol.factory = self
     self.connectedProtocol.queue = self.queue
     return self.connectedProtocol
Exemplo n.º 14
0
 def startedConnecting(self, connector):
     log.aggregator('connecting to %s' % self.remoteAddr)