]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/ixfrdist-stats.cc
Add some notes explaining why some validations are not relevant in the dnstap case.
[thirdparty/pdns.git] / pdns / ixfrdist-stats.cc
CommitLineData
ef9ebc82
PL
1/*
2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * In addition, for the avoidance of any doubt, permission is granted to
10 * link this program with OpenSSL and to (re)distribute the binaries
11 * produced as the result of such linking.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23#include "ixfrdist-stats.hh"
24
25std::string ixfrdistStats::getStats() {
26 std::stringstream stats;
27 const std::string prefix = "ixfrdist_";
28
29 stats<<"# HELP "<<prefix<<"uptime_seconds The uptime of the process"<<std::endl;
30 stats<<"# TYPE "<<prefix<<"uptime_seconds gauge"<<std::endl;
31 stats<<prefix<<"uptime_seconds "<<time(nullptr) - progStats.startTime<<std::endl;
32
33 stats<<"# HELP "<<prefix<<"domains The amount of configured domains"<<std::endl;
34 stats<<"# TYPE "<<prefix<<"domains gauge"<<std::endl;
35 stats<<prefix<<"domains "<<domainStats.size()<<std::endl;
36
37 uint64_t numSOAChecks{0}, numSOAChecksFailed{0}, numSOAinQueries{0}, numIXFRinQueries{0}, numAXFRinQueries{0}, numAXFRFailures{0}, numIXFRFailures{0};
38 bool helpAdded{false};
39 for (auto const &d : domainStats) {
40 if (!helpAdded) {
41 stats<<"# HELP "<<prefix<<"soa_serial The SOA serial number of a domain"<<std::endl;
42 stats<<"# TYPE "<<prefix<<"soa_serial gauge"<<std::endl;
43 }
44 if(d.second.haveZone)
45 stats<<prefix<<"soa_serial{domain="<<d.first<<"} "<<d.second.currentSOA<<std::endl;
46 else
47 stats<<prefix<<"soa_serial{domain="<<d.first<<"} NaN"<<std::endl;
48
49 if (!helpAdded) {
50 stats<<"# HELP "<<prefix<<"soa_checks Number of times a SOA check at the master was attempted"<<std::endl;
51 stats<<"# TYPE "<<prefix<<"soa_checks counter"<<std::endl;
52 }
53 stats<<prefix<<"soa_checks{domain="<<d.first<<"} "<<d.second.numSOAChecks<<std::endl;
54 numSOAChecks += d.second.numSOAChecks;
55
56 if (!helpAdded) {
57 stats<<"# HELP "<<prefix<<"soa_checks_failed Number of times a SOA check at the master failed"<<std::endl;
58 stats<<"# TYPE "<<prefix<<"soa_checks_failed counter"<<std::endl;
59 }
60 stats<<prefix<<"soa_checks_failed{domain="<<d.first<<"} "<<d.second.numSOAChecksFailed<<std::endl;
61 numSOAChecksFailed += d.second.numSOAChecksFailed;
62
63 if (!helpAdded) {
64 stats<<"# HELP "<<prefix<<"soa_inqueries Number of times a SOA query was received"<<std::endl;
65 stats<<"# TYPE "<<prefix<<"soa_inqueries counter"<<std::endl;
66 }
67 stats<<prefix<<"soa_inqueries{domain="<<d.first<<"} "<<d.second.numSOAinQueries<<std::endl;
68 numSOAinQueries += d.second.numSOAinQueries;
69
70 if (!helpAdded) {
71 stats<<"# HELP "<<prefix<<"axfr_inqueries Number of times an AXFR query was received"<<std::endl;
72 stats<<"# TYPE "<<prefix<<"axfr_inqueries counter"<<std::endl;
73 }
74 stats<<prefix<<"axfr_inqueries{domain="<<d.first<<"} "<<d.second.numAXFRinQueries<<std::endl;
75 numAXFRinQueries += d.second.numAXFRinQueries;
76
77 if (!helpAdded) {
78 stats<<"# HELP "<<prefix<<"axfr_failures Number of times an AXFR query was not properly answered"<<std::endl;
79 stats<<"# TYPE "<<prefix<<"axfr_failures counter"<<std::endl;
80 }
81 stats<<prefix<<"axfr_failures{domain="<<d.first<<"} "<<d.second.numAXFRFailures<<std::endl;
82 numAXFRFailures += d.second.numAXFRFailures;
83
84 if (!helpAdded) {
85 stats<<"# HELP "<<prefix<<"ixfr_inqueries Number of times an IXFR query was received"<<std::endl;
86 stats<<"# TYPE "<<prefix<<"ixfr_inqueries counter"<<std::endl;
87 }
88 stats<<prefix<<"ixfr_inqueries{domain="<<d.first<<"} "<<d.second.numIXFRinQueries<<std::endl;
89 numIXFRinQueries += d.second.numIXFRinQueries;
90
91 if (!helpAdded) {
92 stats<<"# HELP "<<prefix<<"ixfr_failures Number of times an IXFR query was not properly answered"<<std::endl;
93 stats<<"# TYPE "<<prefix<<"ixfr_failures counter"<<std::endl;
94 }
95 stats<<prefix<<"ixfr_failures{domain="<<d.first<<"} "<<d.second.numIXFRFailures<<std::endl;
96 numIXFRFailures += d.second.numIXFRFailures;
97 helpAdded = true;
98 }
99
100 stats<<prefix<<"soa_checks "<<numSOAChecks<<std::endl;
101 stats<<prefix<<"soa_checks_failed "<<numSOAChecksFailed<<std::endl;
102 stats<<prefix<<"soa_inqueries "<<numSOAinQueries<<std::endl;
103 stats<<prefix<<"axfr_inqueries "<<numAXFRinQueries<<std::endl;
104 stats<<prefix<<"ixfr_inqueries "<<numIXFRinQueries<<std::endl;
105 stats<<prefix<<"axfr_failures "<<numAXFRFailures<<std::endl;
106 stats<<prefix<<"ixfr_failures "<<numIXFRFailures<<std::endl;
107 return stats.str();
108}