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