Merge remote-tracking branch 'netlogix/nlx_master'

# Conflicts:
#	postfix_exporter.go
This commit is contained in:
Per Abich 2020-02-18 12:50:41 +01:00
commit 72c753ff7d

View File

@ -69,6 +69,7 @@ type PostfixExporter struct {
smtpdSASLAuthenticationFailures prometheus.Counter
smtpdTLSConnects *prometheus.CounterVec
unsupportedLogEntries *prometheus.CounterVec
smtpStatusDeferred prometheus.Counter
}
// CollectShowqFromReader parses the output of Postfix's 'showq' command
@ -280,6 +281,7 @@ var (
logLine = regexp.MustCompile(` ?postfix/(\w+)\[\d+\]: (.*)`)
lmtpPipeSMTPLine = regexp.MustCompile(`, relay=(\S+), .*, delays=([0-9\.]+)/([0-9\.]+)/([0-9\.]+)/([0-9\.]+), `)
qmgrInsertLine = regexp.MustCompile(`:.*, size=(\d+), nrcpt=(\d+) `)
smtpStatusDeferredLine = regexp.MustCompile(`, status=deferred`)
smtpTLSLine = regexp.MustCompile(`^(\S+) TLS connection established to \S+: (\S+) with cipher (\S+) \((\d+)/(\d+) bits\)$`)
smtpDeferredsLine = regexp.MustCompile(`status=deferred`)
smtpdFCrDNSErrorsLine = regexp.MustCompile(`^warning: hostname \S+ does not resolve to address `)
@ -394,9 +396,9 @@ func (e *PostfixExporter) CollectFromLogline(line string) {
log.Printf("Couldn't convert SMTP xdelay: %v", err)
}
e.smtpDelays.WithLabelValues("transmission").Observe(xdelay)
if smtpDeferredsMatches := smtpDeferredsLine.FindStringSubmatch(
logMatches[2]); smtpDeferredsMatches != nil {
e.smtpDeferreds.Inc()
if smtpMatches := smtpStatusDeferredLine.FindStringSubmatch(logMatches[2]) ; smtpMatches != nil {
e.smtpStatusDeferred.Inc()
}
} else if smtpTLSMatches := smtpTLSLine.FindStringSubmatch(logMatches[2]); smtpTLSMatches != nil {
e.smtpTLSConnects.WithLabelValues(smtpTLSMatches[1:]...).Inc()
@ -589,6 +591,12 @@ func NewPostfixExporter(showqPath string, logfilePath string, journal *Journal)
Help: "Log entries that could not be processed.",
},
[]string{"service"}),
smtpStatusDeferred: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "postfix",
Name: "smtp_status_deferred",
Help: "Total number of messages deferred.",
}),
}, nil
}
@ -615,6 +623,7 @@ func (e *PostfixExporter) Describe(ch chan<- *prometheus.Desc) {
e.smtpdRejects.Describe(ch)
ch <- e.smtpdSASLAuthenticationFailures.Desc()
e.smtpdTLSConnects.Describe(ch)
ch <- e.smtpStatusDeferred.Desc()
e.unsupportedLogEntries.Describe(ch)
}
@ -678,6 +687,7 @@ func (e *PostfixExporter) Collect(ch chan<- prometheus.Metric) {
e.smtpdRejects.Collect(ch)
ch <- e.smtpdSASLAuthenticationFailures
e.smtpdTLSConnects.Collect(ch)
ch <- e.smtpStatusDeferred
e.unsupportedLogEntries.Collect(ch)
}