]> git.sesse.net Git - remoteglot/blobdiff - varnishcount.pl
Make varnishcount.pl multi-backend-capable.
[remoteglot] / varnishcount.pl
index 7411b054c0a1d010b790794fb1a569f8fc8d19b1..94203bbe287ee7cdb2e0fbe6a317e6409a5e28fc 100755 (executable)
@@ -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);    
 }