Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
100 lines (65 sloc) 2.7 KB


PyVarnish is a collection of python management tools for Varnish

Currently it only sends Varnish stat output to Graphite.



This software is used in production and works. Documentation and tests are a work in progress. If you have any questions please feel free to contact me. Any contributions are also welcomed.


PyVarnish is a Console App

The PyVarnish package is designed to be run at intervals from crontab. It runs varnishstat on remote varnish servers using SSH commands and sends the data it receives to a Graphite server over UDP.


This guide assumes that you already have a Graphite server set up. Graphite:

It also assumes familiarity with SSH. In order to run properly PyVarnish needs to be able to run command remotely. The recommended way to do this is to set up a restricted account on each of your varnish servers with permission to run a single command

Below is an example of ssh authorized_keys file for the graphite user on your varnish server.

command="/usr/local/bin/",no-port-forwarding,no-X11-forwarding,no-pty ssh-rsa publickey`

/usr/local/bin/ might look like this

    "varnishstat -x")
            varnishstat -x
    "sysctl fs.file-nr")
            /sbin/sysctl fs.file-nr
            exit 1

To install the PyVarnish package

Install PyVarnish on a management server with SSH access to your Varnish boxes. The Management server need to have direct access to your graphite server over UDP.

from github

pip install

or simply download to a local directory and run from there.

Once installed you need to edit

VARNISH_SERVERS = ('server1', "server2",)
SSH_CONFIG = "/home/username/.ssh/config"
DEBUG = True
CARBON_SERVER = 'localhost'
  • Replace server1, server2 etc with the hostnames of your own varnish servers
  • SSH_CONFIG needs to refer to your .ssh/config file
  • CARBON_SERVER and CARBON_PORT should refer to your graphite server.

On each of your Varnish servers: Create a script that runs from crontab to run