example_capture

    An example capture script

    Change the network interface by ``export CAP_DEVICE=eth0``

def example_capture():
    """example_capture

    An example capture script

    Change the network interface by ``export CAP_DEVICE=eth0``

    """

    dev = ev(
        "CAP_DEVICE",
        "lo")

    """
    Ignore ports for forwarding to consolidators:

    Redis Internal VM: 6379, 16379
    RabbitMQ Internal VM: 5672, 15672, 25672
    """

    # http://biot.com/capstats/bpf.html
    custom_filter = ("(udp and portrange 10000-17001) "
                     "or (tcp and portrange 80) "
                     "or arp "
                     "or icmp")

    log.info(("starting device={} filter={}")
             .format(
                dev,
                custom_filter))

    kamene.sniff(
        filter=custom_filter,
        prn=handle_packets)

    log.info("done")