xref: /netbsd-src/external/mpl/bind/dist/bin/tests/system/statschannel/server-json.pl (revision 2718af68c3efc72c9769069b5c7f9ed36f6b9def)
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 https://mozilla.org/MPL/2.0/.
8#
9# See the COPYRIGHT file distributed with this work for additional
10# information regarding copyright ownership.
11
12# server-json.pl:
13# Parses the JSON version of the server stats into a normalized format.
14
15use JSON;
16
17open(INPUT, "<json.stats");
18my $text = do{local$/;<INPUT>};
19close(INPUT);
20
21my $ref = decode_json($text);
22foreach $key (keys %{$ref->{opcodes}}) {
23    print "opcode " . $key . ": " . $ref->{opcodes}->{$key} . "\n";
24}
25foreach $key (keys %{$ref->{rcodes}}) {
26    print "rcode " . $key . ": " . $ref->{rcodes}->{$key} . "\n";
27}
28foreach $key (keys %{$ref->{qtypes}}) {
29    print "qtype " . $key . ": " . $ref->{qtypes}->{$key} . "\n";
30}
31foreach $key (keys %{$ref->{nsstats}}) {
32    print "nsstat " . $key . ": " . $ref->{nsstats}->{$key} . "\n";
33}
34