113 lines
3.8 KiB
Go
113 lines
3.8 KiB
Go
package resolver
|
|
|
|
type ResolverSummaryLogInput struct {
|
|
DomainsTotal int
|
|
FreshCount int
|
|
CacheNegativeHits int
|
|
QuarantineHits int
|
|
StaleHits int
|
|
ResolvedTotal int
|
|
UnresolvedAfterAttempts int
|
|
LiveBatchTarget int
|
|
LiveDeferred int
|
|
LiveP1 int
|
|
LiveP2 int
|
|
LiveP3 int
|
|
LiveBatchNXHeavyPct int
|
|
LiveNXHeavyTotal int
|
|
LiveNXHeavySkip int
|
|
StaticEntries int
|
|
StaticSkipped int
|
|
UniqueIPs int
|
|
DirectIPs int
|
|
WildcardIPs int
|
|
PtrLookups int
|
|
PtrErrors int
|
|
DNSStats DNSMetrics
|
|
TimeoutRecheck ResolverTimeoutRecheckStats
|
|
DurationMS int64
|
|
DomainStateSummary string
|
|
ResolvedNowDNS int
|
|
ResolvedNowStale int
|
|
PrecheckDue bool
|
|
PrecheckScheduled int
|
|
PrecheckStatePath string
|
|
}
|
|
|
|
func LogResolverSummary(in ResolverSummaryLogInput, logf func(string, ...any)) {
|
|
if logf == nil {
|
|
return
|
|
}
|
|
|
|
dnsErrors := in.DNSStats.TotalErrors()
|
|
unresolved := in.DomainsTotal - in.ResolvedTotal
|
|
unresolvedSuppressed := in.CacheNegativeHits + in.QuarantineHits + in.LiveDeferred
|
|
|
|
logf(
|
|
"resolve summary: domains=%d cache_hits=%d cache_neg_hits=%d quarantine_hits=%d stale_hits=%d resolved_now=%d unresolved=%d unresolved_live=%d unresolved_suppressed=%d live_batch_target=%d live_batch_deferred=%d live_batch_p1=%d live_batch_p2=%d live_batch_p3=%d live_batch_nxheavy_pct=%d live_batch_nxheavy_total=%d live_batch_nxheavy_skip=%d static_entries=%d static_skipped=%d unique_ips=%d direct_ips=%d wildcard_ips=%d ptr_lookups=%d ptr_errors=%d dns_attempts=%d dns_ok=%d dns_nxdomain=%d dns_timeout=%d dns_temporary=%d dns_other=%d dns_cooldown_skips=%d dns_errors=%d timeout_recheck_checked=%d timeout_recheck_recovered=%d timeout_recheck_recovered_ips=%d timeout_recheck_still_timeout=%d timeout_recheck_now_nxdomain=%d timeout_recheck_now_temporary=%d timeout_recheck_now_other=%d timeout_recheck_no_signal=%d duration_ms=%d",
|
|
in.DomainsTotal,
|
|
in.FreshCount,
|
|
in.CacheNegativeHits,
|
|
in.QuarantineHits,
|
|
in.StaleHits,
|
|
in.ResolvedTotal-in.FreshCount,
|
|
unresolved,
|
|
in.UnresolvedAfterAttempts,
|
|
unresolvedSuppressed,
|
|
in.LiveBatchTarget,
|
|
in.LiveDeferred,
|
|
in.LiveP1,
|
|
in.LiveP2,
|
|
in.LiveP3,
|
|
in.LiveBatchNXHeavyPct,
|
|
in.LiveNXHeavyTotal,
|
|
in.LiveNXHeavySkip,
|
|
in.StaticEntries,
|
|
in.StaticSkipped,
|
|
in.UniqueIPs,
|
|
in.DirectIPs,
|
|
in.WildcardIPs,
|
|
in.PtrLookups,
|
|
in.PtrErrors,
|
|
in.DNSStats.Attempts,
|
|
in.DNSStats.OK,
|
|
in.DNSStats.NXDomain,
|
|
in.DNSStats.Timeout,
|
|
in.DNSStats.Temporary,
|
|
in.DNSStats.Other,
|
|
in.DNSStats.Skipped,
|
|
dnsErrors,
|
|
in.TimeoutRecheck.Checked,
|
|
in.TimeoutRecheck.Recovered,
|
|
in.TimeoutRecheck.RecoveredIPs,
|
|
in.TimeoutRecheck.StillTimeout,
|
|
in.TimeoutRecheck.NowNXDomain,
|
|
in.TimeoutRecheck.NowTemporary,
|
|
in.TimeoutRecheck.NowOther,
|
|
in.TimeoutRecheck.NoSignal,
|
|
in.DurationMS,
|
|
)
|
|
if perUpstream := in.DNSStats.FormatPerUpstream(); perUpstream != "" {
|
|
logf("resolve dns upstreams: %s", perUpstream)
|
|
}
|
|
if health := in.DNSStats.FormatResolverHealth(); health != "" {
|
|
logf("resolve dns health: %s", health)
|
|
}
|
|
if in.DomainStateSummary != "" {
|
|
logf("resolve domain states: %s", in.DomainStateSummary)
|
|
}
|
|
logf(
|
|
"resolve breakdown: resolved_now_total=%d resolved_now_dns=%d resolved_now_stale=%d skipped_neg=%d skipped_quarantine=%d deferred_live_batch=%d unresolved_after_attempts=%d",
|
|
in.ResolvedTotal-in.FreshCount,
|
|
in.ResolvedNowDNS,
|
|
in.ResolvedNowStale,
|
|
in.CacheNegativeHits,
|
|
in.QuarantineHits,
|
|
in.LiveDeferred,
|
|
in.UnresolvedAfterAttempts,
|
|
)
|
|
if in.PrecheckDue {
|
|
logf("resolve precheck done: scheduled=%d state=%s", in.PrecheckScheduled, in.PrecheckStatePath)
|
|
}
|
|
}
|