]>
Commit | Line | Data |
---|---|---|
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" | |
7bba0dae | 24 | #include "misc.hh" |
ef9ebc82 PL |
25 | |
26 | std::string ixfrdistStats::getStats() { | |
27 | std::stringstream stats; | |
28 | const std::string prefix = "ixfrdist_"; | |
29 | ||
4be206f5 | 30 | stats<<"# HELP "<<prefix<<"uptime_seconds The uptime of the process (in seconds)"<<std::endl; |
b0069a9b | 31 | stats<<"# TYPE "<<prefix<<"uptime_seconds counter"<<std::endl; |
ef9ebc82 PL |
32 | stats<<prefix<<"uptime_seconds "<<time(nullptr) - progStats.startTime<<std::endl; |
33 | ||
4be206f5 | 34 | stats<<"# HELP "<<prefix<<"sys_msec Number of msec spent in system time"<<std::endl; |
b0069a9b | 35 | stats<<"# TYPE "<<prefix<<"sys_msec counter"<<std::endl; |
4be206f5 PD |
36 | stats<<prefix<<"sys_msec "<<getCPUTimeSystem("")<<std::endl; |
37 | ||
38 | stats<<"# HELP "<<prefix<<"user_msec Number of msec spent in user time"<<std::endl; | |
b0069a9b | 39 | stats<<"# TYPE "<<prefix<<"user_msec counter"<<std::endl; |
4be206f5 PD |
40 | stats<<prefix<<"user_msec "<<getCPUTimeUser("")<<std::endl; |
41 | ||
7bba0dae PD |
42 | stats<<"# HELP "<<prefix<<"fd_usage Number of open file descriptors"<<std::endl; |
43 | stats<<"# TYPE "<<prefix<<"fd_usage gauge"<<std::endl; | |
44 | stats<<prefix<<"fd_usage "<<getOpenFileDescriptors("")<<std::endl; | |
45 | ||
4be206f5 PD |
46 | stats<<"# HELP "<<prefix<<"real_memory_usage Actual unique use of memory in bytes (approx)"<<std::endl; |
47 | stats<<"# TYPE "<<prefix<<"real_memory_usage gauge"<<std::endl; | |
48 | stats<<prefix<<"real_memory_usage "<<getRealMemoryUsage("")<<std::endl; | |
49 | ||
ef9ebc82 PL |
50 | stats<<"# HELP "<<prefix<<"domains The amount of configured domains"<<std::endl; |
51 | stats<<"# TYPE "<<prefix<<"domains gauge"<<std::endl; | |
52 | stats<<prefix<<"domains "<<domainStats.size()<<std::endl; | |
53 | ||
54f93cb8 RG |
54 | if (!domainStats.empty()) { |
55 | stats<<"# HELP "<<prefix<<"soa_serial The SOA serial number of a domain"<<std::endl; | |
56 | stats<<"# TYPE "<<prefix<<"soa_serial gauge"<<std::endl; | |
d525b58b | 57 | stats << "# HELP " << prefix << "soa_checks_total Number of times a SOA check at the primary was attempted" << std::endl; |
54f93cb8 | 58 | stats<<"# TYPE "<<prefix<<"soa_checks_total counter"<<std::endl; |
d525b58b | 59 | stats << "# HELP " << prefix << "soa_checks_failed_total Number of times a SOA check at the primary failed" << std::endl; |
54f93cb8 RG |
60 | stats<<"# TYPE "<<prefix<<"soa_checks_failed_total counter"<<std::endl; |
61 | stats<<"# HELP "<<prefix<<"soa_inqueries_total Number of times a SOA query was received"<<std::endl; | |
62 | stats<<"# TYPE "<<prefix<<"soa_inqueries_total counter"<<std::endl; | |
63 | stats<<"# HELP "<<prefix<<"axfr_inqueries_total Number of times an AXFR query was received"<<std::endl; | |
64 | stats<<"# TYPE "<<prefix<<"axfr_inqueries_total counter"<<std::endl; | |
65 | stats<<"# HELP "<<prefix<<"axfr_failures_total Number of times an AXFR query was not properly answered"<<std::endl; | |
66 | stats<<"# TYPE "<<prefix<<"axfr_failures_total counter"<<std::endl; | |
67 | stats<<"# HELP "<<prefix<<"ixfr_inqueries_total Number of times an IXFR query was received"<<std::endl; | |
68 | stats<<"# TYPE "<<prefix<<"ixfr_inqueries_total counter"<<std::endl; | |
69 | stats<<"# HELP "<<prefix<<"ixfr_failures_total Number of times an IXFR query was not properly answered"<<std::endl; | |
70 | stats<<"# TYPE "<<prefix<<"ixfr_failures_total counter"<<std::endl; | |
71 | } | |
72 | ||
ef9ebc82 | 73 | for (auto const &d : domainStats) { |
ef9ebc82 | 74 | if(d.second.haveZone) |
7c05901b | 75 | stats<<prefix<<"soa_serial{domain=\""<<d.first<<"\"} "<<d.second.currentSOA<<std::endl; |
ef9ebc82 | 76 | else |
7c05901b | 77 | stats<<prefix<<"soa_serial{domain=\""<<d.first<<"\"} NaN"<<std::endl; |
ef9ebc82 | 78 | |
7c05901b | 79 | stats<<prefix<<"soa_checks_total{domain=\""<<d.first<<"\"} "<<d.second.numSOAChecks<<std::endl; |
7c05901b | 80 | stats<<prefix<<"soa_checks_failed_total{domain=\""<<d.first<<"\"} "<<d.second.numSOAChecksFailed<<std::endl; |
7c05901b | 81 | stats<<prefix<<"soa_inqueries_total{domain=\""<<d.first<<"\"} "<<d.second.numSOAinQueries<<std::endl; |
7c05901b | 82 | stats<<prefix<<"axfr_inqueries_total{domain=\""<<d.first<<"\"} "<<d.second.numAXFRinQueries<<std::endl; |
7c05901b | 83 | stats<<prefix<<"axfr_failures_total{domain=\""<<d.first<<"\"} "<<d.second.numAXFRFailures<<std::endl; |
7c05901b | 84 | stats<<prefix<<"ixfr_inqueries_total{domain=\""<<d.first<<"\"} "<<d.second.numIXFRinQueries<<std::endl; |
7c05901b | 85 | stats<<prefix<<"ixfr_failures_total{domain=\""<<d.first<<"\"} "<<d.second.numIXFRFailures<<std::endl; |
ef9ebc82 PL |
86 | } |
87 | ||
5b546566 PD |
88 | if (!notimpStats.empty()) { |
89 | stats<<"# HELP "<<prefix<<"notimp An unimplemented opcode"<<std::endl; | |
90 | stats<<"# TYPE "<<prefix<<"notimp counter"<<std::endl; | |
91 | } | |
92 | ||
c8166ef4 PD |
93 | for (std::size_t i = 0; i < notimpStats.size() ; i++) { |
94 | auto val = notimpStats.at(i).load(); | |
95 | ||
96 | if (val > 0) { | |
97 | stats<<prefix<<"notimp{opcode=\""<<Opcode::to_s(i)<<"\"} "<<val<<std::endl; | |
98 | } | |
5b546566 PD |
99 | } |
100 | ||
ca0831d9 PD |
101 | stats<<"# HELP "<<prefix<<"unknown_domain_inqueries_total Number of queries received for domains unknown to us"<<std::endl; |
102 | stats<<"# TYPE "<<prefix<<"unknown_domain_inqueries_total counter"<<std::endl; | |
103 | stats<<prefix<<"unknown_domain_inqueries_total "<<progStats.unknownDomainInQueries<<std::endl; | |
104 | ||
ef9ebc82 PL |
105 | return stats.str(); |
106 | } |