Add user privilege level setting to IPMI sensors (#3643)

This commit is contained in:
Daniel Nelson
2018-01-05 15:59:25 -08:00
committed by GitHub
parent 500c3b68c9
commit aec09e711a
5 changed files with 27 additions and 15 deletions

View File

@@ -17,15 +17,19 @@ var (
)
type Ipmi struct {
Path string
Servers []string
Timeout internal.Duration
Path string
Privilege string
Servers []string
Timeout internal.Duration
}
var sampleConfig = `
## optionally specify the path to the ipmitool executable
# path = "/usr/bin/ipmitool"
#
##
## optionally force session privilege level. Can be CALLBACK, USER, OPERATOR, ADMINISTRATOR
# privilege = "ADMINISTRATOR"
##
## optionally specify one or more servers via a url matching
## [username[:password]@][protocol[(address)]]
## e.g.
@@ -77,13 +81,11 @@ func (m *Ipmi) Gather(acc telegraf.Accumulator) error {
func (m *Ipmi) parse(acc telegraf.Accumulator, server string) error {
opts := make([]string, 0)
hostname := ""
if server != "" {
conn := NewConnection(server)
conn := NewConnection(server, m.Privilege)
hostname = conn.Hostname
opts = conn.options()
}
opts = append(opts, "sdr")
cmd := execCommand(m.Path, opts...)
out, err := internal.CombinedOutputTimeout(cmd, m.Timeout.Duration)