Created
May 11, 2011 03:34
-
-
Save lox/965874 to your computer and use it in GitHub Desktop.
Varnish plugin for Scout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class VarnishPlugin < Scout::Plugin | |
def build_report | |
stats = {} | |
`varnishstat -1`.each_line do |line| | |
#client_conn 211980 0.30 Client connections accepted | |
next unless /^(\w+)\s+(\d+)\s+(\d+\.\d+)\s(.+)$/.match(line) | |
stats[$1.to_sym] = $2.to_i | |
end | |
report(:hitrate => 1 - (stats[:cache_miss].to_f / stats[:cache_hit])) | |
counter(:backend_success, stats[:backend_conn], :per=>:second) | |
counter(:backend_fail, stats[:backend_fail], :per=>:second) | |
counter(:cache_hit, stats[:cache_hit], :per=>:second) | |
counter(:cache_hitpass, stats[:cache_hitpass], :per=>:second) | |
counter(:cache_miss, stats[:cache_miss], :per=>:second) | |
counter(:client_conn, stats[:client_conn], :per=>:second) | |
counter(:client_req, stats[:client_req], :per=>:second) | |
counter(:client_req, stats[:client_req], :per=>:second) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment