Currently I am sniffing packets from my local wlan interface like :
sudo tshark > sampleData.pcap
However, I need to feed this data to kafka.
If you use Node, you can use child_process
and kafka_node
to do it. Something like this:
var kafka = require('kafka-node');
var client = new kafka.Client('localhost:2181');
var producer = new kafka.Producer(client);
var spawn = require('child_process').spawn;
var tshark = spawn('sudo', ['/usr/sbin/tshark']);
tshark.stdout.on('data', (data) => {
producer.send([
{topic: 'spark-kafka', messages: [data.split("\n")]}
], (err,result) => { console.log("sent to kafka")});
});