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