Fixing issue with collecting smtpdProcesses without Sasl

This commit is contained in:
Per Abich 2020-02-24 16:44:29 +01:00
parent ca63474631
commit b17eed2ad7
2 changed files with 3 additions and 2 deletions

View File

@ -373,7 +373,7 @@ func (e *PostfixExporter) CollectFromLogLine(line string) {
} else if smtpdProcessesSASLMatches := smtpdProcessesSASLLine.FindStringSubmatch(remainder); smtpdProcessesSASLMatches != nil {
e.smtpdProcesses.WithLabelValues(smtpdProcessesSASLMatches[1]).Inc()
} else if strings.Contains(remainder, ": client=") {
e.smtpdProcesses.WithLabelValues(smtpdProcessesSASLMatches[1]).Inc()
e.smtpdProcesses.WithLabelValues("").Inc()
} else if smtpdRejectsMatches := smtpdRejectsLine.FindStringSubmatch(remainder); smtpdRejectsMatches != nil {
e.smtpdRejects.WithLabelValues(smtpdRejectsMatches[1]).Inc()
} else if smtpdSASLAuthenticationFailuresLine.MatchString(remainder) {

View File

@ -125,11 +125,12 @@ func TestPostfixExporter_CollectFromLogline(t *testing.T) {
args: args{
line: []string{
"Oct 30 13:19:26 mailgw-out1 postfix/smtpd[27530]: EB4B2C19E2: client=xxx[1.2.3.4], sasl_method=PLAIN, sasl_username=user@domain",
"Feb 24 16:42:00 letterman postfix/smtpd[24906]: 1CF582025C: client=xxx[2.3.4.5]",
},
removedCount: 0,
saslFailedCount: 0,
outgoingTLS: 0,
smtpdMessagesProcessed: 1,
smtpdMessagesProcessed: 2,
},
fields: fields{
unsupportedLogEntries: prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"process"}),