Skip to content

Instantly share code, notes, and snippets.

@spraints
Created May 7, 2013 19:07
Show Gist options
  • Save spraints/5535231 to your computer and use it in GitHub Desktop.
Save spraints/5535231 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Make sure sudoing works first, because tcpdump is going in the background
sudo -p "Root privileges are required in order to run tcpdump. Password: " test
pcap=$TMPDIR/nethog.$$.pcap
# 10.0.1.1 is my LAN's AirPort Extreme, so it gets lots of backup traffic.
sudo tcpdump -i en0 -w $pcap not host 10.0.1.1 >&/dev/null &
tcpdump_pid=$!
trap '{ kill $tcpdump_pid ; rm -f $pcap ; exit ; }' INT
# Only show as much tcptrace as fits on the screen.
watch -d "tcptrace -b -n $pcap 2>/dev/null"'| head -n $(tput lines)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment