Exemple #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
Exemple #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
Exemple #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) )
Exemple #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))
Exemple #5
0
 def clientConnectionFailed(self, connector, reason):
   ReconnectingClientFactory.clientConnectionFailed(self, connector, reason)
   log.aggregator("connection attempt to %s failed: %s" % (self.remoteAddr, reason.value))
Exemple #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))
Exemple #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
Exemple #8
0
 def startedConnecting(self, connector):
   log.aggregator('connecting to %s' % self.remoteAddr)
Exemple #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]
Exemple #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]
Exemple #11
0
 def clientConnectionFailed(self, connector, reason):
     ReconnectingClientFactory.clientConnectionFailed(
         self, connector, reason)
     log.aggregator("connection attempt to %s failed: %s" %
                    (self.remoteAddr, reason.value))
Exemple #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))
Exemple #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
Exemple #14
0
 def startedConnecting(self, connector):
     log.aggregator('connecting to %s' % self.remoteAddr)