From f66a0fd6639235078f419685a393cc01c59f3b90 Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Sat, 23 Jul 2016 16:16:42 -0400 Subject: [PATCH] use forked version of gosensors to avoid memory leak; be explicit about not handling Fahrenheit --- sensor-exporter/main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sensor-exporter/main.go b/sensor-exporter/main.go index 8c9f151..02df83d 100644 --- a/sensor-exporter/main.go +++ b/sensor-exporter/main.go @@ -12,7 +12,7 @@ import ( "strings" "time" - "github.com/md14454/gosensors" + "github.com/ncabatoff/gosensors" "github.com/prometheus/client_golang/prometheus" ) @@ -139,6 +139,8 @@ func parseHddTemps(s string) { pieces := strings.Split(item, "|") if len(pieces) != 4 { log.Printf("Error parsing item from hddtemp, expected 4 tokens: %s", item) + } else if pieces[3] != "C" { + log.Printf("Error parsing item from hddtemp, I only speak Celsius", item) } else { dev, id, temp := pieces[0], pieces[1], pieces[2] ftemp, err := strconv.ParseFloat(temp, 64) @@ -146,6 +148,7 @@ func parseHddTemps(s string) { log.Printf("Error parsing temperature as float: %s", temp) } else { hddtemperature.WithLabelValues(dev, id).Set(ftemp) + // TODO handle unit F } } }