Deleted Added
sdiff udiff text old ( 256281 ) new ( 269257 )
full compact
1/*
2 * daemon/stats.c - collect runtime performance indicators.
3 *
4 * Copyright (c) 2007, NLnet Labs. All rights reserved.
5 *
6 * This software is open source.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 7 unchanged lines hidden (view full) ---

16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * Neither the name of the NLNET LABS nor the names of its contributors may
20 * be used to endorse or promote products derived from this software without
21 * specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36/**
37 * \file
38 *
39 * This file describes the data structure used to collect runtime performance
40 * numbers. These 'statistics' may be of interest to the operator.
41 */
42#include "config.h"
43#include <ldns/wire2host.h>
44#include "daemon/stats.h"
45#include "daemon/worker.h"
46#include "daemon/daemon.h"
47#include "services/mesh.h"
48#include "services/outside_network.h"
49#include "util/config_file.h"
50#include "util/tube.h"
51#include "util/timehist.h"
52#include "util/net_help.h"
53#include "validator/validator.h"
54
55/** add timers and the values do not overflow or become negative */
56static void
57timeval_add(struct timeval* d, const struct timeval* add)
58{
59#ifndef S_SPLINT_S
60 d->tv_sec += add->tv_sec;
61 d->tv_usec += add->tv_usec;

--- 190 unchanged lines hidden (view full) ---

252 * added up here, division later*/
253 total->mesh_time_median += a->mesh_time_median;
254}
255
256void server_stats_insquery(struct server_stats* stats, struct comm_point* c,
257 uint16_t qtype, uint16_t qclass, struct edns_data* edns,
258 struct comm_reply* repinfo)
259{
260 uint16_t flags = ldns_buffer_read_u16_at(c->buffer, 2);
261 if(qtype < STATS_QTYPE_NUM)
262 stats->qtype[qtype]++;
263 else stats->qtype_big++;
264 if(qclass < STATS_QCLASS_NUM)
265 stats->qclass[qclass]++;
266 else stats->qclass_big++;
267 stats->qopcode[ LDNS_OPCODE_WIRE(ldns_buffer_begin(c->buffer)) ]++;
268 if(c->type != comm_udp)
269 stats->qtcp++;
270 if(repinfo && addr_is_ip6(&repinfo->addr, repinfo->addrlen))
271 stats->qipv6++;
272 if( (flags&BIT_QR) )
273 stats->qbit_QR++;
274 if( (flags&BIT_AA) )
275 stats->qbit_AA++;

--- 11 unchanged lines hidden (view full) ---

287 stats->qbit_CD++;
288 if(edns->edns_present) {
289 stats->qEDNS++;
290 if( (edns->bits & EDNS_DO) )
291 stats->qEDNS_DO++;
292 }
293}
294
295void server_stats_insrcode(struct server_stats* stats, ldns_buffer* buf)
296{
297 if(stats->extended && ldns_buffer_limit(buf) != 0) {
298 int r = (int)LDNS_RCODE_WIRE( ldns_buffer_begin(buf) );
299 stats->ans_rcode[r] ++;
300 if(r == 0 && LDNS_ANCOUNT( ldns_buffer_begin(buf) ) == 0)
301 stats->ans_rcode_nodata ++;
302 }
303}