]>
git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/statnode.cc
3 StatNode::Stat
StatNode::print(unsigned int depth
, Stat newstat
, bool silent
) const
6 cout
<<string(depth
, ' ');
7 cout
<<name
<<": "<<endl
;
10 childstat
.queries
+= s
.queries
;
11 childstat
.noerrors
+= s
.noerrors
;
12 childstat
.nxdomains
+= s
.nxdomains
;
13 childstat
.servfails
+= s
.servfails
;
14 childstat
.drops
+= s
.drops
;
15 if(children
.size()>1024 && !silent
) {
16 cout
<<string(depth
, ' ')<<name
<<": too many to print"<<endl
;
18 for(const children_t::value_type
& child
: children
) {
19 childstat
=child
.second
.print(depth
+8, childstat
, silent
|| children
.size()>1024);
21 if(!silent
|| children
.size()>1)
22 cout
<<string(depth
, ' ')<<childstat
.queries
<<" queries, " <<
23 childstat
.noerrors
<<" noerrors, "<<
24 childstat
.nxdomains
<<" nxdomains, "<<
25 childstat
.servfails
<<" servfails, "<<
26 childstat
.drops
<<" drops"<<endl
;
34 void StatNode::visit(visitor_t visitor
, Stat
&newstat
, unsigned int depth
) const
37 childstat
.queries
+= s
.queries
;
38 childstat
.noerrors
+= s
.noerrors
;
39 childstat
.nxdomains
+= s
.nxdomains
;
40 childstat
.servfails
+= s
.servfails
;
41 childstat
.drops
+= s
.drops
;
42 childstat
.remotes
= s
.remotes
;
44 Stat
selfstat(childstat
);
47 for(const children_t::value_type
& child
: children
) {
48 child
.second
.visit(visitor
, childstat
, depth
+8);
51 visitor(this, selfstat
, childstat
);
57 void StatNode::submit(const DNSName
& domain
, int rcode
, const ComboAddress
& remote
)
59 // cerr<<"FIRST submit called on '"<<domain<<"'"<<endl;
60 vector
<string
> tmp
= domain
.getRawLabels();
65 for(auto const i
: tmp
) {
68 children
[parts
.back()].submit(parts
, "", rcode
, remote
, 1);
71 /* www.powerdns.com. ->
78 void StatNode::submit(deque
<string
>& labels
, const std::string
& domain
, int rcode
, const ComboAddress
& remote
, unsigned int count
)
82 // cerr<<"Submit called for domain='"<<domain<<"': ";
83 // for(const std::string& n : labels)
89 // cerr<<"Set short name to '"<<name<<"'"<<endl;
92 // cerr<<"Short name was already set to '"<<name<<"'"<<endl;
95 if(labels
.size()==1) {
96 if (fullname
.empty()) {
97 fullname
=name
+"."+domain
;
100 // cerr<<"Hit the end, set our fullname to '"<<fullname<<"'"<<endl<<endl;
113 if (fullname
.empty()) {
114 fullname
=name
+"."+domain
;
117 // cerr<<"Not yet end, set our fullname to '"<<fullname<<"', recursing"<<endl;
119 children
[labels
.back()].submit(labels
, fullname
, rcode
, remote
, count
+1);