Skip to content
This repository has been archived by the owner on Aug 17, 2021. It is now read-only.

Commit

Permalink
*Really* use the right timezone when parsing timestamps.
Browse files Browse the repository at this point in the history
  • Loading branch information
EdSchouten committed Mar 21, 2017
1 parent 21715e2 commit 5518c1e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions openvpn_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,15 @@ func CollectClientStatusFromReader(statusPath string, file io.Reader, ch chan<-
// Stats header.
} else if fields[0] == "Updated" && len(fields) == 2 {
// Time at which the statistics were updated.
time, err := time.Parse("Mon Jan 2 15:04:05 2006", fields[1])
location, _ := time.LoadLocation("Local")
time, err := time.ParseInLocation("Mon Jan 2 15:04:05 2006", fields[1], location)
if err != nil {
return err
}
ch <- prometheus.MustNewConstMetric(
openvpnStatusUpdateTimeDesc,
prometheus.GaugeValue,
float64(time.Local().Unix()),
float64(time.Unix()),
statusPath)
} else if desc, ok := openvpnClientDescs[fields[0]]; ok && len(fields) == 2 {
// Traffic counters.
Expand Down

0 comments on commit 5518c1e

Please sign in to comment.