From 42d4d25b9304a1af3e52d7e38ced19e41fb62c17 Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Tue, 2 Oct 2018 16:44:59 +0200 Subject: [PATCH] gather some stats; emit them to stdout periodically --- pdns/ixfrdist-stats.hh | 126 +++++++++++++++++++++++++++++++++++++++++ pdns/ixfrdist.cc | 6 ++ 2 files changed, 132 insertions(+) create mode 100644 pdns/ixfrdist-stats.hh diff --git a/pdns/ixfrdist-stats.hh b/pdns/ixfrdist-stats.hh new file mode 100644 index 0000000000..000be560dd --- /dev/null +++ b/pdns/ixfrdist-stats.hh @@ -0,0 +1,126 @@ +/* + * This file is part of PowerDNS or dnsdist. + * Copyright -- PowerDNS.COM B.V. and its contributors + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * In addition, for the avoidance of any doubt, permission is granted to + * link this program with OpenSSL and to (re)distribute the binaries + * produced as the result of such linking. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#pragma once +#include +#include +#include + +#include "dnsname.hh" + +class ixfrdistStats { + public: + ixfrdistStats() { + progStats.startTime = time(nullptr); + } + + std::string getStats() { + std::stringstream stats; + const std::string prefix = "ixfrdist_"; + + stats<<"# TYPE "< currentSOA; // NOTE: this will wrongly be zero for unavailable zones + + std::atomic numSOAChecks; + std::atomic numSOAChecksFailed; + + std::atomic numSOAinQueries; + std::atomic numIXFRinQueries; + std::atomic numAXFRinQueries; + + std::atomic numAXFRFailures; + std::atomic numIXFRFailures; + }; + class programStats { + public: + time_t startTime; + }; + + std::map domainStats; + programStats progStats; +}; diff --git a/pdns/ixfrdist.cc b/pdns/ixfrdist.cc index 4070135c9d..12623e23d4 100644 --- a/pdns/ixfrdist.cc +++ b/pdns/ixfrdist.cc @@ -43,6 +43,7 @@ #include "misc.hh" #include "iputils.hh" #include "logger.hh" +#include "ixfrdist-stats.hh" #include /* BEGIN Needed because of deeper dependencies */ @@ -137,6 +138,8 @@ static bool g_exiting = false; static NetmaskGroup g_acl; static bool g_compress = false; +static ixfrdistStats g_stats; + static void handleSignal(int signum) { g_log< guard(g_soas_mutex); g_soas[domain] = newInfo; + g_stats.setSOASerial(domain, newInfo->soa->d_st.serial); } void updateThread(const string& workdir, const uint16_t& keep, const uint16_t& axfrTimeout, const uint16_t& soaRetry) { @@ -278,6 +282,7 @@ void updateThread(const string& workdir, const uint16_t& keep, const uint16_t& a g_log< s; s.insert(domain["master"].as()); g_domainConfigs[domain["domain"].as()].masters = s; + g_stats.registerDomain(domain["domain"].as()); } for (const auto &addr : config["acl"].as>()) { -- 2.47.2