Sha256: 1ff67e0aed9ab7d0f9adf33a0b559f67f6d1bc34399be9157cb0421082bfefe1
Contents?: true
Size: 1.34 KB
Versions: 1
Compression:
Stored size: 1.34 KB
Contents
#!/usr/bin/env ruby Process.setproctitle($0) # Reports varnish stats to Riemann. require 'open3' require File.expand_path('../../lib/riemann/tools', __FILE__) class Riemann::Tools::Varnish include Riemann::Tools opt :varnish_host, "Varnish hostname", :default => `hostname`.chomp def initialize cmd = 'varnishstat -V' Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr| @ver = /varnishstat \(varnish-(\d+)/.match(stderr.read)[1].to_i end if @ver >= 4 @vstats = [ "MAIN.sess_conn", "MAIN.sess_drop ", "MAIN.client_req", "MAIN.cache_hit", "MAIN.cache_miss" ] else @vstats = [ "client_conn", "client_drop", "client_req", "cache_hit", "cache_miss" ] end end def tick if @ver >= 4 stats = `varnishstat -1 -f #{@vstats.join(" -f ")}` else stats = `varnishstat -1 -f #{@vstats.join(",")}` end stats.each_line do |stat| m = stat.split() report( :host => opts[:varnish_host].dup, :service => "varnish #{m[0]}", :metric => m[1].to_f, :state => "ok", :description => "#{m[3..-1].join(' ')}", :tags => ["varnish"] ) end end end Riemann::Tools::Varnish.run
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
riemann-tools-1.0.0 | bin/riemann-varnish |