From acf7a9791770ef3c56ca32065cb80a75f9338c69 Mon Sep 17 00:00:00 2001 From: Julian Kornberger Date: Mon, 28 Jan 2019 01:26:05 +0100 Subject: [PATCH 1/9] Use Go modules --- go.mod | 16 ++++++++++++++++ go.sum | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 go.mod create mode 100644 go.sum diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..24970d3 --- /dev/null +++ b/go.mod @@ -0,0 +1,16 @@ +module github.com/kumina/postfix_exporter + +require ( + github.com/alecthomas/kingpin v2.2.6+incompatible + github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect + github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect + github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142 + github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect + github.com/fsnotify/fsnotify v1.4.7 // indirect + github.com/hpcloud/tail v1.0.0 + github.com/prometheus/client_golang v0.9.2 + github.com/stretchr/testify v1.3.0 // indirect + golang.org/x/sys v0.0.0-20190220154126-629670e5acc5 // indirect + gopkg.in/fsnotify.v1 v1.4.7 // indirect + gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..871a6e5 --- /dev/null +++ b/go.sum @@ -0,0 +1,44 @@ +github.com/alecthomas/kingpin v2.2.6+incompatible h1:5svnBTFgJjZvGKyYBtMB0+m5wvrbUHiqye8wRJMlnYI= +github.com/alecthomas/kingpin v2.2.6+incompatible/go.mod h1:59OFYbFVLKQKq+mqrL6Rw5bR0c3ACQaawgXx0QYndlE= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142 h1:3jFq2xL4ZajGK4aZY8jz+DAF0FHjI51BXjjSwCzS1Dk= +github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.9.2 h1:awm861/B8OKDd2I/6o1dy3ra4BamzKhYOiGItCeZ740= +github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 h1:idejC8f05m9MGOsuEi1ATq9shN03HrxNkD/luQvxCv8= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/common v0.0.0-20181126121408-4724e9255275 h1:PnBWHBf+6L0jOqq0gIVUe6Yk0/QMZ640k6NvkxcBf+8= +github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a h1:9a8MnZMP0X2nLJdBg+pBmGgkJlSaKC2KaQmTCk1XDtE= +github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190220154126-629670e5acc5 h1:3Nsfe5Xa1wTt01QxlAFIY5j9ycDtS+d7mhvI8ZY5bn0= +golang.org/x/sys v0.0.0-20190220154126-629670e5acc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= From 99db0017f82b23ce065dc98ab88da21a4f6d98d1 Mon Sep 17 00:00:00 2001 From: Julian Kornberger Date: Mon, 28 Jan 2019 01:26:44 +0100 Subject: [PATCH 2/9] Update Dockerfile to use Go 1.11 with modules --- Dockerfile | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index bad4572..16f9a50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,23 @@ -FROM golang:1.8 -ADD . /go/src/github.com/kumina/postfix_exporter -WORKDIR /go/src/github.com/kumina/postfix_exporter +FROM golang:1.11 AS builder +WORKDIR /src + +# avoid downloading the dependencies on succesive builds RUN apt-get update -qq && apt-get install -qqy \ build-essential \ libsystemd-dev -RUN go get -v ./... -RUN go build + +COPY go.mod go.sum ./ +RUN go mod download +RUN go mod verify + +COPY . . + +# Force the go compiler to use modules +ENV GO111MODULE=on +RUN go build -o /bin/postfix_exporter FROM debian:latest EXPOSE 9154 WORKDIR / -COPY --from=0 /go/src/github.com/kumina/postfix_exporter/postfix_exporter . -ENTRYPOINT ["/postfix_exporter"] +COPY --from=builder /bin/postfix_exporter /bin/ +ENTRYPOINT ["/bin/postfix_exporter"] From 243cb7977972f5c9e48ef4994542390d2ecd317e Mon Sep 17 00:00:00 2001 From: Julian Kornberger Date: Mon, 28 Jan 2019 20:40:52 +0100 Subject: [PATCH 3/9] Reduce indentation --- postfix_exporter.go | 328 ++++++++++++++++++++++---------------------- 1 file changed, 167 insertions(+), 161 deletions(-) diff --git a/postfix_exporter.go b/postfix_exporter.go index 7fdd1a1..98460dd 100644 --- a/postfix_exporter.go +++ b/postfix_exporter.go @@ -130,37 +130,39 @@ func CollectTextualShowqFromReader(file io.Reader, ch chan<- prometheus.Metric) for scanner.Scan() { matches := messageLine.FindStringSubmatch(scanner.Text()) if matches != nil { - // Derive the name of the message queue. - queue := "other" - if matches[1] == "*" { - queue = "active" - } else if matches[1] == "!" { - queue = "hold" - } - - // Parse the message size. - size, err := strconv.ParseFloat(matches[2], 64) - if err != nil { - return err - } - - // Parse the message date. Unfortunately, the - // output contains no year number. Assume it - // applies to the last year for which the - // message date doesn't exceed time.Now(). - date, err := time.ParseInLocation("Mon Jan 2 15:04:05", - matches[3], location) - if err != nil { - return err - } - date = date.AddDate(now.Year(), 0, 0) - if date.After(now) { - date = date.AddDate(-1, 0, 0) - } - - sizeHistogram.WithLabelValues(queue).Observe(size) - ageHistogram.WithLabelValues(queue).Observe(now.Sub(date).Seconds()) + continue } + + // Derive the name of the message queue. + queue := "other" + if matches[1] == "*" { + queue = "active" + } else if matches[1] == "!" { + queue = "hold" + } + + // Parse the message size. + size, err := strconv.ParseFloat(matches[2], 64) + if err != nil { + return err + } + + // Parse the message date. Unfortunately, the + // output contains no year number. Assume it + // applies to the last year for which the + // message date doesn't exceed time.Now(). + date, err := time.ParseInLocation("Mon Jan 2 15:04:05", + matches[3], location) + if err != nil { + return err + } + date = date.AddDate(now.Year(), 0, 0) + if date.After(now) { + date = date.AddDate(-1, 0, 0) + } + + sizeHistogram.WithLabelValues(queue).Observe(size) + ageHistogram.WithLabelValues(queue).Observe(now.Sub(date).Seconds()) } sizeHistogram.Collect(ch) @@ -289,139 +291,143 @@ var ( // CollectFromLogline collects metrict from a Postfix log line. func (e *PostfixExporter) CollectFromLogline(line string) { // Strip off timestamp, hostname, etc. - if logMatches := logLine.FindStringSubmatch(line); logMatches != nil { - // Group patterns to check by Postfix service. - if logMatches[1] == "cleanup" { - if strings.Contains(logMatches[2], ": message-id=<") { - e.cleanupProcesses.Inc() - } else if strings.Contains(logMatches[2], ": reject: ") { - e.cleanupRejects.Inc() - } else { - e.unsupportedLogEntries.WithLabelValues(logMatches[1]).Inc() - } - } else if logMatches[1] == "lmtp" { - if lmtpMatches := lmtpPipeSMTPLine.FindStringSubmatch(logMatches[2]); lmtpMatches != nil { - pdelay, err := strconv.ParseFloat(lmtpMatches[2], 64) - if err != nil { - log.Printf("Couldn't convert LMTP pdelay: %v", err) - } - e.lmtpDelays.WithLabelValues("before_queue_manager").Observe(pdelay) - adelay, err := strconv.ParseFloat(lmtpMatches[3], 64) - if err != nil { - log.Printf("Couldn't convert LMTP adelay: %v", err) - } - e.lmtpDelays.WithLabelValues("queue_manager").Observe(adelay) - sdelay, err := strconv.ParseFloat(lmtpMatches[4], 64) - if err != nil { - log.Printf("Couldn't convert LMTP adelay: %v", err) - } - e.lmtpDelays.WithLabelValues("connection_setup").Observe(sdelay) - xdelay, err := strconv.ParseFloat(lmtpMatches[5], 64) - if err != nil { - log.Printf("Couldn't convert LMTP xdelay: %v", err) - } - e.lmtpDelays.WithLabelValues("transmission").Observe(xdelay) - } else { - e.unsupportedLogEntries.WithLabelValues(logMatches[1]).Inc() - } - } else if logMatches[1] == "pipe" { - if pipeMatches := lmtpPipeSMTPLine.FindStringSubmatch(logMatches[2]); pipeMatches != nil { - pdelay, err := strconv.ParseFloat(pipeMatches[2], 64) - if err != nil { - log.Printf("Couldn't convert PIPE pdelay: %v", err) - } - e.pipeDelays.WithLabelValues(pipeMatches[1], "before_queue_manager").Observe(pdelay) - adelay, err := strconv.ParseFloat(pipeMatches[3], 64) - if err != nil { - log.Printf("Couldn't convert PIPE adelay: %v", err) - } - e.pipeDelays.WithLabelValues(pipeMatches[1], "queue_manager").Observe(adelay) - sdelay, err := strconv.ParseFloat(pipeMatches[4], 64) - if err != nil { - log.Printf("Couldn't convert PIPE sdelay: %v", err) - } - e.pipeDelays.WithLabelValues(pipeMatches[1], "connection_setup").Observe(sdelay) - xdelay, err := strconv.ParseFloat(pipeMatches[5], 64) - if err != nil { - log.Printf("Couldn't convert PIPE xdelay: %v", err) - } - e.pipeDelays.WithLabelValues(pipeMatches[1], "transmission").Observe(xdelay) - } else { - e.unsupportedLogEntries.WithLabelValues(logMatches[1]).Inc() - } - } else if logMatches[1] == "qmgr" { - if qmgrInsertMatches := qmgrInsertLine.FindStringSubmatch(logMatches[2]); qmgrInsertMatches != nil { - size, err := strconv.ParseFloat(qmgrInsertMatches[1], 64) - if err != nil { - log.Printf("Couldn't convert QMGR size: %v", err) - } - e.qmgrInsertsSize.Observe(size) - nrcpt, err := strconv.ParseFloat(qmgrInsertMatches[2], 64) - if err != nil { - log.Printf("Couldn't convert QMGR nrcpt: %v", err) - } - e.qmgrInsertsNrcpt.Observe(nrcpt) - } else if strings.HasSuffix(logMatches[2], ": removed") { - e.qmgrRemoves.Inc() - } else { - e.unsupportedLogEntries.WithLabelValues(logMatches[1]).Inc() - } - } else if logMatches[1] == "smtp" { - if smtpMatches := lmtpPipeSMTPLine.FindStringSubmatch(logMatches[2]); smtpMatches != nil { - pdelay, err := strconv.ParseFloat(smtpMatches[2], 64) - if err != nil { - log.Printf("Couldn't convert SMTP pdelay: %v", err) - } - e.smtpDelays.WithLabelValues("before_queue_manager").Observe(pdelay) - adelay, err := strconv.ParseFloat(smtpMatches[3], 64) - if err != nil { - log.Printf("Couldn't convert SMTP adelay: %v", err) - } - e.smtpDelays.WithLabelValues("queue_manager").Observe(adelay) - sdelay, err := strconv.ParseFloat(smtpMatches[4], 64) - if err != nil { - log.Printf("Couldn't convert SMTP sdelay: %v", err) - } - e.smtpDelays.WithLabelValues("connection_setup").Observe(sdelay) - xdelay, err := strconv.ParseFloat(smtpMatches[5], 64) - if err != nil { - log.Printf("Couldn't convert SMTP xdelay: %v", err) - } - e.smtpDelays.WithLabelValues("transmission").Observe(xdelay) - } else if smtpTLSMatches := smtpTLSLine.FindStringSubmatch(logMatches[2]); smtpTLSMatches != nil { - e.smtpTLSConnects.WithLabelValues(smtpTLSMatches[1:]...).Inc() - } else { - e.unsupportedLogEntries.WithLabelValues(logMatches[1]).Inc() - } - } else if logMatches[1] == "smtpd" { - if strings.HasPrefix(logMatches[2], "connect from ") { - e.smtpdConnects.Inc() - } else if strings.HasPrefix(logMatches[2], "disconnect from ") { - e.smtpdDisconnects.Inc() - } else if smtpdFCrDNSErrorsLine.MatchString(logMatches[2]) { - e.smtpdFCrDNSErrors.Inc() - } else if smtpdLostConnectionMatches := smtpdLostConnectionLine.FindStringSubmatch(logMatches[2]); smtpdLostConnectionMatches != nil { - e.smtpdLostConnections.WithLabelValues(smtpdLostConnectionMatches[1]).Inc() - } else if smtpdProcessesSASLMatches := smtpdProcessesSASLLine.FindStringSubmatch(logMatches[2]); smtpdProcessesSASLMatches != nil { - e.smtpdProcesses.WithLabelValues(smtpdProcessesSASLMatches[1]).Inc() - } else if strings.Contains(logMatches[2], ": client=") { - e.smtpdProcesses.WithLabelValues("").Inc() - } else if smtpdRejectsMatches := smtpdRejectsLine.FindStringSubmatch(logMatches[2]); smtpdRejectsMatches != nil { - e.smtpdRejects.WithLabelValues(smtpdRejectsMatches[1]).Inc() - } else if smtpdSASLAuthenticationFailuresLine.MatchString(logMatches[2]) { - e.smtpdSASLAuthenticationFailures.Inc() - } else if smtpdTLSMatches := smtpdTLSLine.FindStringSubmatch(logMatches[2]); smtpdTLSMatches != nil { - e.smtpdTLSConnects.WithLabelValues(smtpdTLSMatches[1:]...).Inc() - } else { - e.unsupportedLogEntries.WithLabelValues(logMatches[1]).Inc() - } - } else { - // Unknown Postfix service. - e.unsupportedLogEntries.WithLabelValues(logMatches[1]).Inc() - } - } else { + logMatches := logLine.FindStringSubmatch(line) + + if logMatches == nil { // Unknown log entry format. e.unsupportedLogEntries.WithLabelValues("").Inc() + return + } + + // Group patterns to check by Postfix service. + switch logMatches[1] { + case "cleanup": + if strings.Contains(logMatches[2], ": message-id=<") { + e.cleanupProcesses.Inc() + } else if strings.Contains(logMatches[2], ": reject: ") { + e.cleanupRejects.Inc() + } else { + e.unsupportedLogEntries.WithLabelValues(logMatches[1]).Inc() + } + case "lmtp": + if lmtpMatches := lmtpPipeSMTPLine.FindStringSubmatch(logMatches[2]); lmtpMatches != nil { + pdelay, err := strconv.ParseFloat(lmtpMatches[2], 64) + if err != nil { + log.Printf("Couldn't convert LMTP pdelay: %v", err) + } + e.lmtpDelays.WithLabelValues("before_queue_manager").Observe(pdelay) + adelay, err := strconv.ParseFloat(lmtpMatches[3], 64) + if err != nil { + log.Printf("Couldn't convert LMTP adelay: %v", err) + } + e.lmtpDelays.WithLabelValues("queue_manager").Observe(adelay) + sdelay, err := strconv.ParseFloat(lmtpMatches[4], 64) + if err != nil { + log.Printf("Couldn't convert LMTP adelay: %v", err) + } + e.lmtpDelays.WithLabelValues("connection_setup").Observe(sdelay) + xdelay, err := strconv.ParseFloat(lmtpMatches[5], 64) + if err != nil { + log.Printf("Couldn't convert LMTP xdelay: %v", err) + } + e.lmtpDelays.WithLabelValues("transmission").Observe(xdelay) + } else { + e.unsupportedLogEntries.WithLabelValues(logMatches[1]).Inc() + } + case "pipe": + if pipeMatches := lmtpPipeSMTPLine.FindStringSubmatch(logMatches[2]); pipeMatches != nil { + pdelay, err := strconv.ParseFloat(pipeMatches[2], 64) + if err != nil { + log.Printf("Couldn't convert PIPE pdelay: %v", err) + } + e.pipeDelays.WithLabelValues(pipeMatches[1], "before_queue_manager").Observe(pdelay) + adelay, err := strconv.ParseFloat(pipeMatches[3], 64) + if err != nil { + log.Printf("Couldn't convert PIPE adelay: %v", err) + } + e.pipeDelays.WithLabelValues(pipeMatches[1], "queue_manager").Observe(adelay) + sdelay, err := strconv.ParseFloat(pipeMatches[4], 64) + if err != nil { + log.Printf("Couldn't convert PIPE sdelay: %v", err) + } + e.pipeDelays.WithLabelValues(pipeMatches[1], "connection_setup").Observe(sdelay) + xdelay, err := strconv.ParseFloat(pipeMatches[5], 64) + if err != nil { + log.Printf("Couldn't convert PIPE xdelay: %v", err) + } + e.pipeDelays.WithLabelValues(pipeMatches[1], "transmission").Observe(xdelay) + } else { + e.unsupportedLogEntries.WithLabelValues(logMatches[1]).Inc() + } + case "qmgr": + if qmgrInsertMatches := qmgrInsertLine.FindStringSubmatch(logMatches[2]); qmgrInsertMatches != nil { + size, err := strconv.ParseFloat(qmgrInsertMatches[1], 64) + if err != nil { + log.Printf("Couldn't convert QMGR size: %v", err) + } + e.qmgrInsertsSize.Observe(size) + nrcpt, err := strconv.ParseFloat(qmgrInsertMatches[2], 64) + if err != nil { + log.Printf("Couldn't convert QMGR nrcpt: %v", err) + } + e.qmgrInsertsNrcpt.Observe(nrcpt) + } else if strings.HasSuffix(logMatches[2], ": removed") { + e.qmgrRemoves.Inc() + } else { + e.unsupportedLogEntries.WithLabelValues(logMatches[1]).Inc() + } + case "smtp": + if smtpMatches := lmtpPipeSMTPLine.FindStringSubmatch(logMatches[2]); smtpMatches != nil { + pdelay, err := strconv.ParseFloat(smtpMatches[2], 64) + if err != nil { + log.Printf("Couldn't convert SMTP pdelay: %v", err) + } + e.smtpDelays.WithLabelValues("before_queue_manager").Observe(pdelay) + adelay, err := strconv.ParseFloat(smtpMatches[3], 64) + if err != nil { + log.Printf("Couldn't convert SMTP adelay: %v", err) + } + e.smtpDelays.WithLabelValues("queue_manager").Observe(adelay) + sdelay, err := strconv.ParseFloat(smtpMatches[4], 64) + if err != nil { + log.Printf("Couldn't convert SMTP sdelay: %v", err) + } + e.smtpDelays.WithLabelValues("connection_setup").Observe(sdelay) + xdelay, err := strconv.ParseFloat(smtpMatches[5], 64) + if err != nil { + log.Printf("Couldn't convert SMTP xdelay: %v", err) + } + e.smtpDelays.WithLabelValues("transmission").Observe(xdelay) + } else if smtpTLSMatches := smtpTLSLine.FindStringSubmatch(logMatches[2]); smtpTLSMatches != nil { + e.smtpTLSConnects.WithLabelValues(smtpTLSMatches[1:]...).Inc() + } else { + e.unsupportedLogEntries.WithLabelValues(logMatches[1]).Inc() + } + case "smtpd": + if strings.HasPrefix(logMatches[2], "connect from ") { + e.smtpdConnects.Inc() + } else if strings.HasPrefix(logMatches[2], "disconnect from ") { + e.smtpdDisconnects.Inc() + } else if smtpdFCrDNSErrorsLine.MatchString(logMatches[2]) { + e.smtpdFCrDNSErrors.Inc() + } else if smtpdLostConnectionMatches := smtpdLostConnectionLine.FindStringSubmatch(logMatches[2]); smtpdLostConnectionMatches != nil { + e.smtpdLostConnections.WithLabelValues(smtpdLostConnectionMatches[1]).Inc() + } else if smtpdProcessesSASLMatches := smtpdProcessesSASLLine.FindStringSubmatch(logMatches[2]); smtpdProcessesSASLMatches != nil { + e.smtpdProcesses.WithLabelValues(smtpdProcessesSASLMatches[1]).Inc() + } else if strings.Contains(logMatches[2], ": client=") { + e.smtpdProcesses.WithLabelValues("").Inc() + } else if smtpdRejectsMatches := smtpdRejectsLine.FindStringSubmatch(logMatches[2]); smtpdRejectsMatches != nil { + e.smtpdRejects.WithLabelValues(smtpdRejectsMatches[1]).Inc() + } else if smtpdSASLAuthenticationFailuresLine.MatchString(logMatches[2]) { + e.smtpdSASLAuthenticationFailures.Inc() + } else if smtpdTLSMatches := smtpdTLSLine.FindStringSubmatch(logMatches[2]); smtpdTLSMatches != nil { + e.smtpdTLSConnects.WithLabelValues(smtpdTLSMatches[1:]...).Inc() + } else { + e.unsupportedLogEntries.WithLabelValues(logMatches[1]).Inc() + } + default: + // Unknown Postfix service. + e.unsupportedLogEntries.WithLabelValues(logMatches[1]).Inc() } } From 7072c5242f1b7244dfe094988a68c70f0aede2d5 Mon Sep 17 00:00:00 2001 From: Julian Kornberger Date: Mon, 28 Jan 2019 21:13:37 +0100 Subject: [PATCH 4/9] Small refactoring --- postfix_exporter.go | 100 +++++++++++++------------------------------- 1 file changed, 30 insertions(+), 70 deletions(-) diff --git a/postfix_exporter.go b/postfix_exporter.go index 98460dd..5ec0e19 100644 --- a/postfix_exporter.go +++ b/postfix_exporter.go @@ -311,66 +311,26 @@ func (e *PostfixExporter) CollectFromLogline(line string) { } case "lmtp": if lmtpMatches := lmtpPipeSMTPLine.FindStringSubmatch(logMatches[2]); lmtpMatches != nil { - pdelay, err := strconv.ParseFloat(lmtpMatches[2], 64) - if err != nil { - log.Printf("Couldn't convert LMTP pdelay: %v", err) - } - e.lmtpDelays.WithLabelValues("before_queue_manager").Observe(pdelay) - adelay, err := strconv.ParseFloat(lmtpMatches[3], 64) - if err != nil { - log.Printf("Couldn't convert LMTP adelay: %v", err) - } - e.lmtpDelays.WithLabelValues("queue_manager").Observe(adelay) - sdelay, err := strconv.ParseFloat(lmtpMatches[4], 64) - if err != nil { - log.Printf("Couldn't convert LMTP adelay: %v", err) - } - e.lmtpDelays.WithLabelValues("connection_setup").Observe(sdelay) - xdelay, err := strconv.ParseFloat(lmtpMatches[5], 64) - if err != nil { - log.Printf("Couldn't convert LMTP xdelay: %v", err) - } - e.lmtpDelays.WithLabelValues("transmission").Observe(xdelay) + addToHistogramVec(e.lmtpDelays, lmtpMatches[2], "LMTP pdelay", "before_queue_manager") + addToHistogramVec(e.lmtpDelays, lmtpMatches[3], "LMTP adelay", "queue_manager") + addToHistogramVec(e.lmtpDelays, lmtpMatches[4], "LMTP sdelay", "connection_setup") + addToHistogramVec(e.lmtpDelays, lmtpMatches[5], "LMTP xdelay", "transmission") } else { e.unsupportedLogEntries.WithLabelValues(logMatches[1]).Inc() } case "pipe": if pipeMatches := lmtpPipeSMTPLine.FindStringSubmatch(logMatches[2]); pipeMatches != nil { - pdelay, err := strconv.ParseFloat(pipeMatches[2], 64) - if err != nil { - log.Printf("Couldn't convert PIPE pdelay: %v", err) - } - e.pipeDelays.WithLabelValues(pipeMatches[1], "before_queue_manager").Observe(pdelay) - adelay, err := strconv.ParseFloat(pipeMatches[3], 64) - if err != nil { - log.Printf("Couldn't convert PIPE adelay: %v", err) - } - e.pipeDelays.WithLabelValues(pipeMatches[1], "queue_manager").Observe(adelay) - sdelay, err := strconv.ParseFloat(pipeMatches[4], 64) - if err != nil { - log.Printf("Couldn't convert PIPE sdelay: %v", err) - } - e.pipeDelays.WithLabelValues(pipeMatches[1], "connection_setup").Observe(sdelay) - xdelay, err := strconv.ParseFloat(pipeMatches[5], 64) - if err != nil { - log.Printf("Couldn't convert PIPE xdelay: %v", err) - } - e.pipeDelays.WithLabelValues(pipeMatches[1], "transmission").Observe(xdelay) + addToHistogramVec(e.pipeDelays, pipeMatches[2], "PIPE pdelay", pipeMatches[1], "before_queue_manager") + addToHistogramVec(e.pipeDelays, pipeMatches[3], "PIPE adelay", pipeMatches[1], "queue_manager") + addToHistogramVec(e.pipeDelays, pipeMatches[4], "PIPE sdelay", pipeMatches[1], "connection_setup") + addToHistogramVec(e.pipeDelays, pipeMatches[5], "PIPE xdelay", pipeMatches[1], "transmission") } else { e.unsupportedLogEntries.WithLabelValues(logMatches[1]).Inc() } case "qmgr": if qmgrInsertMatches := qmgrInsertLine.FindStringSubmatch(logMatches[2]); qmgrInsertMatches != nil { - size, err := strconv.ParseFloat(qmgrInsertMatches[1], 64) - if err != nil { - log.Printf("Couldn't convert QMGR size: %v", err) - } - e.qmgrInsertsSize.Observe(size) - nrcpt, err := strconv.ParseFloat(qmgrInsertMatches[2], 64) - if err != nil { - log.Printf("Couldn't convert QMGR nrcpt: %v", err) - } - e.qmgrInsertsNrcpt.Observe(nrcpt) + addToHistogram(e.qmgrInsertsSize, qmgrInsertMatches[1], "QMGR size") + addToHistogram(e.qmgrInsertsNrcpt, qmgrInsertMatches[2], "QMGR nrcpt") } else if strings.HasSuffix(logMatches[2], ": removed") { e.qmgrRemoves.Inc() } else { @@ -378,26 +338,10 @@ func (e *PostfixExporter) CollectFromLogline(line string) { } case "smtp": if smtpMatches := lmtpPipeSMTPLine.FindStringSubmatch(logMatches[2]); smtpMatches != nil { - pdelay, err := strconv.ParseFloat(smtpMatches[2], 64) - if err != nil { - log.Printf("Couldn't convert SMTP pdelay: %v", err) - } - e.smtpDelays.WithLabelValues("before_queue_manager").Observe(pdelay) - adelay, err := strconv.ParseFloat(smtpMatches[3], 64) - if err != nil { - log.Printf("Couldn't convert SMTP adelay: %v", err) - } - e.smtpDelays.WithLabelValues("queue_manager").Observe(adelay) - sdelay, err := strconv.ParseFloat(smtpMatches[4], 64) - if err != nil { - log.Printf("Couldn't convert SMTP sdelay: %v", err) - } - e.smtpDelays.WithLabelValues("connection_setup").Observe(sdelay) - xdelay, err := strconv.ParseFloat(smtpMatches[5], 64) - if err != nil { - log.Printf("Couldn't convert SMTP xdelay: %v", err) - } - e.smtpDelays.WithLabelValues("transmission").Observe(xdelay) + addToHistogramVec(e.smtpDelays, smtpMatches[2], "before_queue_manager") + addToHistogramVec(e.smtpDelays, smtpMatches[3], "queue_manager") + addToHistogramVec(e.smtpDelays, smtpMatches[4], "connection_setup") + addToHistogramVec(e.smtpDelays, smtpMatches[5], "transmission") } else if smtpTLSMatches := smtpTLSLine.FindStringSubmatch(logMatches[2]); smtpTLSMatches != nil { e.smtpTLSConnects.WithLabelValues(smtpTLSMatches[1:]...).Inc() } else { @@ -431,6 +375,22 @@ func (e *PostfixExporter) CollectFromLogline(line string) { } } +func addToHistogram(h prometheus.Histogram, value, fieldName string) { + float, err := strconv.ParseFloat(value, 64) + if err != nil { + log.Printf("Couldn't convert value '%s' for %v: %v", value, fieldName, err) + } + h.Observe(float) +} + +func addToHistogramVec(h *prometheus.HistogramVec, value, fieldName string, labels ...string) { + float, err := strconv.ParseFloat(value, 64) + if err != nil { + log.Printf("Couldn't convert value '%s' for %v: %v", value, fieldName, err) + } + h.WithLabelValues(labels...).Observe(float) +} + // CollectLogfileFromFile tails a Postfix log file and collects entries from it. func (e *PostfixExporter) CollectLogfileFromFile() error { for { From 43221afdb0039727598871d16c837bc6d79a09fc Mon Sep 17 00:00:00 2001 From: Julian Kornberger Date: Thu, 21 Feb 2019 00:03:41 +0100 Subject: [PATCH 5/9] Move main function to main.go --- main.go | 63 +++++++++++++++++++++++++++++++++++++++++++++ postfix_exporter.go | 56 ---------------------------------------- 2 files changed, 63 insertions(+), 56 deletions(-) create mode 100644 main.go diff --git a/main.go b/main.go new file mode 100644 index 0000000..27f6737 --- /dev/null +++ b/main.go @@ -0,0 +1,63 @@ +package main + +import ( + "log" + "net/http" + "os" + + "github.com/alecthomas/kingpin" + "github.com/prometheus/client_golang/prometheus" +) + +func main() { + var ( + app = kingpin.New("postfix_exporter", "Prometheus metrics exporter for postfix") + listenAddress = app.Flag("web.listen-address", "Address to listen on for web interface and telemetry.").Default(":9154").String() + metricsPath = app.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").String() + postfixShowqPath = app.Flag("postfix.showq_path", "Path at which Postfix places its showq socket.").Default("/var/spool/postfix/public/showq").String() + postfixLogfilePath = app.Flag("postfix.logfile_path", "Path where Postfix writes log entries. This file will be truncated by this exporter.").Default("/var/log/postfix_exporter_input.log").String() + systemdEnable bool + systemdUnit, systemdSlice, systemdJournalPath string + ) + systemdFlags(&systemdEnable, &systemdUnit, &systemdSlice, &systemdJournalPath, app) + + kingpin.MustParse(app.Parse(os.Args[1:])) + + var journal *Journal + if systemdEnable { + var err error + journal, err = NewJournal(systemdUnit, systemdSlice, systemdJournalPath) + if err != nil { + log.Fatalf("Error opening systemd journal: %s", err) + } + defer journal.Close() + } + + exporter, err := NewPostfixExporter( + *postfixShowqPath, + *postfixLogfilePath, + journal, + ) + if err != nil { + log.Fatalf("Failed to create PostfixExporter: %s", err) + } + prometheus.MustRegister(exporter) + + http.Handle(*metricsPath, prometheus.Handler()) + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + _, err = w.Write([]byte(` + + Postfix Exporter + +

Postfix Exporter

+

Metrics

+ + `)) + if err != nil { + panic(err) + } + }) + + log.Print("Listening on ", *listenAddress) + log.Fatal(http.ListenAndServe(*listenAddress, nil)) +} diff --git a/postfix_exporter.go b/postfix_exporter.go index 5ec0e19..cd22bff 100644 --- a/postfix_exporter.go +++ b/postfix_exporter.go @@ -18,12 +18,9 @@ import ( "bytes" "errors" "fmt" - "github.com/alecthomas/kingpin" "io" "log" "net" - "net/http" - "os" "regexp" "strconv" "strings" @@ -622,56 +619,3 @@ func (e *PostfixExporter) Collect(ch chan<- prometheus.Metric) { e.smtpdTLSConnects.Collect(ch) e.unsupportedLogEntries.Collect(ch) } - -func main() { - var ( - app = kingpin.New("postfix_exporter", "Prometheus metrics exporter for postfix") - listenAddress = app.Flag("web.listen-address", "Address to listen on for web interface and telemetry.").Default(":9154").String() - metricsPath = app.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").String() - postfixShowqPath = app.Flag("postfix.showq_path", "Path at which Postfix places its showq socket.").Default("/var/spool/postfix/public/showq").String() - postfixLogfilePath = app.Flag("postfix.logfile_path", "Path where Postfix writes log entries. This file will be truncated by this exporter.").Default("/var/log/postfix_exporter_input.log").String() - systemdEnable bool - systemdUnit, systemdSlice, systemdJournalPath string - ) - systemdFlags(&systemdEnable, &systemdUnit, &systemdSlice, &systemdJournalPath, app) - - kingpin.MustParse(app.Parse(os.Args[1:])) - - var journal *Journal - if systemdEnable { - var err error - journal, err = NewJournal(systemdUnit, systemdSlice, systemdJournalPath) - if err != nil { - log.Fatalf("Error opening systemd journal: %s", err) - } - defer journal.Close() - } - - exporter, err := NewPostfixExporter( - *postfixShowqPath, - *postfixLogfilePath, - journal, - ) - if err != nil { - log.Fatalf("Failed to create PostfixExporter: %s", err) - } - prometheus.MustRegister(exporter) - - http.Handle(*metricsPath, prometheus.Handler()) - http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - _, err = w.Write([]byte(` - - Postfix Exporter - -

Postfix Exporter

-

Metrics

- - `)) - if err != nil { - panic(err) - } - }) - - log.Print("Listening on ", *listenAddress) - log.Fatal(http.ListenAndServe(*listenAddress, nil)) -} From 8e333e774e1397fc4fdfd383f72e1aafce651d21 Mon Sep 17 00:00:00 2001 From: Julian Kornberger Date: Thu, 21 Feb 2019 00:14:45 +0100 Subject: [PATCH 6/9] Update dependencies --- go.mod | 7 ++++--- go.sum | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 24970d3..082a7f3 100644 --- a/go.mod +++ b/go.mod @@ -2,13 +2,14 @@ module github.com/kumina/postfix_exporter require ( github.com/alecthomas/kingpin v2.2.6+incompatible - github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect - github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect - github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142 + github.com/coreos/go-systemd v0.0.0-20190212144455-93d5ec2c7f76 github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect github.com/fsnotify/fsnotify v1.4.7 // indirect github.com/hpcloud/tail v1.0.0 github.com/prometheus/client_golang v0.9.2 + github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 // indirect + github.com/prometheus/common v0.2.0 // indirect + github.com/prometheus/procfs v0.0.0-20190219184716-e4d4a2206da0 // indirect github.com/stretchr/testify v1.3.0 // indirect golang.org/x/sys v0.0.0-20190220154126-629670e5acc5 // indirect gopkg.in/fsnotify.v1 v1.4.7 // indirect diff --git a/go.sum b/go.sum index 871a6e5..371ef30 100644 --- a/go.sum +++ b/go.sum @@ -6,39 +6,70 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZq github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142 h1:3jFq2xL4ZajGK4aZY8jz+DAF0FHjI51BXjjSwCzS1Dk= -github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd v0.0.0-20190212144455-93d5ec2c7f76 h1:FE783w8WFh+Rvg+7bZ5g8p7gP4SeVS4AoNwkvazlsBg= +github.com/coreos/go-systemd v0.0.0-20190212144455-93d5ec2c7f76/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.2 h1:awm861/B8OKDd2I/6o1dy3ra4BamzKhYOiGItCeZ740= github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 h1:idejC8f05m9MGOsuEi1ATq9shN03HrxNkD/luQvxCv8= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 h1:S/YWwWx/RA8rT8tKFRuGUZhuA90OyIBpPCXkcbwU8DE= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181126121408-4724e9255275 h1:PnBWHBf+6L0jOqq0gIVUe6Yk0/QMZ640k6NvkxcBf+8= github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.2.0 h1:kUZDBDTdBVBYBj5Tmh2NZLlF60mfjA27rM34b+cVwNU= +github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a h1:9a8MnZMP0X2nLJdBg+pBmGgkJlSaKC2KaQmTCk1XDtE= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190219184716-e4d4a2206da0 h1:4+Tdy73otddqWxwK30bAMLH9ymeHQ1Y5+fmSoCF1XtU= +github.com/prometheus/procfs v0.0.0-20190219184716-e4d4a2206da0/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190220154126-629670e5acc5 h1:3Nsfe5Xa1wTt01QxlAFIY5j9ycDtS+d7mhvI8ZY5bn0= golang.org/x/sys v0.0.0-20190220154126-629670e5acc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From d23c664b657a1d9f4a959481885ba3da865e17ee Mon Sep 17 00:00:00 2001 From: Per Abich Date: Wed, 19 Feb 2020 18:10:45 +0100 Subject: [PATCH 7/9] Fixing merge issues --- main.go | 13 ++++- postfix_exporter.go | 133 ++++++++------------------------------------ 2 files changed, 35 insertions(+), 111 deletions(-) diff --git a/main.go b/main.go index 27f6737..5e3adb8 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,8 @@ package main import ( + "context" + "github.com/prometheus/client_golang/prometheus/promhttp" "log" "net/http" "os" @@ -16,6 +18,7 @@ func main() { metricsPath = app.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").String() postfixShowqPath = app.Flag("postfix.showq_path", "Path at which Postfix places its showq socket.").Default("/var/spool/postfix/public/showq").String() postfixLogfilePath = app.Flag("postfix.logfile_path", "Path where Postfix writes log entries. This file will be truncated by this exporter.").Default("/var/log/postfix_exporter_input.log").String() + logUnsupportedLines = app.Flag("log.unsupported", "Log all unsupported lines.").Bool() systemdEnable bool systemdUnit, systemdSlice, systemdJournalPath string ) @@ -31,19 +34,23 @@ func main() { log.Fatalf("Error opening systemd journal: %s", err) } defer journal.Close() + log.Println("Reading log events from systemd") + } else { + log.Printf("Reading log events from %v", *postfixLogfilePath) } exporter, err := NewPostfixExporter( *postfixShowqPath, *postfixLogfilePath, journal, + *logUnsupportedLines, ) if err != nil { log.Fatalf("Failed to create PostfixExporter: %s", err) } prometheus.MustRegister(exporter) - http.Handle(*metricsPath, prometheus.Handler()) + http.Handle(*metricsPath, promhttp.Handler()) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { _, err = w.Write([]byte(` @@ -57,7 +64,9 @@ func main() { panic(err) } }) - + ctx, cancelFunc := context.WithCancel(context.Background()) + defer cancelFunc() + go exporter.StartMetricCollection(ctx) log.Print("Listening on ", *listenAddress) log.Fatal(http.ListenAndServe(*listenAddress, nil)) } diff --git a/postfix_exporter.go b/postfix_exporter.go index ce59e0a..18f906c 100644 --- a/postfix_exporter.go +++ b/postfix_exporter.go @@ -258,16 +258,6 @@ func CollectBinaryShowqFromReader(file io.Reader, ch chan<- prometheus.Metric) e return scanner.Err() } -// CollectShowqFromFile collects Postfix queue statistics from a file. -//func CollectShowqFromFile(path string, ch chan<- prometheus.Metric) error { -// fd, err := os.Open(path) -// if err != nil { -// return err -// } -// defer fd.Close() -// return CollectShowqFromReader(fd, ch) -//} - // CollectShowqFromSocket collects Postfix queue statistics from a socket. func CollectShowqFromSocket(path string, ch chan<- prometheus.Metric) error { fd, err := net.Dial("unix", path) @@ -302,15 +292,15 @@ func (e *PostfixExporter) CollectFromLogLine(line string) { if logMatches == nil { // Unknown log entry format. - e.unsupportedLogEntries.WithLabelValues("").Inc() + e.addToUnsupportedLine(line, "") return } process := logMatches[1] - subprocess := logMatches[3] remainder := logMatches[4] switch process { case "postfix": // Group patterns to check by Postfix service. + subprocess := logMatches[3] switch subprocess { case "cleanup": if strings.Contains(remainder, ": message-id=<") { @@ -318,10 +308,7 @@ func (e *PostfixExporter) CollectFromLogLine(line string) { } else if strings.Contains(remainder, ": reject: ") { e.cleanupRejects.Inc() } else { - if e.logUnsupportedLines { - log.Printf("Unsupported Line: %v", line) - } - e.unsupportedLogEntries.WithLabelValues(subprocess).Inc() + e.addToUnsupportedLine(line, subprocess) } case "lmtp": if lmtpMatches := lmtpPipeSMTPLine.FindStringSubmatch(remainder); lmtpMatches != nil { @@ -330,10 +317,7 @@ func (e *PostfixExporter) CollectFromLogLine(line string) { addToHistogramVec(e.lmtpDelays, lmtpMatches[4], "LMTP sdelay", "connection_setup") addToHistogramVec(e.lmtpDelays, lmtpMatches[5], "LMTP xdelay", "transmission") } else { - if e.logUnsupportedLines { - log.Printf("Unsupported Line: %v", line) - } - e.unsupportedLogEntries.WithLabelValues(subprocess).Inc() + e.addToUnsupportedLine(line, subprocess) } case "pipe": if pipeMatches := lmtpPipeSMTPLine.FindStringSubmatch(remainder); pipeMatches != nil { @@ -342,10 +326,7 @@ func (e *PostfixExporter) CollectFromLogLine(line string) { addToHistogramVec(e.pipeDelays, pipeMatches[4], "PIPE sdelay", pipeMatches[1], "connection_setup") addToHistogramVec(e.pipeDelays, pipeMatches[5], "PIPE xdelay", pipeMatches[1], "transmission") } else { - if e.logUnsupportedLines { - log.Printf("Unsupported Line: %v", line) - } - e.unsupportedLogEntries.WithLabelValues(subprocess).Inc() + e.addToUnsupportedLine(line, subprocess) } case "qmgr": if qmgrInsertMatches := qmgrInsertLine.FindStringSubmatch(remainder); qmgrInsertMatches != nil { @@ -354,10 +335,7 @@ func (e *PostfixExporter) CollectFromLogLine(line string) { } else if strings.HasSuffix(remainder, ": removed") { e.qmgrRemoves.Inc() } else { - if e.logUnsupportedLines { - log.Printf("Unsupported Line: %v", line) - } - e.unsupportedLogEntries.WithLabelValues(subprocess).Inc() + e.addToUnsupportedLine(line, subprocess) } case "smtp": if smtpMatches := lmtpPipeSMTPLine.FindStringSubmatch(remainder); smtpMatches != nil { @@ -365,13 +343,15 @@ func (e *PostfixExporter) CollectFromLogLine(line string) { addToHistogramVec(e.smtpDelays, smtpMatches[3], "queue_manager") addToHistogramVec(e.smtpDelays, smtpMatches[4], "connection_setup") addToHistogramVec(e.smtpDelays, smtpMatches[5], "transmission") + if smtpMatches := smtpStatusDeferredLine.FindStringSubmatch(remainder); smtpMatches != nil { + e.smtpStatusDeferred.Inc() + } } else if smtpTLSMatches := smtpTLSLine.FindStringSubmatch(remainder); smtpTLSMatches != nil { e.smtpTLSConnects.WithLabelValues(smtpTLSMatches[1:]...).Inc() + } else if smtpMatches := smtpConnectionTimedOut.FindStringSubmatch(remainder); smtpMatches != nil { + e.smtpConnectionTimedOut.Inc() } else { - if e.logUnsupportedLines { - log.Printf("Unsupported Line: %v", line) - } - e.unsupportedLogEntries.WithLabelValues(subprocess).Inc() + e.addToUnsupportedLine(line, subprocess) } case "smtpd": if strings.HasPrefix(remainder, "connect from ") { @@ -393,35 +373,30 @@ func (e *PostfixExporter) CollectFromLogLine(line string) { } else if smtpdTLSMatches := smtpdTLSLine.FindStringSubmatch(remainder); smtpdTLSMatches != nil { e.smtpdTLSConnects.WithLabelValues(smtpdTLSMatches[1:]...).Inc() } else { - if e.logUnsupportedLines { - log.Printf("Unsupported Line: %v", line) - } - e.unsupportedLogEntries.WithLabelValues(subprocess).Inc() + e.addToUnsupportedLine(line, subprocess) } default: - if e.logUnsupportedLines { - log.Printf("Unsupported Line: %v", line) - } - // Unknown Postfix service. - e.unsupportedLogEntries.WithLabelValues(subprocess).Inc() + e.addToUnsupportedLine(line, subprocess) } case "opendkim": if opendkimMatches := opendkimSignatureAdded.FindStringSubmatch(remainder); opendkimMatches != nil { e.opendkimSignatureAdded.WithLabelValues(opendkimMatches[1], opendkimMatches[2]).Inc() } else { - if e.logUnsupportedLines { - log.Printf("Unsupported Line: %v", line) - } - e.unsupportedLogEntries.WithLabelValues(process).Inc() + e.addToUnsupportedLine(line, process) } default: // Unknown log entry format. - if e.logUnsupportedLines { - log.Printf("Unsupported Line: %v", line) - } - e.unsupportedLogEntries.WithLabelValues("").Inc() + e.addToUnsupportedLine(line, "") } } + +func (e *PostfixExporter) addToUnsupportedLine(line string, subprocess string) { + if e.logUnsupportedLines { + log.Printf("Unsupported Line: %v", line) + } + e.unsupportedLogEntries.WithLabelValues(subprocess).Inc() +} + func addToHistogram(h prometheus.Histogram, value, fieldName string) { float, err := strconv.ParseFloat(value, 64) if err != nil { @@ -735,63 +710,3 @@ func (e *PostfixExporter) Collect(ch chan<- prometheus.Metric) { ch <- e.smtpConnectionTimedOut e.opendkimSignatureAdded.Collect(ch) } - -func main() { - var ( - app = kingpin.New("postfix_exporter", "Prometheus metrics exporter for postfix") - listenAddress = app.Flag("web.listen-address", "Address to listen on for web interface and telemetry.").Default(":9154").String() - metricsPath = app.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").String() - postfixShowqPath = app.Flag("postfix.showq_path", "Path at which Postfix places its showq socket.").Default("/var/spool/postfix/public/showq").String() - postfixLogfilePath = app.Flag("postfix.logfile_path", "Path where Postfix writes log entries. This file will be truncated by this exporter.").Default("/var/log/postfix_exporter_input.log").String() - logUnsupportedLines = app.Flag("log.unsupported", "Log all unsupported lines.").Bool() - systemdEnable bool - systemdUnit, systemdSlice, systemdJournalPath string - ) - systemdFlags(&systemdEnable, &systemdUnit, &systemdSlice, &systemdJournalPath, app) - - kingpin.MustParse(app.Parse(os.Args[1:])) - - var journal *Journal - if systemdEnable { - var err error - journal, err = NewJournal(systemdUnit, systemdSlice, systemdJournalPath) - if err != nil { - log.Fatalf("Error opening systemd journal: %s", err) - } - defer journal.Close() - log.Println("Reading log events from systemd") - } else { - log.Printf("Reading log events from %v", *postfixLogfilePath) - } - - exporter, err := NewPostfixExporter( - *postfixShowqPath, - *postfixLogfilePath, - journal, - *logUnsupportedLines, - ) - if err != nil { - log.Fatalf("Failed to create PostfixExporter: %s", err) - } - prometheus.MustRegister(exporter) - - http.Handle(*metricsPath, promhttp.Handler()) - http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - _, err = w.Write([]byte(` - - Postfix Exporter - -

