Useful Varnish 3.0 Commands: one-liners with varnishtop and varnishlogMattias Geniar, Wednesday, June 29, 2011 - last modified: Sunday, February 19, 2012
Here are some useful commands if you're toying around with Varnish and want to get some more insight into what's happening. Varnishtop will show you the hits you're getting in a "top"-like style, so the most active hits are shown on top. Varnishlog simply iterates over all logs and displays them as you would tail a normal log-file.
Top requests to your backend
This shows only the "TxURL", the URL being retrieved from your backend.
# varnishtop -i TxURL # varnishlog -b | grep 'TxURL'
Requests made by a client
This shows only the "RxURL", the URL being requested.
# varnishtop -i RxURL # varnishlog -c | grep 'RxURL'
Show cookies being sent by clients
This will list all HTTP headers with a "Cookie" keyword in the request that are being sent to Varnish.
# varnishtop -i RxHeader -I Cookie # varnishlog -c | grep 'Cookie: '
Which host is being requested the most
Only really useful when you're serving multiple hosts in Varnish.
varnishtop -i RxHeader -I '^Host:' varnishlog -i RxHeader | grep 'Host: '
There's plenty more useful & small Varnish commands, if you have some more feel free to add them to the comments!