Plugin Cacti for Varnish 3.x

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
egamez
Posts: 1
Joined: Tue Feb 21, 2012 11:25 am

Plugin Cacti for Varnish 3.x

Post by egamez »

Hi to everybody,

I'm actually using plugin to monitorice varnish with cacti "get_varnish_stats.py" but only works with versions 2.x not 3.x. I found that Varnish remove the stats throug telnet, and that is the metod used by get_varnish script for catch data from varnish clients.

Someone knows a plugin to extract data of varnish 3.x and how to install it on cacti server???


Thanks to all
lygie
Posts: 1
Joined: Sun Mar 04, 2012 6:19 am

Re: Plugin Cacti for Varnish 3.x

Post by lygie »

Hallo,

a simple way would be to change the python-script.
As I am not very familiar to python, i use awk to get the data from varnishstats

Code: Select all

#!/usr/bin/python
import os
import re
import sys
import getopt


cmd="varnishstat -1 | grep 'cache_hit ' | awk '{print $2}'"
out=os.popen(cmd).read()
hit = float(out)

cmd="varnishstat -1 | grep 'cache_miss ' | awk '{print $2}'"
out=os.popen(cmd).read()
miss = float(out)

cmd="varnishstat -1 | grep 'client_req ' | awk '{print $2}'"
out=os.popen(cmd).read()
req = float(out)

print 'varnish_requests:'+str(req)+' varnish_hitrate:'+str(round(hit / (hit + miss) * 100, 1))
Hope, that helps you
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests