How to continuously feed sniffed packets to kafka?

前端 未结 4 1600
清酒与你
清酒与你 2021-01-21 04:56

Currently I am sniffing packets from my local wlan interface like :

sudo tshark > sampleData.pcap

However, I need to feed this data to kafka.

4条回答
  •  萌比男神i
    2021-01-21 05:05

    With netcat

    No need to write a server, you can use netcat (and tell your script to listen on the standard input):

    shell1> nc -l 8888 | ./producer.sh
    shell2> sudo tshark -l | nc 127.1 8888
    

    The -l of tshark prevents it from buffering the output too much (flushes after each packet).


    With a named pipe

    You could also use a named pipe to transmit tshark output to your second process:

    shell1> mkfifo /tmp/tsharkpipe
    shell1> tail -f -c +0 /tmp/tsharkpipe | ./producer.sh
    shell2> sudo tshark -l > /tmp/tsharkpipe
    

提交回复
热议问题