Skip to content

Instantly share code, notes, and snippets.

@rubo77
Last active August 29, 2015 14:26
Show Gist options
  • Save rubo77/102dd5011137783e89e5 to your computer and use it in GitHub Desktop.
Save rubo77/102dd5011137783e89e5 to your computer and use it in GitHub Desktop.
analyses the number of clients that cause traffic during a given time on a Freifunk gateway
duration=$1
tmp=/tmp/traffic.tmp
localnet="10.116.128.0/17"
iface=br-ffki
echo capturing for $duration seconds
(
sleep $duration
pkill -f tcpdump
) &
tcpdump -q -n -i $iface src net $localnet and dst net ! $localnet and dst net ! 224.0.0.0/4 and ! arp | \
cut -d" " -f3 | \
cut -d"." -f1-4 | \
sort | uniq -c | sort -nr > $tmp;
cat $tmp
echo -n "clients that caused traffic during the last $duration seconds: "
wc -l < $tmp
rm $tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment