Exporting Ipmi.Path to be set by config. (#2498)

* Exporting Ipmi.Path to be set by config.

Currently "path" is not exported, giving this error when users try to
override the variable via telegraf.conf as per the sample config:

`field corresponding to `path' is not defined in `*ipmi_sensor.Ipmi'`

Exporting the variable solves the problem.

* Updating changelog.
This commit is contained in:
Robpol86 2017-03-08 08:38:36 -08:00 committed by Cameron Sparr
parent 4a9650ecf5
commit 68b10d73fc
3 changed files with 7 additions and 6 deletions

View File

@ -75,6 +75,7 @@ be deprecated eventually.
- [#2466](https://github.com/influxdata/telegraf/issues/2466): Telegraf can crash in LoadDirectory on 0600 files. - [#2466](https://github.com/influxdata/telegraf/issues/2466): Telegraf can crash in LoadDirectory on 0600 files.
- [#2215](https://github.com/influxdata/telegraf/issues/2215): Iptables input: document better that rules without a comment are ignored. - [#2215](https://github.com/influxdata/telegraf/issues/2215): Iptables input: document better that rules without a comment are ignored.
- [#2483](https://github.com/influxdata/telegraf/pull/2483): Fix win_perf_counters capping values at 100. - [#2483](https://github.com/influxdata/telegraf/pull/2483): Fix win_perf_counters capping values at 100.
- [#2498](https://github.com/influxdata/telegraf/pull/2498): Exporting Ipmi.Path to be set by config.
## v1.2.1 [2017-02-01] ## v1.2.1 [2017-02-01]

View File

@ -17,7 +17,7 @@ var (
) )
type Ipmi struct { type Ipmi struct {
path string Path string
Servers []string Servers []string
} }
@ -44,7 +44,7 @@ func (m *Ipmi) Description() string {
} }
func (m *Ipmi) Gather(acc telegraf.Accumulator) error { func (m *Ipmi) Gather(acc telegraf.Accumulator) error {
if len(m.path) == 0 { if len(m.Path) == 0 {
return fmt.Errorf("ipmitool not found: verify that ipmitool is installed and that ipmitool is in your PATH") return fmt.Errorf("ipmitool not found: verify that ipmitool is installed and that ipmitool is in your PATH")
} }
@ -76,7 +76,7 @@ func (m *Ipmi) parse(acc telegraf.Accumulator, server string) error {
} }
opts = append(opts, "sdr") opts = append(opts, "sdr")
cmd := execCommand(m.path, opts...) cmd := execCommand(m.Path, opts...)
out, err := internal.CombinedOutputTimeout(cmd, time.Second*5) out, err := internal.CombinedOutputTimeout(cmd, time.Second*5)
if err != nil { if err != nil {
return fmt.Errorf("failed to run command %s: %s - %s", strings.Join(cmd.Args, " "), err, string(out)) return fmt.Errorf("failed to run command %s: %s - %s", strings.Join(cmd.Args, " "), err, string(out))
@ -149,7 +149,7 @@ func init() {
m := Ipmi{} m := Ipmi{}
path, _ := exec.LookPath("ipmitool") path, _ := exec.LookPath("ipmitool")
if len(path) > 0 { if len(path) > 0 {
m.path = path m.Path = path
} }
inputs.Add("ipmi_sensor", func() telegraf.Input { inputs.Add("ipmi_sensor", func() telegraf.Input {
return &m return &m

View File

@ -14,7 +14,7 @@ import (
func TestGather(t *testing.T) { func TestGather(t *testing.T) {
i := &Ipmi{ i := &Ipmi{
Servers: []string{"USERID:PASSW0RD@lan(192.168.1.1)"}, Servers: []string{"USERID:PASSW0RD@lan(192.168.1.1)"},
path: "ipmitool", Path: "ipmitool",
} }
// overwriting exec commands with mock commands // overwriting exec commands with mock commands
execCommand = fakeExecCommand execCommand = fakeExecCommand
@ -118,7 +118,7 @@ func TestGather(t *testing.T) {
} }
i = &Ipmi{ i = &Ipmi{
path: "ipmitool", Path: "ipmitool",
} }
err = i.Gather(&acc) err = i.Gather(&acc)