Skip to content

Commit 7029ed4

Browse files
committedFeb 14, 2025
run gofmt
1 parent 643e687 commit 7029ed4

7 files changed

+44
-40
lines changed
 

‎logsource_docker.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build !nodocker
12
// +build !nodocker
23

34
package main

‎logsource_docker_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build !nodocker
12
// +build !nodocker
23

34
package main

‎logsource_file.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var defaultConfig = tail.Config{
1515
Follow: true, // run in follow mode
1616
Location: &tail.SeekInfo{Whence: io.SeekEnd}, // seek to end of file
1717
Logger: tail.DiscardingLogger,
18-
}
18+
}
1919

2020
// A FileLogSource can read lines from a file.
2121
type FileLogSource struct {

‎logsource_systemd.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build !nosystemd && linux
12
// +build !nosystemd,linux
23

34
package main

‎logsource_systemd_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build !nosystemd && linux
12
// +build !nosystemd,linux
23

34
package main

‎postfix_exporter.go

+20-20
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,21 @@ type PostfixExporter struct {
4545
logUnsupportedLines bool
4646

4747
// Metrics that should persist after refreshes, based on logs.
48-
cleanupProcesses prometheus.Counter
49-
cleanupRejects prometheus.Counter
50-
cleanupNotAccepted prometheus.Counter
51-
lmtpDelays *prometheus.HistogramVec
52-
pipeDelays *prometheus.HistogramVec
53-
qmgrInsertsNrcpt prometheus.Histogram
54-
qmgrInsertsSize prometheus.Histogram
55-
qmgrRemoves prometheus.Counter
56-
qmgrExpires prometheus.Counter
57-
smtpDelays *prometheus.HistogramVec
58-
smtpTLSConnects *prometheus.CounterVec
59-
smtpConnectionTimedOut prometheus.Counter
60-
smtpProcesses *prometheus.CounterVec
61-
smtpDeferredDSN *prometheus.CounterVec
62-
smtpBouncedDSN *prometheus.CounterVec
48+
cleanupProcesses prometheus.Counter
49+
cleanupRejects prometheus.Counter
50+
cleanupNotAccepted prometheus.Counter
51+
lmtpDelays *prometheus.HistogramVec
52+
pipeDelays *prometheus.HistogramVec
53+
qmgrInsertsNrcpt prometheus.Histogram
54+
qmgrInsertsSize prometheus.Histogram
55+
qmgrRemoves prometheus.Counter
56+
qmgrExpires prometheus.Counter
57+
smtpDelays *prometheus.HistogramVec
58+
smtpTLSConnects *prometheus.CounterVec
59+
smtpConnectionTimedOut prometheus.Counter
60+
smtpProcesses *prometheus.CounterVec
61+
smtpDeferredDSN *prometheus.CounterVec
62+
smtpBouncedDSN *prometheus.CounterVec
6363
// should be the same as smtpProcesses{status=deferred}, kept for compatibility, but this doesn't work !
6464
smtpDeferreds prometheus.Counter
6565
smtpdConnects prometheus.Counter
@@ -72,10 +72,10 @@ type PostfixExporter struct {
7272
smtpdTLSConnects *prometheus.CounterVec
7373
unsupportedLogEntries *prometheus.CounterVec
7474
// same as smtpProcesses{status=deferred}, kept for compatibility
75-
smtpStatusDeferred prometheus.Counter
76-
opendkimSignatureAdded *prometheus.CounterVec
77-
bounceNonDelivery prometheus.Counter
78-
virtualDelivered prometheus.Counter
75+
smtpStatusDeferred prometheus.Counter
76+
opendkimSignatureAdded *prometheus.CounterVec
77+
bounceNonDelivery prometheus.Counter
78+
virtualDelivered prometheus.Counter
7979
}
8080

8181
// A LogSource is an interface to read log lines.
@@ -404,7 +404,7 @@ func (e *PostfixExporter) CollectFromLogLine(line string) {
404404
} else if smtpdLostConnectionMatches := smtpdLostConnectionLine.FindStringSubmatch(remainder); smtpdLostConnectionMatches != nil {
405405
e.smtpdLostConnections.WithLabelValues(smtpdLostConnectionMatches[1]).Inc()
406406
} else if smtpdProcessesSASLMatches := smtpdProcessesSASLLine.FindStringSubmatch(remainder); smtpdProcessesSASLMatches != nil {
407-
e.smtpdProcesses.WithLabelValues(strings.Replace(smtpdProcessesSASLMatches[1],",","",-1)).Inc()
407+
e.smtpdProcesses.WithLabelValues(strings.Replace(smtpdProcessesSASLMatches[1], ",", "", -1)).Inc()
408408
} else if strings.Contains(remainder, ": client=") {
409409
e.smtpdProcesses.WithLabelValues("NONE").Inc()
410410
} else if smtpdRejectsMatches := smtpdRejectsLine.FindStringSubmatch(remainder); smtpdRejectsMatches != nil {

‎postfix_exporter_test.go

+19-19
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestPostfixExporter_CollectFromLogline(t *testing.T) {
5959
smtpMessagesProcessed int
6060
smtpDeferred int
6161
smtpBounced int
62-
bounceNonDelivery int
62+
bounceNonDelivery int
6363
virtualDelivered int
6464
unsupportedLogEntries []testCounterMetric
6565
}
@@ -133,10 +133,10 @@ func TestPostfixExporter_CollectFromLogline(t *testing.T) {
133133
"Apr 10 14:50:16 mail postfix/qmgr[3663]: BACE842E72: from=<noreply@domain.com>, status=expired, returned to sender",
134134
"Apr 10 14:50:16 mail postfix/qmgr[3663]: BACE842E73: from=<noreply@domain.com>, status=force-expired, returned to sender",
135135
},
136-
expiredCount: 2,
136+
expiredCount: 2,
137137
},
138138
fields: fields{
139-
qmgrExpires: prometheus.NewCounter(prometheus.CounterOpts{}),
139+
qmgrExpires: prometheus.NewCounter(prometheus.CounterOpts{}),
140140
},
141141
},
142142
{
@@ -152,7 +152,7 @@ func TestPostfixExporter_CollectFromLogline(t *testing.T) {
152152
},
153153
fields: fields{
154154
smtpdSASLAuthenticationFailures: prometheus.NewCounter(prometheus.CounterOpts{}),
155-
unsupportedLogEntries: prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"service", "level"}),
155+
unsupportedLogEntries: prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"service", "level"}),
156156
smtpProcesses: prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"status"}),
157157
},
158158
},
@@ -180,9 +180,9 @@ func TestPostfixExporter_CollectFromLogline(t *testing.T) {
180180
"Jul 24 04:38:17 mail postfix/smtp[30582]: Verified TLS connection established to gmail-smtp-in.l.google.com[108.177.14.26]:25: TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256",
181181
"Jul 24 03:28:15 mail postfix/smtp[24052]: Verified TLS connection established to mx2.comcast.net[2001:558:fe21:2a::6]:25: TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)",
182182
},
183-
removedCount: 0,
184-
saslFailedCount: 0,
185-
outgoingTLS: 2,
183+
removedCount: 0,
184+
saslFailedCount: 0,
185+
outgoingTLS: 2,
186186
smtpdMessagesProcessed: 0,
187187
},
188188
fields: fields{
@@ -204,7 +204,7 @@ func TestPostfixExporter_CollectFromLogline(t *testing.T) {
204204
smtpMessagesProcessed: 1,
205205
},
206206
fields: fields{
207-
smtpDelays: prometheus.NewHistogramVec(prometheus.HistogramOpts{}, []string{"stage"}),
207+
smtpDelays: prometheus.NewHistogramVec(prometheus.HistogramOpts{}, []string{"stage"}),
208208
smtpProcesses: prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"status"}),
209209
},
210210
},
@@ -217,19 +217,19 @@ func TestPostfixExporter_CollectFromLogline(t *testing.T) {
217217
"Dec 29 03:03:48 mail postfix/smtp[8492]: 732BB407C3: to=<redacted@domain.com>, relay=mail.domain.com[1.1.1.1]:25, delay=582, delays=563/16/1.7/0.81, dsn=5.0.0, status=bounced (host mail.domain.com[1.1.1.1] said: 554 DT:SPM 163 mx9,O8CowEDJVFKCokVaRhz+AA--.26016S3 1514513028,please see http://mail.domain.com/help/help_spam.htm?ip= (in reply to end of DATA command))",
218218
"Dec 29 03:03:48 mail postfix/bounce[9321]: 732BB407C3: sender non-delivery notification: 5DE184083C",
219219
},
220-
smtpMessagesProcessed: 2,
221-
smtpDeferred: 1,
222-
smtpBounced: 1,
223-
bounceNonDelivery: 1,
220+
smtpMessagesProcessed: 2,
221+
smtpDeferred: 1,
222+
smtpBounced: 1,
223+
bounceNonDelivery: 1,
224224
},
225225
fields: fields{
226226
unsupportedLogEntries: prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"service", "level"}),
227-
smtpDelays: prometheus.NewHistogramVec(prometheus.HistogramOpts{}, []string{"stage"}),
228-
smtpStatusDeferred: prometheus.NewCounter(prometheus.CounterOpts{}),
229-
smtpProcesses: prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"status"}),
230-
smtpDeferredDSN: prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"dsn"}),
231-
smtpBouncedDSN: prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"dsn"}),
232-
bounceNonDelivery: prometheus.NewCounter(prometheus.CounterOpts{}),
227+
smtpDelays: prometheus.NewHistogramVec(prometheus.HistogramOpts{}, []string{"stage"}),
228+
smtpStatusDeferred: prometheus.NewCounter(prometheus.CounterOpts{}),
229+
smtpProcesses: prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"status"}),
230+
smtpDeferredDSN: prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"dsn"}),
231+
smtpBouncedDSN: prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"dsn"}),
232+
bounceNonDelivery: prometheus.NewCounter(prometheus.CounterOpts{}),
233233
},
234234
},
235235
{
@@ -249,7 +249,7 @@ func TestPostfixExporter_CollectFromLogline(t *testing.T) {
249249
args: args{
250250
line: []string{
251251
"Feb 14 19:05:25 123-mail postfix/smtpd[1517]: table hash:/etc/postfix/virtual_mailbox_maps(0,lock|fold_fix) has changed -- restarting",
252-
"Mar 16 12:28:02 123-mail postfix/smtpd[16268]: fatal: file /etc/postfix/main.cf: parameter default_privs: unknown user name value: nobody",
252+
"Mar 16 12:28:02 123-mail postfix/smtpd[16268]: fatal: file /etc/postfix/main.cf: parameter default_privs: unknown user name value: nobody",
253253
"Mar 16 23:30:44 123-mail postfix/qmgr[29980]: warning: please avoid flushing the whole queue when you have",
254254
"Mar 16 23:30:44 123-mail postfix/qmgr[29980]: warning: lots of deferred mail, that is bad for performance",
255255
},

0 commit comments

Comments
 (0)