列出清漆缓存的内容?

时间:2013-01-08 11:36:56

标签: varnish

有没有办法列出清漆缓存存储的内容?此外,以某种方式列出最常见的缓存命中将是很好的。

通过列出发送到后端的内容,我找到了一种查看最常见的缓存未命中的方法:

varnishtop -b -i TxURL

查看我的顶级缓存命中网址是非常有用的。

编辑:我使用的是版本:varnish-3.0.3 revision 9e6a70f

2 个答案:

答案 0 :(得分:20)

我认为你可以提供帮助:

您可以使用varnishncsa的参数“Varnish:hitmiss”。

首先使用以下方法捕获日志样本:

varnishncsa -F '%U%q %{Varnish:hitmiss}x' -n NAME -w /path/requests.logs

然后:

sort -k 1 /path/requests.logs | uniq -c | sort -k 1 -n -r | head -25

答案 1 :(得分:2)

此功能不包含在Varnish中,但您可以轻松添加一些脚本来执行此操作。

  • 首先需要的是将varnishncsa作为服务启动并在日常文件中写入输出。
  • 然后添加至默认输出格式至少%{Varnish:hitmiss}x%U(请参阅varnishncsa doc
  • 最后,编写一些脚本来计算您的热门网址,例如以下内容:
# we admit %{Varnish:hitmiss}x is the first column and %U the second
awk '$0 ~ / hit / { arr[$8]=arr[$8]+1 }END{ for(k in arr) { print arr[k]";"k } }' varnishncsa.log|sort -k 1 -nr |head

随时根据您的具体需求进行更新..