From d5caaf5a4d91287383da30ab399ecd405695d8a5 Mon Sep 17 00:00:00 2001 From: Will Rouesnel Date: Sat, 14 Apr 2018 23:38:26 +1000 Subject: [PATCH] Fix issue #174 Postgres can emit 32MB and 64MB units which were previously unhandled. Handle them. --- cmd/postgres_exporter/pg_setting.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/postgres_exporter/pg_setting.go b/cmd/postgres_exporter/pg_setting.go index e3b89b5..d3deafc 100644 --- a/cmd/postgres_exporter/pg_setting.go +++ b/cmd/postgres_exporter/pg_setting.go @@ -96,7 +96,7 @@ func (s *pgSetting) normaliseUnit() (val float64, unit string, err error) { return case "ms", "s", "min", "h", "d": unit = "seconds" - case "kB", "MB", "GB", "TB", "8kB", "16kB", "32kB", "16MB": + case "kB", "MB", "GB", "TB", "8kB", "16kB", "32kB", "16MB", "32MB", "64MB": unit = "bytes" default: err = fmt.Errorf("Unknown unit for runtime variable: %q", s.unit) @@ -134,6 +134,12 @@ func (s *pgSetting) normaliseUnit() (val float64, unit string, err error) { case "16MB": val *= math.Pow(2, 24) } + case "32MB": + val *= math.Pow(2, 25) + } + case "64MB": + val *= math.Pow(2, 26) + } return }