def __init__(self, mcast_addr, listen, prefix): Thread.__init__(self) self.deamon = True self.server = HTTPChaliceServer(listen, prefix) self.receiver = CauldronReceiver(mcast_addr=mcast_addr, handler=self) self.server.start() self.start() self.server.serve_forever()
class StdInCauldronDispatcher: def __init__(self, mcast_addr, prefix): self.server = StdInCauldronServer(prefix, '/home/frank/plugins') self.client = CauldronReceiver(mcast_addr=mcast_addr, handler=self) self.server.start() self.client.receive_forever() def handle_shuttle(self, data): if len(data): self.server.write(data)
class StdInCauldronDispatcher: def __init__(self,mcast_addr,prefix): self.server=StdInCauldronServer(prefix,'/home/frank/plugins') self.client=CauldronReceiver(mcast_addr=mcast_addr,handler=self); self.server.start() self.client.receive_forever() def handle_shuttle(self,data): if len(data): self.server.write(data)
class CauldronToPlugin(Thread,Countable): def __init__(self,name,cauldronAddr,plugin,inFilter,log,outFilter=None): Thread.__init__(self,name="%s (in)" % (name)) Countable.__init__(self) self.daemon=True self.cauldronAddr=cauldronAddr self.plugin=plugin self.allowCache={} self.accu=set() self.inFilter=re.compile(inFilter) self.log=log if outFilter: self.outFilter=re.compile(outFilter) else: self.outFilter=None def run(self): self.running=True self.log("running") self.cauldron=CauldronReceiver(self.cauldronAddr,self) while self.running: self.cauldron.receive_shuttle() def handle_shuttle(self,shuttle): if not self.running: return for (label,value) in shuttle: try: allow=self.allowCache[label] except KeyError: self.count('new_labels_per_second',1) allow= (( self.inFilter.search(label)!=None) and (( self.outFilter==None or not ( self.outFilter.search(label))))) self.allowCache[label]=allow if allow: self.labels_allowed+=1 if allow: self.accu.add("%s=%s" % (label,value)) if len(self.accu)>0: try: databytes=(bytes('%s\n\n' % ('\n'.join(self.accu)),'utf-8')) self.plugin.write(databytes) self.count('bytes_per_second',len(databytes)) self.count('shuttles_per_second',1) self.count('records_per_second',len(self.accu)) self.accu.clear() except IOError: self.running=False def stop(self): self.running=False
class JQueryChaliceDispatcher: def __init__(self,mcast_addr,listen,prefix): self.server=JQueryChaliceServer(listen,prefix) self.client=CauldronReceiver(mcast_addr=mcast_addr,handler=self); self.server.start() self.client.start() self.server.serve_forever() def handle(self,data): if len(data): self.server.write(data)
class TCPCauldronDispatcher: def __init__(self,mcast_addr,listen,prefix): self.server=TCPCauldronServer(listen,prefix) self.client=CauldronReceiver(mcast_addr=mcast_addr,handler=self); self.server.start() self.client.start() self.server.serve_forever() def handle(self,data): if len(data): self.server.write(data)
class HTTPChaliceDispatcher(Thread): def __init__(self, mcast_addr, listen, prefix): Thread.__init__(self) self.deamon = True self.server = HTTPChaliceServer(listen, prefix) self.receiver = CauldronReceiver(mcast_addr=mcast_addr, handler=self) self.server.start() self.start() self.server.serve_forever() def run(self): self.receiver.receive_forever() def handle_shuttle(self, data): self.server.write(data)
class HTTPChaliceDispatcher(Thread): def __init__(self,mcast_addr,listen,prefix): Thread.__init__(self) self.deamon=True self.server=HTTPChaliceServer(listen,prefix) self.receiver=CauldronReceiver(mcast_addr=mcast_addr,handler=self); self.server.start() self.start() self.server.serve_forever() def run(self): self.receiver.receive_forever() def handle_shuttle(self,data): self.server.write(data)
def __init__(self, mcast_addr, listen, prefix): Thread.__init__(self) self.daemon = True self.server = HTTPSelectiveChaliceServer(listen, prefix) self.receiver = CauldronReceiver(mcast_addr=mcast_addr, handler=self) self.server.start() self.start() self.server.serve_forever()
def __init__(self,mcast_addr,listen,prefix): self.server=TCPCauldronServer(listen,prefix) self.client=CauldronReceiver(mcast_addr=mcast_addr,handler=self); self.server.start() self.client.start() self.server.serve_forever()
def __init__(self,mcast_addr,listen,prefix): self.server=JQueryChaliceServer(listen,prefix) self.client=CauldronReceiver(mcast_addr=mcast_addr,handler=self); self.server.start() self.client.start() self.server.serve_forever()
def __init__(self,mcast_addr): CauldronReceiver.__init__(self,mcast_addr,self) self.running=False print("Dump Starting")
# import re; from extremon import CauldronReceiver class Extremon2Graphite: def __init__(self): self.timestamp = 0 def handle_shuttle(self,data): removeItems = set() for (label,value) in data: if re.match(".*\.dispatcher\.timestamp$", label): self.timestamp = value removeItems.add((label,value)) if re.match(".*\.timestamp$", label): self.timestamp = value removeItems.add((label,value)) if re.match(".*\.sequence$", label): removeItems.add((label,value)) if re.match(".*\.comment$", label): removeItems.add((label,value)) for item in removeItems: data.remove(item) for (label,value) in data: print("%s %s %s" % (label,value, self.timestamp)) if __name__=='__main__': source=CauldronReceiver(Extremon2Graphite(),('224.0.0.1',1249)) source.receive_forever()
def run(self): self.running=True self.log("running") self.cauldron=CauldronReceiver(self.cauldronAddr,self) while self.running: self.cauldron.receive_shuttle()
def __init__(self, mcast_addr, prefix): self.server = StdInCauldronServer(prefix, '/home/frank/plugins') self.client = CauldronReceiver(mcast_addr=mcast_addr, handler=self) self.server.start() self.client.receive_forever()
class CauldronToPlugin(Thread, Countable): def __init__(self, name, cauldronAddr, plugin, log, inFilter, inValueFilter=None, outFilter=None, outValueFilter=None, loopProtected=False): Thread.__init__(self, name="%s (in)" % (name)) Countable.__init__(self) self.daemon = True self.cauldronAddr = cauldronAddr self.plugin = plugin self.allowCache = {} self.accu = set() self.inFilter = re.compile(inFilter) self.log = log self.loopProtected = loopProtected if outFilter: self.outFilter = re.compile(outFilter) else: self.outFilter = None if inValueFilter: self.inValueFilter = re.compile(inValueFilter) else: self.inValueFilter = None if outValueFilter: self.outValueFilter = re.compile(outValueFilter) else: self.outValueFilter = None def run(self): self.running = True self.log("running") self.cauldron = CauldronReceiver(self.cauldronAddr, self) while self.running: self.cauldron.receive_shuttle() def handle_shuttle(self, shuttle): if not self.running: return for (label, value) in shuttle: try: allow = self.allowCache[label] except KeyError: self.count('new_labels_per_second', 1) if self.loopProtected: allowLabel = self.inFilter.search(label) != None else: allowLabel = (((self.inFilter.search(label) != None) and (( (self.outFilter == None or not (self.outFilter.search(label) != None)))))) if self.inValueFilter == None: allowValueIn = True else: allowValueIn = self.inValueFilter.match(value) != None if self.outValueFilter == None: allowValueOut = True else: allowValueOut = self.outValueFilter.match(value) != None allow = allowLabel and allowValueIn and allowValueOut self.allowCache[label] = allow if allow: self.labels_allowed += 1 if allow: self.accu.add("%s=%s" % (label, value)) if len(self.accu) > 0: try: databytes = (bytes('%s\n\n' % ('\n'.join(self.accu)), 'utf-8')) self.plugin.write(databytes) self.count('bytes_per_second', len(databytes)) self.count('shuttles_per_second', 1) self.count('records_per_second', len(self.accu)) self.accu.clear() except IOError: self.running = False def stop(self): self.running = False
def __init__(self,mcast_addr,prefix): self.server=StdInCauldronServer(prefix,'/home/frank/plugins') self.client=CauldronReceiver(mcast_addr=mcast_addr,handler=self); self.server.start() self.client.receive_forever()
def run(self): self.running = True self.log("running") self.cauldron = CauldronReceiver(self.cauldronAddr, self) while self.running: self.cauldron.receive_shuttle()
import re from extremon import CauldronReceiver class Extremon2Graphite: def __init__(self): self.timestamp = 0 def handle_shuttle(self, data): removeItems = set() for (label, value) in data: if re.match(".*\.dispatcher\.timestamp$", label): self.timestamp = value removeItems.add((label, value)) if re.match(".*\.timestamp$", label): self.timestamp = value removeItems.add((label, value)) if re.match(".*\.sequence$", label): removeItems.add((label, value)) if re.match(".*\.comment$", label): removeItems.add((label, value)) for item in removeItems: data.remove(item) for (label, value) in data: print("%s %s %s" % (label, value, self.timestamp)) if __name__ == '__main__': source = CauldronReceiver(Extremon2Graphite(), ('224.0.0.1', 1249)) source.receive_forever()