]>
git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/ixfrdist-stats.cc
2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
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.
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.
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.
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.
23 #include "ixfrdist-stats.hh"
25 std::string
ixfrdistStats::getStats() {
26 std::stringstream stats
;
27 const std::string prefix
= "ixfrdist_";
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
;
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
;
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
) {
41 stats
<<"# HELP "<<prefix
<<"soa_serial The SOA serial number of a domain"<<std::endl
;
42 stats
<<"# TYPE "<<prefix
<<"soa_serial gauge"<<std::endl
;
45 stats
<<prefix
<<"soa_serial{domain="<<d
.first
<<"} "<<d
.second
.currentSOA
<<std::endl
;
47 stats
<<prefix
<<"soa_serial{domain="<<d
.first
<<"} NaN"<<std::endl
;
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
;
53 stats
<<prefix
<<"soa_checks{domain="<<d
.first
<<"} "<<d
.second
.numSOAChecks
<<std::endl
;
54 numSOAChecks
+= d
.second
.numSOAChecks
;
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
;
60 stats
<<prefix
<<"soa_checks_failed{domain="<<d
.first
<<"} "<<d
.second
.numSOAChecksFailed
<<std::endl
;
61 numSOAChecksFailed
+= d
.second
.numSOAChecksFailed
;
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
;
67 stats
<<prefix
<<"soa_inqueries{domain="<<d
.first
<<"} "<<d
.second
.numSOAinQueries
<<std::endl
;
68 numSOAinQueries
+= d
.second
.numSOAinQueries
;
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
;
74 stats
<<prefix
<<"axfr_inqueries{domain="<<d
.first
<<"} "<<d
.second
.numAXFRinQueries
<<std::endl
;
75 numAXFRinQueries
+= d
.second
.numAXFRinQueries
;
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
;
81 stats
<<prefix
<<"axfr_failures{domain="<<d
.first
<<"} "<<d
.second
.numAXFRFailures
<<std::endl
;
82 numAXFRFailures
+= d
.second
.numAXFRFailures
;
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
;
88 stats
<<prefix
<<"ixfr_inqueries{domain="<<d
.first
<<"} "<<d
.second
.numIXFRinQueries
<<std::endl
;
89 numIXFRinQueries
+= d
.second
.numIXFRinQueries
;
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
;
95 stats
<<prefix
<<"ixfr_failures{domain="<<d
.first
<<"} "<<d
.second
.numIXFRFailures
<<std::endl
;
96 numIXFRFailures
+= d
.second
.numIXFRFailures
;
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
;