xref: /netbsd-src/external/mpl/bind/dist/bin/tests/system/statschannel/zones-json.pl (revision 9fd8799cb5ceb66c69f2eb1a6d26a1d587ba1f1e)
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# zones-json.pl:
13# Parses the JSON version of the dnssec sign stats for the
14# "dnssec" zone in the default view into a normalized format.
15
16use JSON;
17
18my $file = $ARGV[0];
19my $zone = $ARGV[1];
20open(INPUT, "<$file");
21my $text = do{local$/;<INPUT>};
22close(INPUT);
23
24my $ref = decode_json($text);
25
26
27my $dnssecsign = $ref->{views}->{_default}->{zones}[$zone]->{"dnssec-sign"};
28my $type = "dnssec-sign operations ";
29foreach $key (keys %{$dnssecsign}) {
30    print $type . $key . ": ". $dnssecsign->{$key} ."\n";
31}
32my $dnssecrefresh = $ref->{views}->{_default}->{zones}[$zone]->{"dnssec-refresh"};
33my $type = "dnssec-refresh operations ";
34foreach $key (keys %{$dnssecrefresh}) {
35    print $type . $key . ": ". $dnssecrefresh->{$key} ."\n";
36}
37