unbound: daemon/stats.h File Reference

unbound 0.1

Functions
stats.h File Reference

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

`#include "util/timehist.h"`
`#include "libunbound/unbound.h"`

## Functions
void | server_stats_init (struct ub_server_stats *stats, struct config_file *cfg)
| Initialize server stats to 0.
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
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.
void | server_stats_compile (struct worker *worker, struct ub_stats_info *s, int reset)
| Compile stats into structure for this thread worker.
void | server_stats_reply (struct worker *worker, int reset)
| Send stats over comm tube in reply to query cmd.
void | server_stats_add (struct ub_stats_info *total, struct ub_stats_info *a)
| Addup stat blocks.
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.
void | server_stats_insrcode (struct ub_server_stats *stats, struct sldns_buffer *buf)
| Add rcode for this query.
void | server_stats_downstream_cookie (struct ub_server_stats *stats, struct edns_data *edns)
| Add DNS Cookie stats for this query.

## 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

  stats | what to init (this is alloced by the caller).
  cfg | with extended statistics option.

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

Referenced by worker_init(), and worker_stats_clear().

## ◆ 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

  worker | the worker that is executing (the first worker).
  who | on who to get the statistics info.
  s | the stats block to fill in.
  reset | if stats can be reset.

References worker::cmd, fatal_exit(), server_stats_compile(), STATS_THREAD_WAIT, worker::thr_id, worker::thread_num, tube_read_msg(), tube_wait_timeout(), VERB_ALGO, VERB_OPS, verbose(), verbosity, worker_cmd_stats, worker_cmd_stats_noreset, and worker_send_cmd().

Referenced by do_stats().

## ◆ server_stats_compile()

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

Compile stats into structure for this thread worker.

Also clears the statistics counters (if that is set by config file).

Parameters

  worker | the worker to compile stats for, also the executing worker.
  s | stats block.
  reset | if true, depending on config stats are reset. if false, statistics are not reset.

References mesh_area::all, mesh_area::ans_bogus, ub_server_stats::ans_bogus, mesh_area::ans_cachedb, mesh_area::ans_expired, ub_server_stats::ans_expired, mesh_area::ans_nodata, mesh_area::ans_rcode, ub_server_stats::ans_rcode, ub_server_stats::ans_rcode_nodata, mesh_area::ans_secure, ub_server_stats::ans_secure, module_env::auth_zones, worker::back, module_env::cfg, listen_list::com, rbtree_type::count, listen_dnsport::cps, comm_point::cur_tcp_count, worker::daemon, worker::env, worker::front, get_queries_ratelimit(), get_rrset_bogus(), get_slabhash_stats(), ub_server_stats::hist, mesh_area::histogram, infra_cache::hosts, http2_get_query_buffer_size(), http2_get_response_buffer_size(), module_env::infra_cache, ub_server_stats::infra_cache_count, module_env::key_cache, ub_server_stats::key_cache_count, auth_zones::lock, ub_server_stats::mem_http2_query_buffer, ub_server_stats::mem_http2_response_buffer, ub_server_stats::mem_stream_wait, module_env::mesh, 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, module_env::msg_cache, ub_server_stats::msg_cache_count, ub_server_stats::msg_cache_max_collisions, listen_list::next, ub_server_stats::nonce_cache_count, NUM_BUCKETS_HIST, ub_server_stats::num_query_authzone_down, ub_server_stats::num_query_authzone_up, ub_server_stats::num_query_cachedb, ub_server_stats::num_query_dnscrypt_replay, ub_server_stats::num_query_dnscrypt_secret_missed_cache, auth_zones::num_query_down, ub_server_stats::num_query_subnet, ub_server_stats::num_query_subnet_cache, auth_zones::num_query_up, mesh_area::num_reply_states, outside_network::num_tcp_outgoing, outside_network::num_udp_outgoing, ub_server_stats::qtcp_outgoing, ub_server_stats::qudp_outgoing, ub_server_stats::queries_ratelimited, mesh_area::replies_sent, mesh_area::replies_sum_wait, mesh_area::rpz_action, ub_server_stats::rpz_action, ub_server_stats::rrset_bogus, module_env::rrset_cache, ub_server_stats::rrset_cache_count, ub_server_stats::rrset_cache_max_collisions, set_neg_cache_stats(), ub_server_stats::shared_secret_cache_count, key_cache::slab, config_file::stat_cumulative, worker::stats, mesh_area::stats_dropped, mesh_area::stats_jostled, ub_stats_info::svr, rrset_cache::table, ub_server_stats::tcp_accept_usage, tcp_req_info_get_stream_buffer_size(), timehist_export(), timehist_quartile(), comm_point::type, UB_STATS_RCODE_NUM, UB_STATS_RPZ_ACTION_NUM, outside_network::unwanted_replies, ub_server_stats::unwanted_replies, and worker_stats_clear().

