I decided to write a quick something to give me a overview of the status of Varnish which I intend to build upon. Currently what I have put together is a overview page which will show me the following:
- Status of the websites that are managed by the instance
- Cache hit ratio for the varnish instance
- The CPU/Memory/Disk space status of the varnish server
- Some varnishstats
- Historical chart of the Cache hit ratio
- The details of the VCLs that are loaded into varnish
- The latest hits against varnish and there details e.g. hit/miss, source, URL etc
- The current ban list
I decided that I would write a restful interface to gather the various bits of information and some cron jobs which would store historical information into a mysql database.
The details all can by dynamically refreshed via AJAX calls to the restful interface that I created to gather the stats. I currently have the CPU,Memory and disk stats updating every 30 seconds and the historical hourly hit ratio chart updating every minute. The other elements can all by refreshed by a refresh button.
The following is the details of the website checks, this just does a curl to get the website to make sure it is responding. When the website is being checked the circle is amber, when it is down it is red and when it is up it is green.
Varnish server status
The following are the Varnish stats, the colour of the CPU, Memory and Disk change depending on the thresholds that have been set, based on a Red, Amber and Green colour.
The following is the details collected from varnishstat for some elements that I was interested in:
Varnish historical hit ratio
The following historical hit ratio chart is created by the data collected every minute by cron and put into a database, I am planning on putting a selection to change the range of the dates collected and probably put in a zoom, so if you collect a large date range you can zoom in.
The following is the latest hits to varnish. I have varnishncsa running as a daemon storing the hit details into a file which is then queried by the backend restful interface.
Varnish ban list
The following is the current ban in varnish, not really sure that I need to see this so this may well go in a future version.
The last part of the dashboard is the varnish VCLs that are configured. It will show all the VCLs and which one is active, I plan on putting a button to either upload a new VCL or change which VCL is active.
I have also created a interface into google analytics so that I can pull information about the visitor count etc from there to overlay with the stats that I have from varnish. I will also do some processing on the file that I’m capturing from varnishncsa so that I can collect more details about the response times for URLs, hits against URLs etc. This will then all be uploaded to the Database every hour. I’ll put some more posts on with some more details about the backend part of this.
The whole interface is based on twitters bootstrap so is mobile friendly as well. The restful interface that I decided upon was using slim micro framework.