Kristian Lyngstøl's Blog

Varnish, Munin, RRDTool and RPN - Yaaai

Posted on 2009-03-31

I've spent a couple of days working on a new munin-plugin for Varnish, and it's been interesting. First of all, there are several existing Varnish plugins, all slightly different with their own quirks. This new one will replace the plugin in the varnish subversion repo and hopefully enter the list of official munin plugins.

Spent monday setting up the basic plugin, and all day (tuesday) trying to figure out how the heck to display hitrates sanely. The statistics varnish delivers are ever increasing, which munin handles exceptionally well (well, rrdtool does). The only way to display it relatively (in percentages) is to either store history on the node (which is out of the question) or fix it up with a CDEF.

As it turns out, there's a slight bug in Munin trunk with regards to the CDEF-solution, in addition to a lack of working examples of how to do this. Nicolai helped me track down the Munin-issue (patch comming), so then it was only the RPN-insanity...

::
'cdef' => 'client_req,0,EQ,0,cache_miss,client_req,/,100,*,IF'

This little beauty is obviously the equivalent of

if (client_req == 0) {
        0
} else {
        (cache_miss / client_req) * 100
}

That is, if I actually got that right. So in this case, it defaults to 0 cache misses if there are no requests in the relevant period.

Right now I'm at the point where the graphs _draw_ correctly but the numbers just don't add up. This only applies to the percentage-based graphs, which so far is only the hit_rate graph. I guess that's a problem for tomorrow.

At any rate, I'll see if I can't get some real-life data later this week, in the meanwhile, here's the four first graphs with random httperf-generated data...

http://kly.no/varnish/varnish_request_rate-day.png http://kly.no/varnish/varnish_threads-day.png http://kly.no/varnish/varnish_backend_traffic-day.png http://kly.no/varnish/varnish_hit_rate-day.png