示例#1
0
文件: coven.py 项目: koendc/ExtreMon
 def run(self):
     self.running = True
     self.log("running")
     self.cauldron = CauldronSender(self.cauldronAddr,
                                    max_shuttle_size=512,
                                    max_shuttle_age=.2)
     for recordBytes in self.plugin:
         if not self.running:
             return
         if len(recordBytes) > 1:
             try:
                 record = str(recordBytes, 'UTF-8')
                 (label, value) = record.rstrip().split('=')
                 try:
                     allow = self.allowCache[label]
                 except KeyError:
                     self.count('new_labels_per_second', 1)
                     allow = (self.outFilter.search(label) != None)
                     self.allowCache[label] = allow
                     self.labels_allowed += 1
                 if allow:
                     self.cauldron.put(label, value)
                     self.count('records_per_second', 1)
                     self.count('bytes_per_second', len(recordBytes))
                 else:
                     self.log(
                         "Label [%s] does not match filter (%s)" %
                         (label, self.outFilterExpr), syslog.LOG_WARNING)
             except ValueError:
                 self.log(
                     "Can't Parse [%s] [%s]" %
                     (str(recordBytes, 'utf-8').rstrip(), ''.join(
                         ['%02x' % (thebyte) for thebyte in recordBytes])))
         else:
             self.count('shuttles_per_second', 1)
示例#2
0
文件: coven.py 项目: koendc/ExtreMon
 def __init__(self,
              path,
              prefix,
              cauldronAddr,
              ignore=[
                  r'^\.', r'\.x?swp$', r'~', r'^__', r'__$', r'\.jar$',
                  r'\.db$'
              ]):
     syslog.openlog(ident="X3Coven", facility=syslog.LOG_DAEMON)
     self.path = path
     self.prefix = prefix
     self.cauldronAddr = cauldronAddr
     self.plugins = {}
     self.plugins_lock = Lock()
     self.confRE = re.compile('^#\\s*x3\.([a-z0-9.]+)\\s*=\\s*(.*)\\s*$')
     self.dirManager = DirManager(self.path, self, ignore=ignore)
     self.cauldron = CauldronSender(self.cauldronAddr)