1 #!/usr/bin/perl 2 3 # Copyright (C) Internet Systems Consortium, Inc. ("ISC") 4 # 5 # SPDX-License-Identifier: MPL-2.0 6 # 7 # This Source Code Form is subject to the terms of the Mozilla Public 8 # License, v. 2.0. If a copy of the MPL was not distributed with this 9 # file, you can obtain one at https://mozilla.org/MPL/2.0/. 10 # 11 # See the COPYRIGHT file distributed with this work for additional 12 # information regarding copyright ownership. 13 14 # fetch.pl: 15 # Simple script to fetch HTTP content from the statistics channel 16 # of a BIND server. Fetches the full XML stats from 10.53.0.2 port 17 # 8853 by default; these can be overridden by command line arguments. 18 19 use File::Fetch; 20 use Getopt::Std; 21 22 sub usage { 23 print ("Usage: fetch.pl [-s address] [-p port] [path]\n"); 24 exit 1; 25 } 26 27 my %options={}; 28 getopts("s:p:", \%options); 29 30 my $addr = "10.53.0.2"; 31 $addr = $options{s} if defined $options{s}; 32 33 my $path = 'xml/v3'; 34 if (@ARGV >= 1) { 35 $path = shift @ARGV; 36 } 37 38 my $port = 8853; 39 $port = $options{p} if defined $options{p}; 40 41 my $ff = File::Fetch->new(uri => "http://$addr:$port/$path"); 42 my $file = $ff->fetch() or die $ff->error; 43 print ("$file\n"); 44