Functions
stats.c File Reference

This file describes the data structure used to collect runtime performance numbers. More...

#include "config.h"
#include <sys/time.h>
#include <sys/types.h>
#include "daemon/stats.h"
#include "daemon/worker.h"
#include "daemon/daemon.h"
#include "services/mesh.h"
#include "services/outside_network.h"
#include "services/listen_dnsport.h"
#include "util/config_file.h"
#include "util/tube.h"
#include "util/timehist.h"
#include "util/net_help.h"
#include "validator/validator.h"
#include "iterator/iterator.h"
#include "sldns/sbuffer.h"
#include "services/cache/rrset.h"
#include "services/cache/infra.h"
#include "validator/val_kcache.h"

Functions

static void stats_timeval_add (long long *d_sec, long long *d_usec, long long add_sec, long long add_usec)
 add timers and the values do not overflow or become negative
 
void server_stats_init (struct ub_server_stats *stats, struct config_file *cfg)
 Initialize server stats to 0. More...
 
void server_stats_querymiss (struct ub_server_stats *stats, struct worker *worker)
 add query if it missed the cache
 
void server_stats_prefetch (struct ub_server_stats *stats, struct worker *worker)
 add query if was cached and also resulted in a prefetch
 
void server_stats_log (struct ub_server_stats *stats, struct worker *worker, int threadnum)
 display the stats to the log
 
static size_t get_rrset_bogus (struct worker *worker, int reset)
 get rrsets bogus number from validator
 
static size_t get_queries_ratelimit (struct worker *worker, int reset)
 get number of ratelimited queries from iterator
 
void server_stats_compile (struct worker *worker, struct ub_stats_info *s, int reset)
 Compile stats into structure for this thread worker. More...
 
void server_stats_obtain (struct worker *worker, struct worker *who, struct ub_stats_info *s, int reset)
 Obtain the stats info for a given thread. More...
 
void server_stats_reply (struct worker *worker, int reset)
 Send stats over comm tube in reply to query cmd. More...
 
void server_stats_add (struct ub_stats_info *total, struct ub_stats_info *a)
 Addup stat blocks. More...
 
void server_stats_insquery (struct ub_server_stats *stats, struct comm_point *c, uint16_t qtype, uint16_t qclass, struct edns_data *edns, struct comm_reply *repinfo)
 Add stats for this query. More...
 
void server_stats_insrcode (struct ub_server_stats *stats, sldns_buffer *buf)
 Add rcode for this query. More...
 

Detailed Description

This file describes the data structure used to collect runtime performance numbers.

These 'statistics' may be of interest to the operator.

Function Documentation

◆ server_stats_init()

void server_stats_init ( struct ub_server_stats stats,
struct config_file cfg 
)

Initialize server stats to 0.

Parameters
statswhat to init (this is alloced by the caller).
cfgwith extended statistics option.

References ub_server_stats::extended, and config_file::stat_extended.

Referenced by worker_stats_clear().

◆ server_stats_compile()

void server_stats_compile ( struct worker worker,
struct ub_stats_info s,
int  reset 
)

◆ server_stats_obtain()

void server_stats_obtain ( struct worker worker,
struct worker who,
struct ub_stats_info s,
int  reset 
)

Obtain the stats info for a given thread.

Uses pipe to communicate.

Parameters
workerthe worker that is executing (the first worker).
whoon who to get the statistics info.
sthe stats block to fill in.
resetif stats can be reset.

References worker::cmd, server_stats_compile(), tube_read_msg(), VERB_ALGO, verbose(), worker_cmd_stats, worker_cmd_stats_noreset, and worker_send_cmd().

Referenced by do_stats().

◆ server_stats_reply()

void server_stats_reply ( struct worker worker,
int  reset 
)

Send stats over comm tube in reply to query cmd.

Parameters
workerthis worker.
resetif true, depending on config stats are reset. if false, statistics are not reset.

References worker::cmd, worker::daemon, server_stats_compile(), tube_write_msg(), VERB_ALGO, verbose(), and daemon::workers.

◆ server_stats_add()

void server_stats_add ( struct ub_stats_info total,
struct ub_stats_info a 
)

Addup stat blocks.

Parameters
totalsum of the two entries.
ato add to it.

References ub_server_stats::ans_bogus, ub_server_stats::ans_rcode, ub_server_stats::ans_rcode_nodata, ub_server_stats::ans_secure, ub_server_stats::extended, ub_server_stats::hist, ub_server_stats::max_query_list_size, ub_stats_info::mesh_dropped, ub_stats_info::mesh_jostled, ub_stats_info::mesh_num_reply_states, ub_stats_info::mesh_num_states, ub_stats_info::mesh_replies_sent, ub_stats_info::mesh_replies_sum_wait_sec, ub_stats_info::mesh_time_median, NUM_BUCKETS_HIST, ub_server_stats::num_queries, ub_server_stats::num_queries_ip_ratelimited, ub_server_stats::num_queries_missed_cache, ub_server_stats::num_queries_prefetch, ub_server_stats::num_query_dnscrypt_cert, ub_server_stats::num_query_dnscrypt_cleartext, ub_server_stats::num_query_dnscrypt_crypted, ub_server_stats::num_query_dnscrypt_crypted_malformed, ub_server_stats::qbit_AA, ub_server_stats::qbit_AD, ub_server_stats::qbit_CD, ub_server_stats::qbit_QR, ub_server_stats::qbit_RA, ub_server_stats::qbit_RD, ub_server_stats::qbit_TC, ub_server_stats::qbit_Z, ub_server_stats::qclass, ub_server_stats::qclass_big, ub_server_stats::qEDNS, ub_server_stats::qEDNS_DO, ub_server_stats::qipv6, ub_server_stats::qopcode, ub_server_stats::qtcp, ub_server_stats::qtcp_outgoing, ub_server_stats::qtype, ub_server_stats::qtype_big, stats_timeval_add(), ub_server_stats::sum_query_list_size, ub_stats_info::svr, ub_server_stats::tcp_accept_usage, UB_STATS_OPCODE_NUM, UB_STATS_QCLASS_NUM, UB_STATS_QTYPE_NUM, UB_STATS_RCODE_NUM, ub_server_stats::unwanted_queries, ub_server_stats::unwanted_replies, and ub_server_stats::zero_ttl_responses.

Referenced by do_stats().

◆ server_stats_insquery()

void server_stats_insquery ( struct ub_server_stats stats,
struct comm_point c,
uint16_t  qtype,
uint16_t  qclass,
struct edns_data edns,
struct comm_reply repinfo 
)

Add stats for this query.

Parameters
statsthe stats
ccommpoint with type and buffer.
qtypequery type
qclassquery class
ednsedns record
repinforeply info with remote address

References comm_point::buffer, ub_server_stats::qclass, ub_server_stats::qclass_big, ub_server_stats::qopcode, ub_server_stats::qtype, ub_server_stats::qtype_big, sldns_buffer_read_u16_at(), UB_STATS_QCLASS_NUM, and UB_STATS_QTYPE_NUM.

◆ server_stats_insrcode()

void server_stats_insrcode ( struct ub_server_stats stats,
struct sldns_buffer buf 
)

Add rcode for this query.

Parameters
statsthe stats
bufbuffer with rcode. If buffer is length0: not counted.

References ub_server_stats::extended, and sldns_buffer_limit().