doctor

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package doctor ties the queue, log, config and DNS checks together. Both the CLI and the MCP server call into it.

Index

Constants

View Source
const (
	SevProblem = "problem"
	SevWarn    = "warning"
	SevInfo    = "info"
)

Severity of a finding.

Variables

This section is empty.

Functions

func ConfigView

func ConfigView(all map[string]string) map[string]string

ConfigView returns the subset of postconf -n that matters for delivery.

func WriteDNS

func WriteDNS(w io.Writer, s Style, r dnsauth.Report)

WriteDNS prints DNS checks.

func WriteLog

func WriteLog(w io.Writer, s Style, lr LogResult)

WriteLog prints log stats.

func WriteQueue

func WriteQueue(w io.Writer, s Style, q queue.Summary)

WriteQueue prints a queue summary.

func WriteReport

func WriteReport(w io.Writer, s Style, r Report)

WriteReport prints the doctor report.

func WriteShape

func WriteShape(w io.Writer, s Style, sh queue.Shape)

WriteShape prints a qshape matrix.

func WriteTrend added in v0.2.0

func WriteTrend(w io.Writer, s Style, tr TrendResult)

WriteTrend prints per-destination deferral trends.

Types

type DNSOptions

type DNSOptions struct {
	Domain    string
	IPs       []string
	Selectors []string
	HELO      string
	// SelectorsFromLog: if no selectors are given, look for opendkim signing lines in the log.
	SelectorsFromLog bool
}

DNSOptions for DNS.

type Env

type Env struct {
	Runner    postfix.Runner
	Logs      postfix.LogSource
	QueueFile string // read postqueue -j output from this file instead of running postqueue
	Resolver  dnsauth.Resolver
	Now       func() time.Time
}

Env is the shared runtime configuration.

func (*Env) Config

func (e *Env) Config(ctx context.Context) (map[string]string, error)

Config returns `postconf -n` (empty map when Postfix is not reachable).

func (*Env) DNS

func (e *Env) DNS(ctx context.Context, o DNSOptions) (dnsauth.Report, error)

DNS runs the authentication checks. Missing domain/IPs are filled from postconf.

func (*Env) Identity

func (e *Env) Identity(ctx context.Context) SenderIdentity

Identity derives the sending domain/IPs from postconf (best effort).

func (*Env) LogStats

func (e *Env) LogStats(ctx context.Context, window time.Duration, domain string, top int) (LogResult, error)

LogStats aggregates the log since now-window.

func (*Env) LogTrend added in v0.2.0

func (e *Env) LogTrend(ctx context.Context, window, bucketSize time.Duration, domain string, top int) (TrendResult, error)

LogTrend aggregates per-destination deferral rates over time buckets. bucketSize 0 selects an automatic width from the window.

func (*Env) Queue

func (e *Env) Queue(ctx context.Context) ([]queue.Message, error)

Queue loads the queue.

func (*Env) Run

func (e *Env) Run(ctx context.Context, o Options) Report

Run produces a diagnosis. Individual sources may fail; their errors are recorded and the rest of the report is still produced.

func (*Env) Trace

func (e *Env) Trace(ctx context.Context, query string, window time.Duration, limit int) ([]maillog.TracedMessage, string, error)

Trace follows a queue ID or address through the log.

type Finding

type Finding struct {
	Severity string `json:"severity"`
	Area     string `json:"area"` // queue, log, dns, config
	Title    string `json:"title"`
	Detail   string `json:"detail,omitempty"`
	Next     string `json:"next_step,omitempty"`
}

Finding is one thing the operator should know.

type LogResult

type LogResult struct {
	Source string        `json:"source"`
	Since  time.Time     `json:"since"`
	Stats  maillog.Stats `json:"stats"`
}

LogResult is log statistics plus where they came from.

type Options

type Options struct {
	Window    time.Duration
	Domain    string
	IPs       []string
	Selectors []string
	SkipDNS   bool
	SkipLog   bool
	Top       int
}

Options for Run.

type Report

type Report struct {
	GeneratedAt time.Time         `json:"generated_at"`
	Identity    SenderIdentity    `json:"identity"`
	Queue       *queue.Summary    `json:"queue,omitempty"`
	QueueError  string            `json:"queue_error,omitempty"`
	Shape       *queue.Shape      `json:"shape,omitempty"`
	Log         *LogResult        `json:"log,omitempty"`
	LogError    string            `json:"log_error,omitempty"`
	Trend       *TrendResult      `json:"trend,omitempty"`
	DNS         *dnsauth.Report   `json:"dns,omitempty"`
	DNSError    string            `json:"dns_error,omitempty"`
	Config      map[string]string `json:"config,omitempty"`
	Findings    []Finding         `json:"findings"`
	Problems    int               `json:"problems"`
	Warnings    int               `json:"warnings"`
}

Report is the combined diagnosis.

func (Report) ExitCode

func (r Report) ExitCode() int

ExitCode is 0 when no problems were found, 1 otherwise.

type SenderIdentity

type SenderIdentity struct {
	Hostname string   `json:"myhostname"`
	Domain   string   `json:"sending_domain"`
	IPs      []string `json:"sending_ips"`
}

SenderIdentity is what Postfix presents to the world, from postconf.

type Style

type Style struct{ Color bool }

Style colours terminal output.

func (Style) Bold

func (s Style) Bold(t string) string

Bold text.

func (Style) Dim

func (s Style) Dim(t string) string

Dim text.

func (Style) Mark

func (s Style) Mark(status string) string

Mark returns a coloured status glyph.

type TrendResult added in v0.2.0

type TrendResult struct {
	Source string        `json:"source"`
	Since  time.Time     `json:"since"`
	Trend  maillog.Trend `json:"trend"`
}

TrendResult is per-destination deferral trends plus where they came from.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL