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
- func CollectPlaybooks(q *queue.Summary, st *maillog.Stats, only string) []provider.Hit
- func ConfigView(all map[string]string) map[string]string
- func HumanSize(n int64) string
- func WriteDNS(w io.Writer, s Style, r dnsauth.Report)
- func WriteLog(w io.Writer, s Style, lr LogResult)
- func WriteMessage(w io.Writer, s Style, r message.Report)
- func WritePlaybook(w io.Writer, s Style, p provider.Playbook)
- func WritePlaybookIndex(w io.Writer, s Style)
- func WritePlaybooks(w io.Writer, s Style, r PlaybookResult)
- func WriteQueue(w io.Writer, s Style, q queue.Summary)
- func WriteReplyLookup(w io.Writer, s Style, r ReplyLookup)
- func WriteReport(w io.Writer, s Style, r Report)
- func WriteShape(w io.Writer, s Style, sh queue.Shape)
- func WriteTrend(w io.Writer, s Style, tr TrendResult)
- type DNSOptions
- type Env
- func (e *Env) Config(ctx context.Context) (map[string]string, error)
- func (e *Env) DNS(ctx context.Context, o DNSOptions) (dnsauth.Report, error)
- func (e *Env) Identity(ctx context.Context) SenderIdentity
- func (e *Env) LogStats(ctx context.Context, window time.Duration, domain string, top int) (LogResult, error)
- func (e *Env) LogTrend(ctx context.Context, window, bucketSize time.Duration, domain string, top int) (TrendResult, error)
- func (e *Env) Message(ctx context.Context, id string, redact bool) (message.Report, error)
- func (e *Env) ProviderPlaybooks(ctx context.Context, window time.Duration, only string) (PlaybookResult, error)
- func (e *Env) Queue(ctx context.Context) ([]queue.Message, error)
- func (e *Env) Run(ctx context.Context, o Options) Report
- func (e *Env) Trace(ctx context.Context, query string, window time.Duration, limit int) ([]maillog.TracedMessage, string, error)
- type Finding
- type LogResult
- type Options
- type PlaybookResult
- type ReplyLookup
- type Report
- type SenderIdentity
- type Style
- type TrendResult
Constants ¶
const ( SevProblem = "problem" SevWarn = "warning" SevInfo = "info" )
Severity of a finding.
Variables ¶
This section is empty.
Functions ¶
func CollectPlaybooks ¶ added in v0.2.1
CollectPlaybooks matches queue delay reasons and log deferral/bounce texts against the provider playbooks. Either source may be nil.
func ConfigView ¶
ConfigView returns the subset of postconf -n that matters for delivery.
func WriteMessage ¶ added in v0.2.2
WriteMessage prints one queued message: where it is, who is still waiting and why, the route it took, its authentication and its headers.
func WritePlaybook ¶ added in v0.2.1
WritePlaybook prints one playbook in full, without evidence.
func WritePlaybookIndex ¶ added in v0.2.1
WritePlaybookIndex lists every built-in playbook.
func WritePlaybooks ¶ added in v0.2.1
func WritePlaybooks(w io.Writer, s Style, r PlaybookResult)
WritePlaybooks prints the provider playbooks for what is failing on this server.
func WriteQueue ¶
WriteQueue prints a queue summary.
func WriteReplyLookup ¶ added in v0.2.1
func WriteReplyLookup(w io.Writer, s Style, r ReplyLookup)
WriteReplyLookup prints the result of looking up one reply text.
func WriteReport ¶
WriteReport prints the doctor report.
func WriteShape ¶
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
// MessageFile: read saved "postcat -e -h -q ID" output instead of running postcat.
MessageFile string
Resolver dnsauth.Resolver
Now func() time.Time
}
Env is the shared runtime configuration.
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) Message ¶ added in v0.2.2
Message reads the envelope and headers of one queued message (postcat -e -h -q ID; never the body) and joins them with its postqueue -j entry for the delay reasons. With redact (always on over MCP) local parts, display names, subjects and other free text are hidden; secret-like headers are removed either way.
func (*Env) ProviderPlaybooks ¶ added in v0.2.1
func (e *Env) ProviderPlaybooks(ctx context.Context, window time.Duration, only string) (PlaybookResult, error)
ProviderPlaybooks reads the queue and the mail log (window, 0 = all) and returns the provider playbooks for what is failing. It fails only when neither source can be read.
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"`
// Provider playbook findings (area "provider") carry the full ordered
// steps and the provider's official references.
Playbook string `json:"playbook,omitempty"`
Steps []string `json:"steps,omitempty"`
References []provider.Ref `json:"references,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 PlaybookResult ¶ added in v0.2.1
type PlaybookResult struct {
LogSource string `json:"log_source,omitempty"`
Since time.Time `json:"since,omitempty"`
LogError string `json:"log_error,omitempty"`
QueueError string `json:"queue_error,omitempty"`
Provider string `json:"provider_filter,omitempty"`
Playbooks []provider.Hit `json:"playbooks"`
}
PlaybookResult is the provider playbooks that apply to this server.
type ReplyLookup ¶ added in v0.2.1
type ReplyLookup struct {
Reply string `json:"reply"`
Provider string `json:"provider,omitempty"`
ProviderName string `json:"provider_name,omitempty"`
Code string `json:"code,omitempty"`
CodeNote string `json:"code_note,omitempty"`
Temporary bool `json:"temporary"`
Category string `json:"category"`
Hint string `json:"hint"`
Playbook *provider.Playbook `json:"playbook"`
}
ReplyLookup is the playbook lookup for one pasted reply text.
func LookupReply ¶ added in v0.2.1
func LookupReply(text, rcptDomain string) ReplyLookup
LookupReply classifies one SMTP reply or delay reason (as found in the log or in postqueue output) and finds its provider playbook. rcptDomain is an optional hint used when the reply names no host.
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"`
Playbooks []provider.Hit `json:"provider_playbooks,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.
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.