#!/bin/sh # Run 32118850138 could bound the dnsmasq listener loss only to a 6m39s # window between two host DNS consumers; one line per 10s pins it to one # sample bucket and names which :53 listener (hex local_address) was left. set -u EXTERNAL_PROBE_NAME=deb.debian.org sample_once() { socks="$(awk '$2 ~ /:0035$/ && $3 == "00000000:0000" {printf " %s", $2}' "${1}")" printf '%s%s\n' "$(date -u '+%Y-%m-%dT%H:%M:%SZ')" "${socks:- none}" } zone_probe_name() { dirs="$(sed -n 's|^[[:space:]]*conf-dir=\([^,[:space:]]*\).*|\1|p' "${1}" 2>/dev/null)" # shellcheck disable=SC2086 # a dnsmasq conf-dir path carries no whitespace zone="$(grep -rhs '^[[:space:]]*address=/' "${1}" ${dirs} | sed -n 's|^[[:space:]]*address=/\([^/]*\)/.*|\1|p' | head -n1)" [ -n "${zone}" ] || return 0 printf 'rescue-probe.%s' "${zone}" } uptime_ms() { read -r up _ /dev/null 2>&1; then verdict=ok else verdict=fail fi printf ' %s=%s/%sms' "${name}" "${verdict}" "$(($(uptime_ms) - start))" } [ "${DNS53_SAMPLER_LIB:-}" = "1" ] && return 0 : "${INFINITO_DNS53_SAMPLER_LOG:?INFINITO_DNS53_SAMPLER_LOG must be set}" mkdir -p "$(dirname "${INFINITO_DNS53_SAMPLER_LOG}")" while :; do { printf '%s' "$(sample_once /proc/net/udp)" inzone="$(zone_probe_name /etc/dnsmasq.conf)" if [ -n "${inzone}" ]; then answer_once "${inzone}" else printf ' inzone=unconfigured' fi answer_once "${EXTERNAL_PROBE_NAME}" printf '\n' } >>"${INFINITO_DNS53_SAMPLER_LOG}" sleep 10 done