예제 #1
0
파일: udp.py 프로젝트: deferraz/leela
class UdpService(Service, udp_proto.UDP):

    def __init__(self, cfg):
        self.cfg   = cfg
        self.relay = Relay(self.cfg.get("udp", "relay"), "leela.%s.udp.timeline" % config.hostname())

    def forward_packet(self, packet):
        logger.debug("forward: %d" % len(packet))
        self.relay.relay(packet)

    def startService(self):
        reactor.listenUDP(self.cfg.getint("udp", "port"), self, self.cfg.get("udp", "address"))
예제 #2
0
class UdpService(Service, udp_proto.UDP):
    def __init__(self, cfg):
        self.cfg = cfg
        self.relay = Relay(self.cfg.get("udp", "relay"),
                           "leela.%s.udp.timeline" % config.hostname())

    def forward_packet(self, packet):
        logger.debug("forward: %d" % len(packet))
        self.relay.relay(packet)

    def startService(self):
        reactor.listenUDP(self.cfg.getint("udp", "port"), self,
                          self.cfg.get("udp", "address"))
예제 #3
0
class CollectdService(Service, collectd_proto.UDP):

    def __init__(self, cfg):
        self.cfg   = cfg
        self.relay = Relay(self.cfg.get("collectd", "relay"), "leela.%s.collectd.timeline" % config.hostname())

    def recv_metrics(self, metrics):
        logger.debug("recv_metrics: %d" % len(metrics))
        try:
            self.relay.relay(metrics)
        except:
            logger.error("cant relay to peer address")

    def startService(self):
        reactor.listenUDP(self.cfg.getint("collectd", "port"), self, self.cfg.get("collectd", "address"))
예제 #4
0
    def __init__(self, cfg):
        cfg  = cfg
        bus0 = Relay(cfg.get("http", "multicast"), "leela.%s.http.multicast" % config.hostname())
        bus1 = Relay(cfg.get("http", "timeline"), "leela.%s.http.timeline" % config.hostname())
        sto  = cassandra_proto.CassandraProto(cfg)
        app  = web.Application([
            (r"^/v1/version$"                   , http_proto.Version),
            (r"^/v1/data/past24/(.*)"           , http_proto.Past24         , {"storage": sto, "class_" : data.Data}),
            (r"^/v1/data/pastweek/(.*)"         , http_proto.PastWeek       , {"storage": sto, "class_" : data.Data}),
            (r"^/v1/data/(\d+)/(\d+)/(\d+)/(.*)", http_proto.YearMonthDay   , {"storage": sto, "class_" : data.Data}),
            (r"^/v1/data/(\d+)/(\d+)/(.*)"      , http_proto.YearMonth      , {"storage": sto, "class_" : data.Data}),
            (r"^/v1/data/(.*)"                  , http_proto.RangeDataRdwr  , {"storage": sto, "class_" : data.Data, "relay": bus0}),
            (r"^/v1/past24/(.*)"                , http_proto.Past24         , {"storage": sto, "class_" : event.Event}),
            (r"^/v1/pastweek/(.*)"              , http_proto.PastWeek       , {"storage": sto, "class_" : event.Event}),
            (r"^/v1/(\d+)/(\d+)/(\d+)/(.*)"     , http_proto.YearMonthDay   , {"storage": sto, "class_" : event.Event}),
            (r"^/v1/(\d+)/(\d+)/(.*)"           , http_proto.YearMonth      , {"storage": sto, "class_" : event.Event}),
            (r"^/v1/(.*)"                       , http_proto.RangeMetricRdwr, {"storage": sto, "class_" : event.Event, "relay": bus1}),

            (r".*"                              , resthandler.Always404)
            ])
        self.srv = service.MultiService()
        self.srv.addService(service.IService(internet.TCPServer(cfg.getint("http", "port"), app, interface=cfg.get("http", "address"))))
        self.srv.addService(sto)
예제 #5
0
 def __init__(self, cfg):
     self.cfg   = cfg
     self.relay = Relay(self.cfg.get("collectd", "relay"), "leela.%s.collectd.timeline" % config.hostname())
예제 #6
0
 def __init__(self, cfg):
     self.cfg = cfg
     self.relay = Relay(self.cfg.get("udp", "relay"),
                        "leela.%s.udp.timeline" % config.hostname())
예제 #7
0
파일: udp.py 프로젝트: deferraz/leela
 def __init__(self, cfg):
     self.cfg   = cfg
     self.relay = Relay(self.cfg.get("udp", "relay"), "leela.%s.udp.timeline" % config.hostname())