Beispiel #1
0
 def stop(self):
     """ Stop the nodes connection and stop asyncore.loop thread """
     LOGGER.info("Stopping")
     self._running = False
     for node in self.values():
         node.close()
     self.thread.join()
Beispiel #2
0
 def start(self):
     """ Connect all nodes and run asyncore.loop in a thread """
     self._running = True
     for node in self.values():
         node.start()
     self.thread.start()
     LOGGER.info("Aggregator started")
Beispiel #3
0
def main(args=None):
    """ Aggregate all nodes radio sniffer """
    args = args or sys.argv[1:]
    opts = SnifferAggregator.parser.parse_args(args)
    try:
        # Parse arguments
        nodes_list = SnifferAggregator.select_nodes(opts)
        if opts.debug:
            LOGGER.setLevel(logging.DEBUG)
        # Run the aggregator
        with SnifferAggregator(nodes_list, opts.outfd, opts.raw) as aggregator:
            aggregator.run()
            LOGGER.info('%u packets captured', aggregator.rx_packets)
    except (ValueError, RuntimeError) as err:
        sys.stderr.write("%s\n" % err)
        exit(1)
def main(args=None):
    """ Aggregate all nodes radio sniffer """
    args = args or sys.argv[1:]
    opts = SnifferAggregator.parser.parse_args(args)
    try:
        # Parse arguments
        nodes_list = SnifferAggregator.select_nodes(opts)
        if opts.debug:
            LOGGER.setLevel(logging.DEBUG)
        # Run the aggregator
        with SnifferAggregator(nodes_list, opts.outfd, opts.raw) as aggregator:
            aggregator.run()
            LOGGER.info('%u packets captured', aggregator.rx_packets)
    except (ValueError, RuntimeError) as err:
        sys.stderr.write("{}\n".format(err))
        exit(1)
Beispiel #5
0
 def handle_data(self, data):
     """ Dummy handle data """
     LOGGER.info("%s received %u bytes", self.hostname, len(data))
     return ''  # Remaining unprocessed data
Beispiel #6
0
 def _loop(self):
     """ Run asyncore loop send SIGINT at the end to stop main process """
     asyncore.loop(timeout=1, use_poll=True)
     if self._running:  # Don't send signal if we are stopping
         LOGGER.info("Loop finished, all connection closed")
         os.kill(os.getpid(), signal.SIGINT)