diff --git a/CHANGELOG.md b/CHANGELOG.md index 846ba2b46..23e39adb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - [#1628](https://github.com/influxdata/telegraf/issues/1628): Fix mongodb input panic on version 2.2. - [#1738](https://github.com/influxdata/telegraf/issues/1738): Fix unmarshal of influxdb metrics with null tags - [#1733](https://github.com/influxdata/telegraf/issues/1733): Fix statsd scientific notation parsing +- [#1716](https://github.com/influxdata/telegraf/issues/1716): Sensors plugin strconv.ParseFloat: parsing "": invalid syntax ## v1.0 [2016-09-08] diff --git a/plugins/inputs/sensors/sensors.go b/plugins/inputs/sensors/sensors.go index 6e165e4cb..1caf6ba59 100644 --- a/plugins/inputs/sensors/sensors.go +++ b/plugins/inputs/sensors/sensors.go @@ -73,7 +73,7 @@ func (s *Sensors) parse(acc telegraf.Accumulator) error { tags["chip"] = chip continue } - if !strings.HasPrefix(line, " ") { + if !strings.HasPrefix(line, " ") { if len(tags) > 1 { acc.AddFields("sensors", fields, tags) } @@ -114,5 +114,5 @@ func init() { // snake converts string to snake case func snake(input string) string { - return strings.ToLower(strings.Replace(input, " ", "_", -1)) + return strings.ToLower(strings.Replace(strings.TrimSpace(input), " ", "_", -1)) } diff --git a/plugins/inputs/sensors/sensors_test.go b/plugins/inputs/sensors/sensors_test.go index 01d27abcf..7e6cac95a 100644 --- a/plugins/inputs/sensors/sensors_test.go +++ b/plugins/inputs/sensors/sensors_test.go @@ -122,6 +122,28 @@ func TestGatherDefault(t *testing.T) { "temp_crit_alarm": 0.0, }, }, + { + map[string]string{ + "chip": "atk0110-acpi-0", + "feature": "vcore_voltage", + }, + map[string]interface{}{ + "in_input": 1.136, + "in_min": 0.800, + "in_max": 1.600, + }, + }, + { + map[string]string{ + "chip": "atk0110-acpi-0", + "feature": "+3.3_voltage", + }, + map[string]interface{}{ + "in_input": 3.360, + "in_min": 2.970, + "in_max": 3.630, + }, + }, } for _, test := range tests { @@ -240,8 +262,29 @@ func TestGatherNotRemoveNumbers(t *testing.T) { "temp3_crit_alarm": 0.0, }, }, + { + map[string]string{ + "chip": "atk0110-acpi-0", + "feature": "vcore_voltage", + }, + map[string]interface{}{ + "in0_input": 1.136, + "in0_min": 0.800, + "in0_max": 1.600, + }, + }, + { + map[string]string{ + "chip": "atk0110-acpi-0", + "feature": "+3.3_voltage", + }, + map[string]interface{}{ + "in1_input": 3.360, + "in1_min": 2.970, + "in1_max": 3.630, + }, + }, } - for _, test := range tests { acc.AssertContainsTaggedFields(t, "sensors", test.fields, test.tags) } @@ -309,6 +352,16 @@ Core 1: temp3_max: 82.000 temp3_crit: 92.000 temp3_crit_alarm: 0.000 + +atk0110-acpi-0 +Vcore Voltage: + in0_input: 1.136 + in0_min: 0.800 + in0_max: 1.600 + +3.3 Voltage: + in1_input: 3.360 + in1_min: 2.970 + in1_max: 3.630 ` args := os.Args