Monitoring HTTP requests from the command line
network | rafacas | (0)
Some days ago Javisantana sent me a tweet with a link to a one-liner HTTP requests monitor.
It goes as follows with some ouput added:
$ sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"
Password:
tcpdump: listening on en1, link-type EN10MB (Ethernet), capture size 65535 bytes
GET / HTTP/1.1
Host: commandliners.com
GET / HTTP/1.1
Host: google.com
GET / HTTP/1.1
Host: www.google.com
GET / HTTP/1.1
Host: www.google.es
GET /intl/en_com/images/logo_plain.png HTTP/1.1
Host: www.google.es
[...]
Replace en1 with your network interface's name. Usually enX in BSD-like OSes and ethX in Linux.
You can create an alias named httpdump and add it to ~/.bash_profile:
alias httpdump='sudo tcpdump -i en1 -n -s 0 -w ...