Merge pull request #29 from CamilionEU/evilham-new-metrics
New metrics cleanupNotAccepted and smtpDeferreds.
This commit is contained in:
commit
9f69ed3c47
@ -51,6 +51,7 @@ type PostfixExporter struct {
|
|||||||
// Metrics that should persist after refreshes, based on logs.
|
// Metrics that should persist after refreshes, based on logs.
|
||||||
cleanupProcesses prometheus.Counter
|
cleanupProcesses prometheus.Counter
|
||||||
cleanupRejects prometheus.Counter
|
cleanupRejects prometheus.Counter
|
||||||
|
cleanupNotAccepted prometheus.Counter
|
||||||
lmtpDelays *prometheus.HistogramVec
|
lmtpDelays *prometheus.HistogramVec
|
||||||
pipeDelays *prometheus.HistogramVec
|
pipeDelays *prometheus.HistogramVec
|
||||||
qmgrInsertsNrcpt prometheus.Histogram
|
qmgrInsertsNrcpt prometheus.Histogram
|
||||||
@ -58,6 +59,7 @@ type PostfixExporter struct {
|
|||||||
qmgrRemoves prometheus.Counter
|
qmgrRemoves prometheus.Counter
|
||||||
smtpDelays *prometheus.HistogramVec
|
smtpDelays *prometheus.HistogramVec
|
||||||
smtpTLSConnects *prometheus.CounterVec
|
smtpTLSConnects *prometheus.CounterVec
|
||||||
|
smtpDeferreds prometheus.Counter
|
||||||
smtpdConnects prometheus.Counter
|
smtpdConnects prometheus.Counter
|
||||||
smtpdDisconnects prometheus.Counter
|
smtpdDisconnects prometheus.Counter
|
||||||
smtpdFCrDNSErrors prometheus.Counter
|
smtpdFCrDNSErrors prometheus.Counter
|
||||||
@ -279,6 +281,7 @@ var (
|
|||||||
lmtpPipeSMTPLine = regexp.MustCompile(`, relay=(\S+), .*, delays=([0-9\.]+)/([0-9\.]+)/([0-9\.]+)/([0-9\.]+), `)
|
lmtpPipeSMTPLine = regexp.MustCompile(`, relay=(\S+), .*, delays=([0-9\.]+)/([0-9\.]+)/([0-9\.]+)/([0-9\.]+), `)
|
||||||
qmgrInsertLine = regexp.MustCompile(`:.*, size=(\d+), nrcpt=(\d+) `)
|
qmgrInsertLine = regexp.MustCompile(`:.*, size=(\d+), nrcpt=(\d+) `)
|
||||||
smtpTLSLine = regexp.MustCompile(`^(\S+) TLS connection established to \S+: (\S+) with cipher (\S+) \((\d+)/(\d+) bits\)$`)
|
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 `)
|
smtpdFCrDNSErrorsLine = regexp.MustCompile(`^warning: hostname \S+ does not resolve to address `)
|
||||||
smtpdProcessesSASLLine = regexp.MustCompile(`: client=.*, sasl_username=(\S+)`)
|
smtpdProcessesSASLLine = regexp.MustCompile(`: client=.*, sasl_username=(\S+)`)
|
||||||
smtpdRejectsLine = regexp.MustCompile(`^NOQUEUE: reject: RCPT from \S+: ([0-9]+) `)
|
smtpdRejectsLine = regexp.MustCompile(`^NOQUEUE: reject: RCPT from \S+: ([0-9]+) `)
|
||||||
@ -297,6 +300,8 @@ func (e *PostfixExporter) CollectFromLogline(line string) {
|
|||||||
e.cleanupProcesses.Inc()
|
e.cleanupProcesses.Inc()
|
||||||
} else if strings.Contains(logMatches[2], ": reject: ") {
|
} else if strings.Contains(logMatches[2], ": reject: ") {
|
||||||
e.cleanupRejects.Inc()
|
e.cleanupRejects.Inc()
|
||||||
|
} else if strings.Contains(logMatches[2], "message not accepted") {
|
||||||
|
e.cleanupNotAccepted.Inc()
|
||||||
} else {
|
} else {
|
||||||
e.unsupportedLogEntries.WithLabelValues(logMatches[1]).Inc()
|
e.unsupportedLogEntries.WithLabelValues(logMatches[1]).Inc()
|
||||||
}
|
}
|
||||||
@ -389,6 +394,10 @@ func (e *PostfixExporter) CollectFromLogline(line string) {
|
|||||||
log.Printf("Couldn't convert SMTP xdelay: %v", err)
|
log.Printf("Couldn't convert SMTP xdelay: %v", err)
|
||||||
}
|
}
|
||||||
e.smtpDelays.WithLabelValues("transmission").Observe(xdelay)
|
e.smtpDelays.WithLabelValues("transmission").Observe(xdelay)
|
||||||
|
if smtpDeferredsMatches := smtpDeferredsLine.FindStringSubmatch(
|
||||||
|
logMatches[2]); smtpDeferredsMatches != nil {
|
||||||
|
e.smtpDeferreds.Inc()
|
||||||
|
}
|
||||||
} else if smtpTLSMatches := smtpTLSLine.FindStringSubmatch(logMatches[2]); smtpTLSMatches != nil {
|
} else if smtpTLSMatches := smtpTLSLine.FindStringSubmatch(logMatches[2]); smtpTLSMatches != nil {
|
||||||
e.smtpTLSConnects.WithLabelValues(smtpTLSMatches[1:]...).Inc()
|
e.smtpTLSConnects.WithLabelValues(smtpTLSMatches[1:]...).Inc()
|
||||||
} else {
|
} else {
|
||||||
@ -467,6 +476,11 @@ func NewPostfixExporter(showqPath string, logfilePath string, journal *Journal)
|
|||||||
Name: "cleanup_messages_rejected_total",
|
Name: "cleanup_messages_rejected_total",
|
||||||
Help: "Total number of messages rejected by cleanup.",
|
Help: "Total number of messages rejected by cleanup.",
|
||||||
}),
|
}),
|
||||||
|
cleanupNotAccepted: prometheus.NewCounter(prometheus.CounterOpts{
|
||||||
|
Namespace: "postfix",
|
||||||
|
Name: "cleanup_messages_not_accepted_total",
|
||||||
|
Help: "Total number of messages not accepted by cleanup.",
|
||||||
|
}),
|
||||||
lmtpDelays: prometheus.NewHistogramVec(
|
lmtpDelays: prometheus.NewHistogramVec(
|
||||||
prometheus.HistogramOpts{
|
prometheus.HistogramOpts{
|
||||||
Namespace: "postfix",
|
Namespace: "postfix",
|
||||||
@ -515,6 +529,11 @@ func NewPostfixExporter(showqPath string, logfilePath string, journal *Journal)
|
|||||||
Help: "Total number of outgoing TLS connections.",
|
Help: "Total number of outgoing TLS connections.",
|
||||||
},
|
},
|
||||||
[]string{"trust", "protocol", "cipher", "secret_bits", "algorithm_bits"}),
|
[]string{"trust", "protocol", "cipher", "secret_bits", "algorithm_bits"}),
|
||||||
|
smtpDeferreds: prometheus.NewCounter(prometheus.CounterOpts{
|
||||||
|
Namespace: "postfix",
|
||||||
|
Name: "smtp_deferred_messages_total",
|
||||||
|
Help: "Total number of messages that have been deferred on SMTP.",
|
||||||
|
}),
|
||||||
smtpdConnects: prometheus.NewCounter(prometheus.CounterOpts{
|
smtpdConnects: prometheus.NewCounter(prometheus.CounterOpts{
|
||||||
Namespace: "postfix",
|
Namespace: "postfix",
|
||||||
Name: "smtpd_connects_total",
|
Name: "smtpd_connects_total",
|
||||||
@ -579,6 +598,7 @@ func (e *PostfixExporter) Describe(ch chan<- *prometheus.Desc) {
|
|||||||
|
|
||||||
ch <- e.cleanupProcesses.Desc()
|
ch <- e.cleanupProcesses.Desc()
|
||||||
ch <- e.cleanupRejects.Desc()
|
ch <- e.cleanupRejects.Desc()
|
||||||
|
ch <- e.cleanupNotAccepted.Desc()
|
||||||
e.lmtpDelays.Describe(ch)
|
e.lmtpDelays.Describe(ch)
|
||||||
e.pipeDelays.Describe(ch)
|
e.pipeDelays.Describe(ch)
|
||||||
ch <- e.qmgrInsertsNrcpt.Desc()
|
ch <- e.qmgrInsertsNrcpt.Desc()
|
||||||
@ -586,6 +606,7 @@ func (e *PostfixExporter) Describe(ch chan<- *prometheus.Desc) {
|
|||||||
ch <- e.qmgrRemoves.Desc()
|
ch <- e.qmgrRemoves.Desc()
|
||||||
e.smtpDelays.Describe(ch)
|
e.smtpDelays.Describe(ch)
|
||||||
e.smtpTLSConnects.Describe(ch)
|
e.smtpTLSConnects.Describe(ch)
|
||||||
|
ch <- e.smtpDeferreds.Desc()
|
||||||
ch <- e.smtpdConnects.Desc()
|
ch <- e.smtpdConnects.Desc()
|
||||||
ch <- e.smtpdDisconnects.Desc()
|
ch <- e.smtpdDisconnects.Desc()
|
||||||
ch <- e.smtpdFCrDNSErrors.Desc()
|
ch <- e.smtpdFCrDNSErrors.Desc()
|
||||||
@ -640,6 +661,7 @@ func (e *PostfixExporter) Collect(ch chan<- prometheus.Metric) {
|
|||||||
|
|
||||||
ch <- e.cleanupProcesses
|
ch <- e.cleanupProcesses
|
||||||
ch <- e.cleanupRejects
|
ch <- e.cleanupRejects
|
||||||
|
ch <- e.cleanupNotAccepted
|
||||||
e.lmtpDelays.Collect(ch)
|
e.lmtpDelays.Collect(ch)
|
||||||
e.pipeDelays.Collect(ch)
|
e.pipeDelays.Collect(ch)
|
||||||
ch <- e.qmgrInsertsNrcpt
|
ch <- e.qmgrInsertsNrcpt
|
||||||
@ -647,6 +669,7 @@ func (e *PostfixExporter) Collect(ch chan<- prometheus.Metric) {
|
|||||||
ch <- e.qmgrRemoves
|
ch <- e.qmgrRemoves
|
||||||
e.smtpDelays.Collect(ch)
|
e.smtpDelays.Collect(ch)
|
||||||
e.smtpTLSConnects.Collect(ch)
|
e.smtpTLSConnects.Collect(ch)
|
||||||
|
ch <- e.smtpDeferreds
|
||||||
ch <- e.smtpdConnects
|
ch <- e.smtpdConnects
|
||||||
ch <- e.smtpdDisconnects
|
ch <- e.smtpdDisconnects
|
||||||
ch <- e.smtpdFCrDNSErrors
|
ch <- e.smtpdFCrDNSErrors
|
||||||
|
Loading…
Reference in New Issue
Block a user