DjinnS/Varnish-Report
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
Varnish Report
Analyzes the contents of a log generated by varnishncsa and build statistics usage of cache
How to install it:
1) install git on your machine
2) clone Varnish Report
$ git clone git@github.com:DjinnS/Varnish-Report
3) install prerequisites packages
Perl:
- Getopt::Long;
- DateTime (Debian: apt-get install libdatetime-perl)
- Text::ASCIITable (cpan: install Text::ASCIITable)
- ProgressBar::Stack (cpan: install ProgressBar::Stack)
- URI (Debian: apt-get install liburi-perl)
How to use it:
1) Get log from your varnish. Use le following log format with varnishncsa:
"[%{Varnish:hitmiss}x-%{Varnish:handling}x] %h %t %s %b \"%r\" \"%{Referer}i\" %{User-agent}i (%{Content-Type}o)"
For example:
$ varnishncsa -F "[%{Varnish:hitmiss}x-%{Varnish:handling}x] %h %t %s %b \"%r\" \"%{Referer}i\" %{User-agent}i (%{Content-Type}o)" &> access.log &
2) Run Varnish Report:
$ perl varnishncsareport.pl -l access.log -f -t 20
ToDo:
- Export format:
- CSV export => JOB DONE !
- HTML export
- PDF export
- Recommandations (if possible)
- Color output (for better view)
Output example, you can get more stats with the -f option:
Varnish Report - 0.1.2
[####################] 100.0% ETA: 0:00 Processing file access.log ...
Log start: Wed Dec 21 16:33:46 2011
Log end : Thu Dec 22 12:32:39 2011
.-----------------------------------------.
| Summary |
+---------+------------+------------------+
| Data | Value | Rate |
+---------+------------+------------------+
| Request | 447736 | 6.22 req/s |
| Bytes | 3106449682 | 0.04 MB/s |
| Hit | 50823 | 0.71 hit/s |
| Miss | 396913 | 5.52 hit/s |
'---------+------------+------------------'
.------------------------------------------------.
| Varnish cache stats |
+--------+--------+-----------+-------+----------+
| Status | Hit | Size (Mb) | req/s | Rate (%) |
+--------+--------+-----------+-------+----------+
| HIT | 50823 | 1525.19 | 0.71 | 11.35 |
| MISS | 396913 | 1437.35 | 5.52 | 88.65 |
'--------+--------+-----------+-------+----------'
.------------------------------------------------------------------------.
| HTTP status code |
+-----------+--------+-----------+-------+----------+---------+----------+
| HTTP Code | Hit | Size (Mb) | req/s | Rate (%) | hit (%) | miss (%) |
+-----------+--------+-----------+-------+----------+---------+----------+
| 200 | 396830 | 2900.03 | 5.52 | 88.63 | 3.00 | 97.00 |
| 500 | 28982 | 62.49 | 0.40 | 6.47 | 71.63 | 28.37 |
| 304 | 21515 | 0.00 | 0.30 | 4.81 | 84.08 | 15.92 |
| 301 | 300 | 0.00 | 0.00 | 0.07 | 20.00 | 80.00 |
| 404 | 54 | 0.01 | 0.00 | 0.01 | 25.93 | 74.07 |
| 403 | 33 | 0.00 | 0.00 | 0.01 | 24.24 | 75.76 |
| 503 | 10 | 0.00 | 0.00 | 0.00 | 0.00 | 100.00 |
| 302 | 9 | 0.01 | 0.00 | 0.00 | 0.00 | 100.00 |
| 400 | 3 | 0.00 | 0.00 | 0.00 | 0.00 | 100.00 |
'-----------+--------+-----------+-------+----------+---------+----------'
.--------------------------------------------------------------------------.
| HTTP Request method |
+-------------+--------+-----------+-------+----------+---------+----------+
| HTTP Method | Hit | Size (Mb) | req/s | Rate (%) | hit (%) | miss (%) |
+-------------+--------+-----------+-------+----------+---------+----------+
| GET | 447594 | 2962.36 | 6.22 | 99.97 | 11.35 | 88.65 |
| POST | 142 | 0.18 | 0.00 | 0.03 | 0.00 | 100.00 |
'-------------+--------+-----------+-------+----------+---------+----------'
.-----------------------------------------------------------------------------------------------.
| MIME STATS |
+----------------------------------+--------+-----------+-------+----------+---------+----------+
| MIME | Hit | Size (Mb) | req/s | Rate (%) | hit (%) | miss (%) |
+----------------------------------+--------+-----------+-------+----------+---------+----------+
| text/xml; charset=UTF-8 | 217963 | 355.74 | 3.03 | 48.68 | 7.57 | 92.43 |
| text/html; charset=utf-8 | 71931 | 14.80 | 1.00 | 16.07 | 0.00 | 100.00 |
| application/xml; charset=utf-8 | 63258 | 884.70 | 0.88 | 14.13 | 7.55 | 92.45 |
| text/html | 43236 | 71.62 | 0.60 | 9.66 | 49.32 | 50.68 |
| application/xml; charset=UTF-8 | 21460 | 54.72 | 0.30 | 4.79 | 0.57 | 99.43 |
| application/xml; charset: UTF-8 | 14645 | 19.47 | 0.20 | 3.27 | 5.65 | 94.35 |
| application/zip | 3492 | 1180.89 | 0.05 | 0.78 | 93.36 | 6.64 |
| application/javascript | 3486 | 3.05 | 0.05 | 0.78 | 61.68 | 38.32 |
| image/gif | 1864 | 0.15 | 0.03 | 0.42 | 37.93 | 62.07 |
| text/html; charset=UTF-8 | 1718 | 9.44 | 0.02 | 0.38 | 0.35 | 99.65 |
| application/xml; charset: utf-8 | 1386 | 0.36 | 0.02 | 0.31 | 4.18 | 95.82 |
| image/png | 1113 | 0.90 | 0.02 | 0.25 | 35.76 | 64.24 |
| text/css | 860 | 0.14 | 0.01 | 0.19 | 65.58 | 34.42 |
| text/html;charset=UTF-8 | 480 | 0.30 | 0.01 | 0.11 | 0.00 | 100.00 |
| text/html; charset=iso-8859-1 | 315 | 0.00 | 0.00 | 0.07 | 20.00 | 80.00 |
| image/jpeg | 195 | 3.66 | 0.00 | 0.04 | 6.67 | 93.33 |
| application/x-shockwave-flash | 114 | 0.95 | 0.00 | 0.03 | 28.07 | 71.93 |
| text/javascript; charset: UTF-8 | 110 | 0.18 | 0.00 | 0.02 | 24.55 | 75.45 |
| application/json; charset=UTF-8 | 54 | 12.76 | 0.00 | 0.01 | 0.00 | 100.00 |
| - | 14 | 0.00 | 0.00 | 0.00 | 0.00 | 100.00 |
| video/x-ms-wmv | 14 | 348.66 | 0.00 | 0.00 | 0.00 | 100.00 |
| text/plain; charset=UTF-8 | 10 | 0.00 | 0.00 | 0.00 | 0.00 | 100.00 |
| image/x-icon | 9 | 0.01 | 0.00 | 0.00 | 0.00 | 100.00 |
| application/json; charset: utf-8 | 8 | 0.01 | 0.00 | 0.00 | 0.00 | 100.00 |
| video/mp4 | 1 | 0.00 | 0.00 | 0.00 | 0.00 | 100.00 |
'----------------------------------+--------+-----------+-------+----------+---------+----------'
.-----------------------------------------------------------------------------------------------.
| VHOST |
+----------------------------------+--------+-----------+-------+----------+---------+----------+
| VHOST | Hit | Size (Mb) | req/s | Rate (%) | hit (%) | miss (%) |
+----------------------------------+--------+-----------+-------+----------+---------+----------+
| xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | 365560 | 2578.21 | 5.08 | 81.65 | 12.83 | 87.17 |
| xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | 71890 | 14.74 | 1.00 | 16.06 | 0.00 | 100.00 |
| xxxxxxxxxxxxxxxxxxxxxxx | 9806 | 369.29 | 0.14 | 2.19 | 40.11 | 59.89 |
| xxxxxxxxxxxxxxxxxxxxxxx | 480 | 0.30 | 0.01 | 0.11 | 0.00 | 100.00 |
'----------------------------------+--------+-----------+-------+----------+---------+----------'