stats.c (256281) | stats.c (269257) |
---|---|
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 | 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. | 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 * SOFTWARE, EVEN IF ADVISED OF THE 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" | 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> | 43#ifdef HAVE_TIME_H 44#include <time.h> 45#endif 46#include <sys/time.h> 47#include <sys/types.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" | 48#include "daemon/stats.h" 49#include "daemon/worker.h" 50#include "daemon/daemon.h" 51#include "services/mesh.h" 52#include "services/outside_network.h" 53#include "util/config_file.h" 54#include "util/tube.h" 55#include "util/timehist.h" 56#include "util/net_help.h" 57#include "validator/validator.h" |
58#include "ldns/sbuffer.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{ | 59 60/** add timers and the values do not overflow or become negative */ 61static void 62timeval_add(struct timeval* d, const struct timeval* add) 63{ 64#ifndef S_SPLINT_S 65 d->tv_sec += add->tv_sec; 66 d->tv_usec += add->tv_usec; --- 190 unchanged lines hidden (view full) --- 257 * added up here, division later*/ 258 total->mesh_time_median += a->mesh_time_median; 259} 260 261void server_stats_insquery(struct server_stats* stats, struct comm_point* c, 262 uint16_t qtype, uint16_t qclass, struct edns_data* edns, 263 struct comm_reply* repinfo) 264{ |
260 uint16_t flags = ldns_buffer_read_u16_at(c->buffer, 2); | 265 uint16_t flags = sldns_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++; | 266 if(qtype < STATS_QTYPE_NUM) 267 stats->qtype[qtype]++; 268 else stats->qtype_big++; 269 if(qclass < STATS_QCLASS_NUM) 270 stats->qclass[qclass]++; 271 else stats->qclass_big++; |
267 stats->qopcode[ LDNS_OPCODE_WIRE(ldns_buffer_begin(c->buffer)) ]++; | 272 stats->qopcode[ LDNS_OPCODE_WIRE(sldns_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 | 273 if(c->type != comm_udp) 274 stats->qtcp++; 275 if(repinfo && addr_is_ip6(&repinfo->addr, repinfo->addrlen)) 276 stats->qipv6++; 277 if( (flags&BIT_QR) ) 278 stats->qbit_QR++; 279 if( (flags&BIT_AA) ) 280 stats->qbit_AA++; --- 11 unchanged lines hidden (view full) --- 292 stats->qbit_CD++; 293 if(edns->edns_present) { 294 stats->qEDNS++; 295 if( (edns->bits & EDNS_DO) ) 296 stats->qEDNS_DO++; 297 } 298} 299 |
295void server_stats_insrcode(struct server_stats* stats, ldns_buffer* buf) | 300void server_stats_insrcode(struct server_stats* stats, sldns_buffer* buf) |
296{ | 301{ |
297 if(stats->extended && ldns_buffer_limit(buf) != 0) { 298 int r = (int)LDNS_RCODE_WIRE( ldns_buffer_begin(buf) ); | 302 if(stats->extended && sldns_buffer_limit(buf) != 0) { 303 int r = (int)LDNS_RCODE_WIRE( sldns_buffer_begin(buf) ); |
299 stats->ans_rcode[r] ++; | 304 stats->ans_rcode[r] ++; |
300 if(r == 0 && LDNS_ANCOUNT( ldns_buffer_begin(buf) ) == 0) | 305 if(r == 0 && LDNS_ANCOUNT( sldns_buffer_begin(buf) ) == 0) |
301 stats->ans_rcode_nodata ++; 302 } 303} | 306 stats->ans_rcode_nodata ++; 307 } 308} |