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"
33 Ewma() : d_last(0), d_10(0), d_5(0), d_1(0), d_max(0){dt.set();}
37 double difft=dt.udiff()/1000000.0;
40 d_10=((600.0-difft)*d_10+(difft*rate))/600.0;
41 d_5=((300.0-difft)*d_5+(difft*rate))/300.0;
42 d_1=((60.0-difft)*d_1+(difft*rate))/60.0;
66 double d_10, d_5, d_1, d_max;
78 static string makePercentage(const double& val);
81 void indexfunction(HttpRequest* req, HttpResponse* resp);
82 void cssfunction(HttpRequest* req, HttpResponse* resp);
83 void jsonstat(HttpRequest* req, HttpResponse* resp);
84 void registerApiHandler(const string& url, boost::function<void(HttpRequest*, HttpResponse*)> handler);
85 void printvars(ostringstream &ret);
86 void printargs(ostringstream &ret);
91 double d_min10, d_min5, d_min1;
92 Ewma d_queries, d_cachehits, d_cachemisses;
93 Ewma d_qcachehits, d_qcachemisses;
94 WebServer *d_ws{nullptr};