Referenced by server_stats_obtain(), and server_stats_reply().

## ◆ server_stats_reply()

void server_stats_reply | ( | struct worker * | worker,
|  | int | reset )

Send stats over comm tube in reply to query cmd.

Parameters

  worker | this worker.
  reset | if true, depending on config stats are reset. if false, statistics are not reset.

References worker::cmd, worker::daemon, fatal_exit(), 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

  total | sum of the two entries.
  a | to add to it.

References ub_server_stats::ans_bogus, ub_server_stats::ans_expired, 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_server_stats::max_query_time_us, 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_cookie_client, ub_server_stats::num_queries_cookie_invalid, ub_server_stats::num_queries_cookie_valid, ub_server_stats::num_queries_ip_ratelimited, ub_server_stats::num_queries_missed_cache, ub_server_stats::num_queries_prefetch, ub_server_stats::num_queries_timed_out, ub_server_stats::num_query_cachedb, 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::qhttps, ub_server_stats::qipv6, ub_server_stats::qopcode, ub_server_stats::qtcp, ub_server_stats::qtcp_outgoing, ub_server_stats::qtls, ub_server_stats::qtls_resume, ub_server_stats::qtype, ub_server_stats::qtype_big, ub_server_stats::qudp_outgoing, ub_server_stats::rpz_action, 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_STATS_RPZ_ACTION_NUM, ub_server_stats::unwanted_queries, and ub_server_stats::unwanted_replies.

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

  stats | the stats
  c | commpoint with type and buffer.
  qtype | query type
  qclass | query class
  edns | edns record
  repinfo | reply info with remote address

References addr_is_ip6(), BIT_AA, BIT_AD, BIT_CD, BIT_QR, BIT_RA, BIT_RD, BIT_TC, BIT_Z, edns_data::bits, comm_point::buffer, EDNS_DO, edns_data::edns_present, 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::qhttps, ub_server_stats::qipv6, ub_server_stats::qopcode, ub_server_stats::qtcp, ub_server_stats::qtls, ub_server_stats::qtls_resume, ub_server_stats::qtype, ub_server_stats::qtype_big, comm_reply::remote_addr, comm_reply::remote_addrlen, sldns_buffer_begin(), sldns_buffer_read_u16_at(), comm_point::ssl, comm_point::type, UB_STATS_QCLASS_NUM, and UB_STATS_QTYPE_NUM.

Referenced by worker_handle_request().

## ◆ server_stats_insrcode()

void server_stats_insrcode | ( | struct ub_server_stats * | stats,
|  | struct sldns_buffer * | buf )

Add rcode for this query.

Parameters

  stats | the stats
  buf | buffer with rcode. If buffer is length0: not counted.

References ub_server_stats::ans_rcode, ub_server_stats::ans_rcode_nodata, ub_server_stats::extended, sldns_buffer_begin(), and sldns_buffer_limit().

Referenced by answer_norec_from_cache(), and worker_handle_request().

## ◆ server_stats_downstream_cookie()

void server_stats_downstream_cookie | ( | struct ub_server_stats * | stats,
|  | struct edns_data * | edns )

Add DNS Cookie stats for this query.

Parameters

  stats | the stats
  edns | edns record

References edns_data::cookie_client, edns_data::cookie_present, edns_data::cookie_valid, edns_data::edns_present, ub_server_stats::num_queries_cookie_client, ub_server_stats::num_queries_cookie_invalid, and ub_server_stats::num_queries_cookie_valid.

Referenced by worker_handle_request().