Postfix Exporter

-

Metrics

- - `)) - if err != nil { - panic(err) - } - }) - ctx, cancelFunc := context.WithCancel(context.Background()) - defer cancelFunc() - go exporter.StartMetricCollection(ctx) - log.Print("Listening on ", *listenAddress) - log.Fatal(http.ListenAndServe(*listenAddress, nil)) -} From 30711892c6405b3e61f57b7cafc109826dafeda9 Mon Sep 17 00:00:00 2001 From: Per Abich Date: Wed, 19 Feb 2020 18:11:52 +0100 Subject: [PATCH 8/9] added go.sum --- go.sum | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 go.sum diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..bea5d93 --- /dev/null +++ b/go.sum @@ -0,0 +1,111 @@ +github.com/alecthomas/kingpin v2.2.6+incompatible h1:5svnBTFgJjZvGKyYBtMB0+m5wvrbUHiqye8wRJMlnYI= +github.com/alecthomas/kingpin v2.2.6+incompatible/go.mod h1:59OFYbFVLKQKq+mqrL6Rw5bR0c3ACQaawgXx0QYndlE= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4 h1:Hs82Z41s6SdL1CELW+XaDYmOH4hkBN4/N9og/AsOv7E= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/coreos/go-systemd/v22 v22.0.0 h1:XJIw/+VlJ+87J+doOxznsAWIdmWuViOVhkQamW5YV28= +github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.4.1 h1:FFSuS004yOQEtDdTq+TAOLP5xUq63KqAFYyOi8zA+Y8= +github.com/prometheus/client_golang v1.4.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.9.1 h1:KOMtN28tlbam3/7ZKEYKHhKoJZYYj3gMH4uc62x7X7U= +github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82 h1:ywK/j/KkyTHcdyYSZNXGjMwgmDSfjglYZ3vStQ/gSCU= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5 h1:ymVxjfMaHvXD8RqPRmzHHsB3VvucivSkIAvJFDI5O3c= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 2e1ca8fd52cbb00ca9e201d9ea3f0191ec6df66d Mon Sep 17 00:00:00 2001 From: Per Abich Date: Wed, 19 Feb 2020 18:18:31 +0100 Subject: [PATCH 9/9] ran "go mod tidy" after merge --- go.mod | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 9eba737..3d5e663 100644 --- a/go.mod +++ b/go.mod @@ -10,14 +10,6 @@ require ( github.com/prometheus/client_golang v1.4.1 github.com/prometheus/client_model v0.2.0 github.com/stretchr/testify v1.4.0 - github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect - github.com/fsnotify/fsnotify v1.4.7 // indirect - github.com/hpcloud/tail v1.0.0 - github.com/prometheus/client_golang v0.9.2 - github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 // indirect - github.com/prometheus/common v0.2.0 // indirect - github.com/prometheus/procfs v0.0.0-20190219184716-e4d4a2206da0 // indirect - github.com/stretchr/testify v1.3.0 // indirect - golang.org/x/sys v0.0.0-20190220154126-629670e5acc5 // indirect + gopkg.in/fsnotify.v1 v1.4.7 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect )