From a907c85658a06586b2710d5ac0c1c9e495d854b4 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Mon, 29 May 2017 14:51:46 +0200 Subject: [PATCH] Parse showq timestamps in the right timezone. --- postfix_exporter.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/postfix_exporter.go b/postfix_exporter.go index d7ac3b0..44906d3 100644 --- a/postfix_exporter.go +++ b/postfix_exporter.go @@ -111,6 +111,7 @@ func CollectTextualShowqFromReader(file io.Reader, ch chan<- prometheus.Metric) []string{"queue"}) now := time.Now() + location, _ := time.LoadLocation("Local") for scanner.Scan() { matches := messageLine.FindStringSubmatch(scanner.Text()) if matches != nil { @@ -132,7 +133,8 @@ func CollectTextualShowqFromReader(file io.Reader, ch chan<- prometheus.Metric) // 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.Parse("Mon Jan 2 15:04:05", matches[3]) + date, err := time.ParseInLocation("Mon Jan 2 15:04:05", + matches[3], location) if err != nil { return err }