From: Steinar H. Gunderson Date: Sun, 21 Jun 2015 23:21:35 +0000 (+0200) Subject: Make varnishcount.pl multi-backend-capable. X-Git-Url: https://git.sesse.net/?p=remoteglot;a=commitdiff_plain;h=1678a9e9c9c0189dfdbbf68ab11cbcc178c5bf97;hp=078813087093cd7971d52bb5fe0e814c432f03a2 Make varnishcount.pl multi-backend-capable. --- diff --git a/varnishcount.pl b/varnishcount.pl index 7411b05..94203bb 100755 --- a/varnishcount.pl +++ b/varnishcount.pl @@ -8,7 +8,10 @@ use strict; use warnings; no warnings qw(once); -open my $fh, "-|", "varnishncsa -F '%{%s}t %U %q tffb=%{Varnish:time_firstbyte}x' -q 'ReqURL ~ \"^/analysis.pl\"'" +my $url = $ARGV[0] // "/analysis.pl"; # Technically an URL regex, not an URL. +my $port = $ARGV[1] // 5000; + +open my $fh, "-|", "varnishncsa -F '%{%s}t %U %q tffb=%{Varnish:time_firstbyte}x' -q 'ReqURL ~ \"^$url\"'" or die "varnishncsa: $!"; my %uniques = (); @@ -74,5 +77,5 @@ sub output { my $num_viewers = scalar keys %uniques; printf "%d entries in hash, mtime=$mtime\n", scalar keys %uniques; - LWP::Simple::get('http://127.0.0.1:5000/override-num-viewers?num=' . $num_viewers); + LWP::Simple::get('http://127.0.0.1:' . $port . '/override-num-viewers?num=' . $num_viewers); }