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.
28 #include "namespaces.hh"
29 #include "webserver.hh"
38 [[nodiscard]] double get10() const;
39 [[nodiscard]] double get5() const;
40 [[nodiscard]] double get1() const;
41 [[nodiscard]] double getMax() const;
46 double d_10{}, d_5{}, d_1{}, d_max{};
53 void go(StatBag& stats);
54 static string makePercentage(const double& val);
57 void indexfunction(HttpRequest* req, HttpResponse* resp);
58 void jsonstat(HttpRequest* req, HttpResponse* resp);
59 void registerApiHandler(const string& url, std::function<void(HttpRequest*, HttpResponse*)> handler);
61 void statThread(StatBag& stats);
64 double d_min10, d_min5, d_min1;
65 Ewma d_queries, d_cachehits, d_cachemisses;
66 Ewma d_qcachehits, d_qcachemisses;
67 unique_ptr<WebServer> d_ws{nullptr};
70 void apiDocs(HttpRequest* req, HttpResponse* resp);