From 2e4f6f58869eca1c9869bc6a57d204a5dfa4c09e Mon Sep 17 00:00:00 2001 From: admin account Date: Tue, 25 Feb 2020 08:07:37 +0000 Subject: [PATCH 01/12] Added redfish plugin Signed-off-by: admin account --- plugins/inputs/all/all.go | 1 + plugins/inputs/redfish/README.md | 159 ++++ plugins/inputs/redfish/redfish.go | 394 ++++++++ plugins/inputs/redfish/redfish_test.go | 849 ++++++++++++++++++ .../redfish/testdata/.dell_power.json.swp | Bin 0 -> 24576 bytes .../redfish/testdata/dell_hostname.json | 329 +++++++ .../testdata/dell_hostnameinvalid.json | 329 +++++++ .../redfish/testdata/dell_location.json | 187 ++++ .../testdata/dell_locationinvalid.json | 188 ++++ .../inputs/redfish/testdata/dell_power.json | 207 +++++ .../redfish/testdata/dell_powerinvalid.json | 207 +++++ .../inputs/redfish/testdata/dell_thermal.json | 589 ++++++++++++ .../redfish/testdata/dell_thermalinvalid.json | 589 ++++++++++++ .../inputs/redfish/testdata/hp_hostname.json | 319 +++++++ .../redfish/testdata/hp_hostnameinvalid.json | 320 +++++++ plugins/inputs/redfish/testdata/hp_power.json | 144 +++ .../redfish/testdata/hp_powerinvalid.json | 145 +++ .../inputs/redfish/testdata/hp_thermal.json | 116 +++ .../redfish/testdata/hp_thermalinvalid.json | 117 +++ 19 files changed, 5189 insertions(+) create mode 100644 plugins/inputs/redfish/README.md create mode 100644 plugins/inputs/redfish/redfish.go create mode 100644 plugins/inputs/redfish/redfish_test.go create mode 100644 plugins/inputs/redfish/testdata/.dell_power.json.swp create mode 100644 plugins/inputs/redfish/testdata/dell_hostname.json create mode 100644 plugins/inputs/redfish/testdata/dell_hostnameinvalid.json create mode 100644 plugins/inputs/redfish/testdata/dell_location.json create mode 100644 plugins/inputs/redfish/testdata/dell_locationinvalid.json create mode 100644 plugins/inputs/redfish/testdata/dell_power.json create mode 100644 plugins/inputs/redfish/testdata/dell_powerinvalid.json create mode 100644 plugins/inputs/redfish/testdata/dell_thermal.json create mode 100644 plugins/inputs/redfish/testdata/dell_thermalinvalid.json create mode 100644 plugins/inputs/redfish/testdata/hp_hostname.json create mode 100644 plugins/inputs/redfish/testdata/hp_hostnameinvalid.json create mode 100644 plugins/inputs/redfish/testdata/hp_power.json create mode 100644 plugins/inputs/redfish/testdata/hp_powerinvalid.json create mode 100644 plugins/inputs/redfish/testdata/hp_thermal.json create mode 100644 plugins/inputs/redfish/testdata/hp_thermalinvalid.json diff --git a/plugins/inputs/all/all.go b/plugins/inputs/all/all.go index dec04b3970f47..0b10f5e9dc32a 100644 --- a/plugins/inputs/all/all.go +++ b/plugins/inputs/all/all.go @@ -131,6 +131,7 @@ import ( _ "github.com/influxdata/telegraf/plugins/inputs/puppetagent" _ "github.com/influxdata/telegraf/plugins/inputs/rabbitmq" _ "github.com/influxdata/telegraf/plugins/inputs/raindrops" + _ "github.com/influxdata/telegraf/plugins/inputs/redfish" _ "github.com/influxdata/telegraf/plugins/inputs/redis" _ "github.com/influxdata/telegraf/plugins/inputs/rethinkdb" _ "github.com/influxdata/telegraf/plugins/inputs/riak" diff --git a/plugins/inputs/redfish/README.md b/plugins/inputs/redfish/README.md new file mode 100644 index 0000000000000..4f6ce54546494 --- /dev/null +++ b/plugins/inputs/redfish/README.md @@ -0,0 +1,159 @@ +# Redfish Input Plugin + +The `redfish` plugin gathers metrics and status information about CPU temperature, Fanspeed, Powersupply, voltage, Hostname and Location details(datacenter,placement,rack and room) of Dell hardware servers for which redfish is enabled. +And also metrics like CPU temperature,Fanspeed, Powersupply and Hostname metrics for HP Hardware server(redfish should be enabled). + +Note: Currently this plugin only supports DELL and HP servers. + + + +### Configuration + +```toml +[[inputs.redfish]] +## Server OOB-IP +host = "https://192.0.0.1" + +## Username,Password for hardware server +basicauthusername = "test" +basicauthpassword = "test" +## Server Vendor(dell or hp) +server= "dell" +## Resource Id for redfish APIs +id="System.Embedded.1" + +## Amount of time allowed to complete the HTTP request +# timeout = "5s" +``` + +### Metrics for Dell Servers + +- cputemperatures + - tags: + - Hostname + - Name + - OOBIP + - host + - Fields: + - Datacenter + - Temperature + - Health + - Rack + - Room + - Row + - State + +- fans + - tags: + - Hostname + - Name + - OOBIP + - host + - Fields: + - Datacenter + - Fanspeed + - Health + - Rack + - Room + - Row + - State + +- Voltages + - tags: + - Hostname + - Name + - OOBIP + - host + - Fields: + - Datacenter + - Voltage + - Health + - Rack + - Room + - Row + - State + +- Powersupply + - tags: + - Hostname + - Name + - OOBIP + - host + - Fields: + - Datacenter + - Health + - PowerCapacityWatts + - PowerInputWatts + - PowerOutputWatts + - Rack + - Room + - Row + - State + +### Metrics for HP Servers + +- cputemperatures + - tags: + - Hostname + - Name + - OOBIP + - host + - Fields: + - Temperature + - Health + - State + +- fans + - tags: + - Hostname + - Name + - OOBIP + - host + - Fields: + - Fanspeed + - Health + - State +- Powersupply + - tags: + - Hostname + - Name + - OOBIP + - host + - MemberId + - Fields: + - PowerCapacityWatts + - LastPowerOutputWatts + - LineInputVoltage + +### Example Output For HP +``` +cputemperature,Hostname=tpa_hostname,Name=01-Inlet\ Ambient,OOBIP=https://127.0.0.1,host=tpa_po Health="OK",State="Enabled",Temperature="19" 1582612210000000000 +cputemperature,Hostname=tpa_hostname,Name=02-CPU\ 1,OOBIP=https://127.0.0.1,host=tpa_po Health="OK",State="Enabled",Temperature="40" 1582612210000000000 +fans,Hostname=tpa_hostname,Name=Fan\ 4,OOBIP=https://127.0.0.1,host=tpa_po Fanspeed="23",Health="OK",State="Enabled" 1582612210000000000 +fans,Hostname=tpa_hostname,Name=Fan\ 5,OOBIP=https://127.0.0.1,host=tpa_po Fanspeed="23",Health="OK",State="Enabled" 1582612210000000000 +fans,Hostname=tpa_hostname,Name=Fan\ 6,OOBIP=https://127.0.0.1,host=tpa_po Fanspeed="23",Health="OK",State="Enabled" 1582612210000000000 +fans,Hostname=tpa_hostname,Name=Fan\ 7,OOBIP=https://127.0.0.1,host=tpa_po Fanspeed="23",Health="OK",State="Enabled" 1582612210000000000 +powersupply,Hostname=tpa_hostname,MemberId=0,Name=HpeServerPowerSupply,OOBIP=https://127.0.0.1,host=tpa_po LastPowerOutputWatts="109",LineInputVoltage="206",PowerCapacityWatts="800" 1582612210000000000 +powersupply,Hostname=tpa_hostname,MemberId=1,Name=HpeServerPowerSupply,OOBIP=https://127.0.0.1,host=tpa_po LastPowerOutputWatts="98",LineInputVoltage="204",PowerCapacityWatts="800" 1582612210000000000 + +``` + +### Example Output For Dell +``` +cputemperature,Hostname=test-hostname,Name=CPU1\ Temp,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled",Temperature="41" 1582114112000000000 +cputemperature,Hostname=test-hostname,Name=CPU2\ Temp,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled",Temperature="51" 1582114112000000000 +cputemperature,Hostname=test-hostname,Name=System\ Board\ Inlet\ Temp,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled",Temperature="23" 1582114112000000000 +cputemperature,Hostname=test-hostname,Name=System\ Board\ Exhaust\ Temp,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled",Temperature="33" 1582114112000000000 +fans,Hostname=test-hostname,Name=System\ Board\ Fan1A,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Fanspeed="17760",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled" 1582114112000000000 +fans,Hostname=test-hostname,Name=System\ Board\ Fan1B,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Fanspeed="15360",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled" 1582114112000000000 +fans,Hostname=test-hostname,Name=System\ Board\ Fan2A,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Fanspeed="17880",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled" 1582114112000000000 +powersupply,Hostname=test-hostname,Name=PS1\ Status,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",PowerCapacityWatts="750",PowerInputWatts="900",PowerOutputWatts="208",Rack="12",Room="tbc",Row="3",State="Enabled" 1582114112000000000 +powersupply,Hostname=test-hostname,Name=PS2\ Status,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",PowerCapacityWatts="750",PowerInputWatts="900",PowerOutputWatts="194",Rack="12",Room="tbc",Row="3",State="Enabled" 1582114112000000000 +voltages,Hostname=test-hostname,Name=CPU1\ MEM345\ VDDQ\ PG,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled",Voltage="1" 1582114112000000000 +voltages,Hostname=test-hostname,Name=CPU1\ MEM345\ VPP\ PG,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled",Voltage="1" 1582114112000000000 +voltages,Hostname=test-hostname,Name=CPU1\ MEM345\ VTT\ PG,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled",Voltage="1" 1582114112000000000 +voltages,Hostname=test-hostname,Name=PS1\ Voltage\ 1,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled",Voltage="208" 1582114112000000000 +voltages,Hostname=test-hostname,Name=PS2\ Voltage\ 2,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled",Voltage="208" 1582114112000000000 +voltages,Hostname=test-hostname,Name=System\ Board\ 3.3V\ A\ PG,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled",Voltage="1" 1582114112000000000 + +``` diff --git a/plugins/inputs/redfish/redfish.go b/plugins/inputs/redfish/redfish.go new file mode 100644 index 0000000000000..2c7862b2b331b --- /dev/null +++ b/plugins/inputs/redfish/redfish.go @@ -0,0 +1,394 @@ +package redfish +import ( + "github.com/influxdata/telegraf" + "github.com/influxdata/telegraf/plugins/inputs" + "github.com/influxdata/telegraf/internal" + "github.com/influxdata/telegraf/plugins/parsers" + "fmt" + "net/http" + "io/ioutil" + "encoding/base64" + "crypto/tls" + "encoding/json" + "strconv" +) +type Redfish struct{ + Host string `toml:"host"` + BasicAuthUsername string `toml:"basicauthusername"` + BasicAuthPassword string `toml:"basicauthpassword"` + Id string `toml:"id"` + Server string `toml:"server"` + parser parsers.Parser `toml:"parser"` + Timeout internal.Duration `toml:"timeout"` +} +type Hostname struct { + Hostname string `json:"HostName"` +} +type Cpu struct { + Name string `json:"Name"` + Temperature int64 `json:"ReadingCelsius"` + Status CpuStatus `json:"Status"` +} +type Temperatures struct { + Temperatures []Cpu `json:"Temperatures"` +} +type CpuStatus struct { + State string `json:"State"` + Health string `json:"Health"` +} +type Fans struct { + Fans []speed `json:"Fans"` +} +type speed struct { + Name string `json:"Name"` + Speed int64 `json:"Reading"` + Status FansStatus `json:"Status"` +} +type FansStatus struct { + State string `json:"State"` + Health string `json:"Health"` +} +type PowerSupplies struct { + PowerSupplies []watt `json:"PowerSupplies"` +} +type PowerSupplieshp struct { + PowerSupplieshp []watthp `json:"PowerSupplies"` +} +type watt struct { + Name string `json:"Name"` + PowerInputWatts float64 `json:"PowerInputWatts"` + PowerCapacityWatts float64 `json:"PowerCapacityWatts"` + PowerOutputWatts float64 `json:"PowerOutputWatts"` + Status PowerStatus `json:"Status"` +} +type watthp struct{ + Name string `json:"Name"` + MemberId string `json:"MemberId"` + PowerCapacityWatts float64 `json:"PowerCapacityWatts"` + LastPowerOutputWatts float64 `json:"LastPowerOutputWatts"` + LineInputVoltage float64 `json:"LineInputVoltage"` +} +type PowerStatus struct { + State string `json:"State"` + Health string `json:"Health"` +} +type Voltages struct { + Voltages []volt `json:"Voltages"` +} +type volt struct{ + Name string `json:"Name"` + ReadingVolts int64 `json:"ReadingVolts"` + Status VoltStatus `json:"Status"` +} +type VoltStatus struct { + State string `json:"State"` + Health string `json:"Health"` +} +type Location struct{ + Location Address `json:"Location"` +} +type Address struct{ + PostalAddress PostalAddress `json:"PostalAddress"` + Placement Placement `json:"Placement"` +} +type PostalAddress struct{ + DataCenter string `json:"Building"` + Room string `json:"Room"` + } +type Placement struct{ + Rack string `json:"Rack"` + Row string `json:"Row"` +} + + +var h Hostname +var t Temperatures +var f Fans +var p PowerSupplies +var v Voltages +var php PowerSupplieshp +var l Location + +func basicAuth(username, password string) string { + auth := username + ":" + password + return base64.StdEncoding.EncodeToString([]byte(auth)) +} + +func getThermal(host,username,password,id string) (error){ + r := fmt.Sprint(host,"/redfish/v1/Chassis/",id,"/Thermal") + client := &http.Client{} + http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + req, err := http.NewRequest("GET", r, nil) + req.Header.Add("Authorization","Basic "+ basicAuth(username,password)) + req.Header.Set("Accept","application/json") + req.Header.Set("Content-Type", "application/json") + resp, err := client.Do(req) + if err != nil{ + return err + } + if resp.StatusCode == 200 { + body, _ := ioutil.ReadAll(resp.Body) + jsonErr := json.Unmarshal(body,&t) + if jsonErr != nil { + return fmt.Errorf("error parsing input: %v", jsonErr) + } + jsonErr = json.Unmarshal(body,&f) + if jsonErr != nil { + return fmt.Errorf("error parsing input: %v", jsonErr) + } + }else { + return fmt.Errorf("received status code %d (%s), expected 200", + resp.StatusCode, + http.StatusText(resp.StatusCode)) + } + return nil +} + +func getPower(host,username,password,id,server string)(error){ + r := fmt.Sprint(host,"/redfish/v1/Chassis/",id,"/Power") + client := &http.Client{} + http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + req, err := http.NewRequest("GET", r, nil) + req.Header.Add("Authorization","Basic "+ basicAuth(username,password)) + req.Header.Set("Accept","application/json") + req.Header.Set("Content-Type", "application/json") + resp, err := client.Do(req) + if err != nil{ + return err + } + if resp.StatusCode == 200 { + body, _ := ioutil.ReadAll(resp.Body) + if server == "dell"{ + jsonErr := json.Unmarshal(body,&p) + if jsonErr != nil { + return fmt.Errorf("error parsing input: %v", jsonErr) + } + jsonErr = json.Unmarshal(body,&v) + if jsonErr != nil { + return fmt.Errorf("error parsing input: %v", jsonErr) + } + } + if server == "hp"{ + jsonErr := json.Unmarshal(body,&php) + if jsonErr != nil { + return fmt.Errorf("error parsing input: %v", jsonErr) + } + } + return nil + }else { + return fmt.Errorf("received status code %d (%s), expected 200", + resp.StatusCode, + http.StatusText(resp.StatusCode)) + } +} + +func getHostname(host,username,password,id string) (error){ + url := fmt.Sprint(host,"/redfish/v1/Systems/",id) + client := &http.Client{} + http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + req, err := http.NewRequest("GET", url, nil) + req.Header.Add("Authorization","Basic "+ basicAuth(username,password)) + req.Header.Set("Accept","*/*") + req.Header.Set("Content-Type", "application/json") + resp, err := client.Do(req) + if err != nil{ + return err + } + if resp.StatusCode == 200 { + body, _ := ioutil.ReadAll(resp.Body) + jsonErr := json.Unmarshal(body,&h) + if jsonErr != nil { + return fmt.Errorf("error parsing input: %v", jsonErr) + } + } else { + return fmt.Errorf("received status code %d (%s), expected 200", + resp.StatusCode, + http.StatusText(resp.StatusCode)) + } + return nil +} + +func getLocation(host,Username,password,id string)(error){ + r := fmt.Sprint(host,"/redfish/v1/Chassis/",id,"/") + client := &http.Client{} + http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + req, err := http.NewRequest("GET", r, nil) + req.Header.Add("Authorization","Basic "+ basicAuth(Username,password)) + req.Header.Set("Accept","application/json") + req.Header.Set("Content-Type", "application/json") + resp, err := client.Do(req) + if err != nil{ + return err + } + if resp.StatusCode == 200 { + body, _ := ioutil.ReadAll(resp.Body) + jsonErr := json.Unmarshal(body,&l) + if jsonErr != nil { + return fmt.Errorf("error parsing input: %v", jsonErr) + } + } else { + return fmt.Errorf("received status code %d (%s), expected 200", + resp.StatusCode, + http.StatusText(resp.StatusCode)) + } + + return nil +} + + + +func (r *Redfish) Description() string { + return "Read CPU, Fans, Powersupply and Voltage metrics of Dell/HP hardware server through redfish APIs" +} + +var redfishConfig =` +## Server OOB-IP +host = "https://192.0.0.1" + +## Username,Password for hardware server +basicauthusername = "test" +basicauthpassword = "test" +## Server Vendor(dell or hp) +server= "dell" +## Resource Id for redfish APIs +id="System.Embedded.1" + +## Amount of time allowed to complete the HTTP request +# timeout = "5s" +` +func (r *Redfish) SampleConfig() string { + return redfishConfig +} + + +func (r *Redfish) SetParser(parser parsers.Parser) { + r.parser = parser +} + + +func (r *Redfish) Init() error { + return nil +} + +func (r *Redfish) Gather(acc telegraf.Accumulator) error { + + if len(r.Host) > 0 && len(r.BasicAuthUsername) > 0 && len(r.BasicAuthPassword) > 0 && len(r.Server) > 0 && len(r.Id) > 0 && (r.Server == "dell" || r.Server == "hp"){ + err := getThermal(r.Host,r.BasicAuthUsername,r.BasicAuthPassword,r.Id) + if err != nil { + return err + } + err = getHostname(r.Host,r.BasicAuthUsername,r.BasicAuthPassword,r.Id) + if err != nil { + return err + } + + err = getPower(r.Host,r.BasicAuthUsername,r.BasicAuthPassword,r.Id,r.Server) + if err != nil { + return err + } + + + if r.Server == "dell" { + err = getLocation(r.Host,r.BasicAuthUsername,r.BasicAuthPassword,r.Id) + if err != nil { + return err + } + + } + + for i := 0; i < len(t.Temperatures); i++ { + // Tags +// tags := map[string]string{"Name": t.Temperatures[i].Name} + tags := map[string]string{"OOBIP": r.Host,"Name": t.Temperatures[i].Name,"Hostname": h.Hostname,} + // Fields + fields := make(map[string]interface{}) + fields["Temperature"] = strconv.FormatInt(t.Temperatures[i].Temperature,10) + fields["State"] = t.Temperatures[i].Status.State + fields["Health"] = t.Temperatures[i].Status.Health + if r.Server == "dell"{ + fields["Datacenter"] = l.Location.PostalAddress.DataCenter + fields["Room"] = l.Location.PostalAddress.Room + fields["Rack"] = l.Location.Placement.Rack + fields["Row"] = l.Location.Placement.Row + acc.AddFields("cputemperature", fields, tags) + } + if r.Server == "hp"{ + acc.AddFields("cputemperature", fields, tags) + } + } + for i := 0; i < len(f.Fans); i++ { + // Tags + tags := map[string]string{"OOBIP": r.Host,"Name": f.Fans[i].Name,"Hostname": h.Hostname} + // Fields + fields := make(map[string]interface{}) + fields["Fanspeed"] = strconv.FormatInt(f.Fans[i].Speed,10) + fields["State"] = f.Fans[i].Status.State + fields["Health"] = f.Fans[i].Status.Health + if r.Server == "dell" { + fields["Datacenter"] = l.Location.PostalAddress.DataCenter + fields["Room"] = l.Location.PostalAddress.Room + fields["Rack"] = l.Location.Placement.Rack + fields["Row"] = l.Location.Placement.Row + acc.AddFields("fans", fields, tags) + } + if r.Server == "hp" { + acc.AddFields("fans", fields, tags) + } + } + if r.Server == "dell" { + for i := 0; i < len(p.PowerSupplies); i++ { + // Tags + tags := map[string]string{"OOBIP": r.Host,"Name": p.PowerSupplies[i].Name,"Hostname": h.Hostname} + // Fields + fields := make(map[string]interface{}) + fields["PowerInputWatts"] = strconv.FormatFloat(p.PowerSupplies[i].PowerInputWatts,'f',-1,64) + fields["PowerCapacityWatts"] = strconv.FormatFloat(p.PowerSupplies[i].PowerCapacityWatts,'f',-1,64) + fields["PowerOutputWatts"] = strconv.FormatFloat(p.PowerSupplies[i].PowerOutputWatts,'f',-1,64) + fields["State"] = p.PowerSupplies[i].Status.State + fields["Health"] = p.PowerSupplies[i].Status.Health + fields["Datacenter"] = l.Location.PostalAddress.DataCenter + fields["Room"] = l.Location.PostalAddress.Room + fields["Rack"] = l.Location.Placement.Rack + fields["Row"] = l.Location.Placement.Row + acc.AddFields("powersupply", fields, tags) + } + } + if r.Server == "hp" { + for i := 0; i < len(php.PowerSupplieshp); i++ { + // Tags + tags := map[string]string{"OOBIP": r.Host,"Name": php.PowerSupplieshp[i].Name,"MemberId" : php.PowerSupplieshp[i].MemberId,"Hostname": h.Hostname} + // Fields + fields := make(map[string]interface{}) + fields["LineInputVoltage"] = strconv.FormatFloat(php.PowerSupplieshp[i].LineInputVoltage,'f',-1,64) + fields["PowerCapacityWatts"] = strconv.FormatFloat(php.PowerSupplieshp[i].PowerCapacityWatts,'f',-1,64) + fields["LastPowerOutputWatts"] = strconv.FormatFloat(php.PowerSupplieshp[i].LastPowerOutputWatts,'f',-1,64) + acc.AddFields("powersupply", fields, tags) + } + } + + if r.Server == "dell" { + for i := 0; i < len(v.Voltages); i++ { + // Tags + tags := map[string]string{"OOBIP": r.Host,"Name": v.Voltages[i].Name,"Hostname": h.Hostname} + // Fields + fields := make(map[string]interface{}) + fields["Voltage"] = strconv.FormatInt(v.Voltages[i].ReadingVolts,10) + fields["State"] = v.Voltages[i].Status.State + fields["Health"] = v.Voltages[i].Status.Health + fields["Datacenter"] = l.Location.PostalAddress.DataCenter + fields["Room"] = l.Location.PostalAddress.Room + fields["Rack"] = l.Location.Placement.Rack + fields["Row"] = l.Location.Placement.Row + acc.AddFields("voltages", fields, tags) + } + } + return nil + }else { + return fmt.Errorf("Did not provide all the mandatory fields in the configuration") + } + +} + +func init() { + inputs.Add("redfish", func() telegraf.Input { return &Redfish{} }) +} diff --git a/plugins/inputs/redfish/redfish_test.go b/plugins/inputs/redfish/redfish_test.go new file mode 100644 index 0000000000000..7fba0111885a1 --- /dev/null +++ b/plugins/inputs/redfish/redfish_test.go @@ -0,0 +1,849 @@ +package redfish + +import ( + "net/http" + "net/http/httptest" + "testing" + "time" + + "github.com/influxdata/telegraf" + "github.com/influxdata/telegraf/testutil" + "github.com/stretchr/testify/assert" +) + +func TestThermal(t *testing.T) { + + ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + + if !checkAuth(r, "test", "test") { + http.Error(w, "Unauthorized.", 401) + return + } + + + switch r.URL.Path { + case "/redfish/v1/Chassis/System.Embedded.1/Thermal": + http.ServeFile(w, r, "testdata/dell_thermal.json") + case "/redfish/v1/Chassis/System.Embedded.1/Power": + http.ServeFile(w, r, "testdata/dell_power.json") + case "/redfish/v1/Chassis/System.Embedded.1/": + http.ServeFile(w, r, "testdata/dell_location.json") + case "/redfish/v1/Systems/System.Embedded.1": + http.ServeFile(w, r, "testdata/dell_hostname.json") + case "/redfish/v1/Chassis/System.Embedded.2/Thermal": + http.ServeFile(w, r, "testdata/hp_thermal.json") + case "/redfish/v1/Chassis/System.Embedded.2/Power": + http.ServeFile(w, r, "testdata/hp_power.json") + case "/redfish/v1/Systems/System.Embedded.2": + http.ServeFile(w, r, "testdata/hp_hostname.json") + default: + panic("Cannot handle request") + } + })) + + defer ts.Close() + + expected_metrics_hp := []telegraf.Metric{ + testutil.MustMetric( + "cputemperature", + map[string]string{ + "Name": "01-Inlet Ambient", + "Hostname": "tpa-hostname", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Health": "OK", + "State": "Enabled", + "Temperature": "19", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "cputemperature", + map[string]string{ + "Name": "44-P/S 2 Zone", + "Hostname": "tpa-hostname", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Health": "OK", + "State": "Enabled", + "Temperature": "34", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "Fan 1", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Fanspeed": "23", + "Health": "OK", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "Fan 2", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Fanspeed": "23", + "Health": "OK", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "Fan 3", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Fanspeed": "23", + "Health": "OK", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "powersupply", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "HpeServerPowerSupply", + "MemberId": "0", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "PowerCapacityWatts" :"800", + "LineInputVoltage": "205", + "LastPowerOutputWatts": "0", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "powersupply", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "HpeServerPowerSupply", + "MemberId": "1", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "PowerCapacityWatts" :"800", + "LineInputVoltage": "205", + "LastPowerOutputWatts": "90", + }, + time.Unix(0, 0), + ), + } + + expected_metrics := []telegraf.Metric{ + testutil.MustMetric( + "cputemperature", + map[string]string{ + "Name": "CPU1 Temp", + "Hostname": "tpa-hostname", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + "Temperature": "40", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan1A", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "17760", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan1B", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "15360", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan2A", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "17880", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan2B", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "15120", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan3A", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "18000", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan3B", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "15600", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan4A", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "17280", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan4B", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "15360", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan5A", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "17640", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan5B", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "15600", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan6A", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "17760", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan6B", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "15600", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan7A", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "17400", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan7B", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "15720", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan8A", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "18000", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan8B", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "15840", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "powersupply", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "PS1 Status", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + "PowerCapacityWatts" :"750", + "PowerInputWatts": "900", + "PowerOutputWatts": "203", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "voltages", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board DIMM PG", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + "Voltage" :"1", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "voltages", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board NDC PG", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + "Voltage" :"1", + }, + time.Unix(0, 0), + ), + + testutil.MustMetric( + "voltages", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board PS1 PG FAIL", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + "Voltage" :"1", + }, + time.Unix(0, 0), + ), + } + plugin := &Redfish{ + Host: ts.URL, + BasicAuthUsername: "test", + BasicAuthPassword: "test", + Id: "System.Embedded.1", + Server: "dell", + } + plugin.Init() + var acc testutil.Accumulator + + _ = plugin.Gather(&acc) + assert.True(t, acc.HasMeasurement("cputemperature")) + testutil.RequireMetricsEqual(t, expected_metrics, acc.GetTelegrafMetrics(), + testutil.IgnoreTime()) + + + hp_plugin := &Redfish{ + Host: ts.URL, + BasicAuthUsername: "test", + BasicAuthPassword: "test", + Id: "System.Embedded.2", + Server: "hp", + } + hp_plugin.Init() + var hp_acc testutil.Accumulator + + _ = hp_plugin.Gather(&hp_acc) + assert.True(t, hp_acc.HasMeasurement("cputemperature")) + testutil.RequireMetricsEqual(t, expected_metrics_hp, hp_acc.GetTelegrafMetrics(), + testutil.IgnoreTime()) +} + + +func checkAuth(r *http.Request, username, password string) bool { + user, pass, ok := r.BasicAuth() + if !ok { + return false + } + return user == username && pass == password +} + +func TestConnection(t *testing.T) { + + r := &Redfish{ + Host: "https://127.0.0.1", + BasicAuthUsername: "test", + BasicAuthPassword: "test", + Id: "System.Embedded.1", + Server: "dell", + + } + + var acc testutil.Accumulator + + r.Init() + + err := r.Gather(&acc) + + if assert.Error(t, err) { + assert.Contains(t, err.Error(), "connect: connection refused") + } +} + + +func TestInvalidUsernameorPassword(t *testing.T) { + + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + + if !checkAuth(r, "testing", "testing") { + http.Error(w, "Unauthorized.", 401) + return + } + + switch r.URL.Path { + case "/redfish/v1/Chassis/System.Embedded.1/Thermal": + http.ServeFile(w, r, "testdata/dell_thermal.json") + default: + panic("Cannot handle request") + } + })) + + defer ts.Close() + + r := &Redfish{ + Host: ts.URL, + BasicAuthUsername: "test", + BasicAuthPassword: "test", + Id: "System.Embedded.1", + Server: "dell", + + } + + var acc testutil.Accumulator + r.Init() + err := r.Gather(&acc) + assert.EqualError(t, err, "received status code 401 (Unauthorized), expected 200") +} +func TestNoUsernameorPasswordConfiguration(t *testing.T) { + + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + + if !checkAuth(r, "testing", "testing") { + http.Error(w, "Unauthorized.", 401) + return + } + + switch r.URL.Path { + case "/redfish/v1/Chassis/System.Embedded.1/Thermal": + http.ServeFile(w, r, "testdata/dell_thermal.json") + default: + panic("Cannot handle request") + } + })) + + defer ts.Close() + + r := &Redfish{ + Host: ts.URL, + Id: "System.Embedded.1", + Server: "dell", + + } + + var acc testutil.Accumulator + r.Init() + err := r.Gather(&acc) + assert.EqualError(t, err, "Did not provide all the mandatory fields in the configuration") +} + +func TestInvalidServerVarConfiguration(t *testing.T) { + + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + + if !checkAuth(r, "test", "test") { + http.Error(w, "Unauthorized.", 401) + return + } + + switch r.URL.Path { + case "/redfish/v1/Chassis/System.Embedded.1/Thermal": + http.ServeFile(w, r, "testdata/dell_thermal.json") + default: + panic("Cannot handle request") + } + })) + + defer ts.Close() + + r := &Redfish{ + Host: ts.URL, + BasicAuthUsername: "test", + BasicAuthPassword: "test", + Id: "System.Embedded.1", + Server: "wtu", + + } + + var acc testutil.Accumulator + r.Init() + err := r.Gather(&acc) + assert.EqualError(t, err, "Did not provide all the mandatory fields in the configuration") +} + + +func TestInvalidDellJSON(t *testing.T) { + + tests := []struct { + name string + thermalfilename string + powerfilename string + locationfilename string + hostnamefilename string + }{ + { + name: "check Thermal", + thermalfilename: "testdata/dell_thermalinvalid.json", + powerfilename: "testdata/dell_power.json", + locationfilename: "testdata/dell_location.json", + hostnamefilename: "testdata/dell_hostname.json", + }, + { + name: "check Power", + thermalfilename: "testdata/dell_thermal.json", + powerfilename: "testdata/dell_powerinvalid.json", + locationfilename: "testdata/dell_location.json", + hostnamefilename: "testdata/dell_hostname.json", + }, + { + name: "check Location", + thermalfilename: "testdata/dell_thermal.json", + powerfilename: "testdata/dell_power.json", + locationfilename: "testdata/dell_locationinvalid.json", + hostnamefilename: "testdata/dell_hostname.json", + }, + { + name: "check Hostname", + thermalfilename: "testdata/dell_thermal.json", + powerfilename: "testdata/dell_power.json", + locationfilename: "testdata/dell_location.json", + hostnamefilename: "testdata/dell_hostnameinvalid.json", + }, + } + for _, tt := range tests { + ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + + + if !checkAuth(r, "test", "test") { + http.Error(w, "Unauthorized.", 401) + return + } + + + + switch r.URL.Path { + case "/redfish/v1/Chassis/System.Embedded.1/Thermal": + http.ServeFile(w, r, tt.thermalfilename) + case "/redfish/v1/Chassis/System.Embedded.1/Power": + http.ServeFile(w, r, tt.powerfilename) + case "/redfish/v1/Chassis/System.Embedded.1/": + http.ServeFile(w, r, tt.locationfilename) + case "/redfish/v1/Systems/System.Embedded.1": + http.ServeFile(w, r, tt.hostnamefilename) + default: + panic("Cannot handle request") + } + })) + + defer ts.Close() + + plugin := &Redfish{ + Host: ts.URL, + BasicAuthUsername: "test", + BasicAuthPassword: "test", + Id: "System.Embedded.1", + Server: "dell", + } + + plugin.Init() + + var acc testutil.Accumulator + err := plugin.Gather(&acc) + + if assert.Error(t, err) { + assert.Contains(t, err.Error(), "error parsing input:") + } + } +} + + +func TestInvalidHPJSON(t *testing.T) { + + tests := []struct { + name string + thermalfilename string + powerfilename string + hostnamefilename string + }{ + { + name: "check Thermal", + thermalfilename: "testdata/hp_thermalinvalid.json", + powerfilename: "testdata/hp_power.json", + hostnamefilename: "testdata/hp_hostname.json", + }, + { + name: "check Power", + thermalfilename: "testdata/hp_thermal.json", + powerfilename: "testdata/hp_powerinvalid.json", + hostnamefilename: "testdata/hp_hostname.json", + }, + { + name: "check Hostname", + thermalfilename: "testdata/hp_thermal.json", + powerfilename: "testdata/hp_power.json", + hostnamefilename: "testdata/hp_hostnameinvalid.json", + }, + } + for _, tt := range tests { + ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + + + if !checkAuth(r, "test", "test" ) { + http.Error(w, "Unauthorized.", 401) + return + } + + + switch r.URL.Path { + case "/redfish/v1/Chassis/System.Embedded.2/Thermal": + http.ServeFile(w, r, tt.thermalfilename) + case "/redfish/v1/Chassis/System.Embedded.2/Power": + http.ServeFile(w, r, tt.powerfilename) + case "/redfish/v1/Systems/System.Embedded.2": + http.ServeFile(w, r, tt.hostnamefilename) + default: + panic("Cannot handle request") + } + })) + + defer ts.Close() + + plugin := &Redfish{ + Host: ts.URL, + BasicAuthUsername: "test", + BasicAuthPassword: "test", + Id: "System.Embedded.2", + Server: "hp", + } + + plugin.Init() + + var acc testutil.Accumulator + err := plugin.Gather(&acc) + + if assert.Error(t, err) { + assert.Contains(t, err.Error(), "error parsing input:") + } + } +} diff --git a/plugins/inputs/redfish/testdata/.dell_power.json.swp b/plugins/inputs/redfish/testdata/.dell_power.json.swp new file mode 100644 index 0000000000000000000000000000000000000000..39e0df1656f6c06c5f43d3c90122fc642ed761d1 GIT binary patch literal 24576 zcmeI4dyHIF8NhFOLn#`>7*TY%TM$UudF*!Em8dMc+wN+2JMQ!msHM4`xx0JI-I-

gzmEty|JZaYFO53+(n@jKY6sD&t=~}gzo-(ZI`u6T(WhU*$)hsP->83ta z)h5%kW_`*i*9e=fTeWmmFHIV?X~Jt(NeGs7(?z8P zT%Y9rHr($ek?&L8->Un)BNBd!`+LCs{&gh$WcRoCeWx42OUJvv(v^#bzjf64yj#QF zVkcjT1riG+7Dz0RSRk=LVu8d0i3Ji1Bo;_4kXYb^SU@W|bN|Q0M4UZ;Z~p(E_bJK~ za0_gMVd#YmVHunbPoJYGyI}+_1_cf-Qeuo{-b>t`y;OYnWT33M2TA@~HG z48K1E{csoD2z4-F1eU|8aPV|Rc@*|T875#5vT!aucpA2Wqb!j87Jd$2g}rc;HIBn@ z5T1j_U_V?5PqN@K2W#MbI0sIFw^@jJ6@ChL!WUsH41)?wVF}pvWqU+Qe$*=~;#@?x zQBpsdQssGxo!Ru@v{tJbwRB;=X6ZBC!!z6UQb{j$XH~_Ez1zJ~Cv;P@^wKDTsM+G* zF4fB=tz4XUQz=&JWebVSibfF;ajU$a7e_P-_1Rf-e#88%E;2VTsD^{r*DVftY}PER zMtCmM6Am5~M?k#L{*0fdt$R?L)ry8S?+L7084%E_)_9!)S4Fy+{Ab68#s@N4nfx9v zp;T&*TaXl=;B_jcPH5#RJv*k&*%`4D^%5gDfq2Lc>6T`gdZ}PxN0Dg0s@L>#QBM(~ z7qP8OT%<${*P@ndoUS1bwgil}$oU{)-=$G2Uu9K}l6(&vP4gq(2s42BU7+O&L4QVOZZtPMsX19acJ6F-^S4sFW$b*F4?4uQSTmiS`rLqmI@Jy9}#1ZIq{+ zW{8MYt?SLJFU}2PTrgBizB9+zFSaM@#QhfE^`h-5RG6sCg$!#42JWcq?f%lUygIJU zIE}xMO^KeMUX!}ju}VodiL2%}PoxU@byu&T$J)GNVrYEBih+p@!-cEI?b`S1M;+5e z2R3T=>rI-UI;NHDlUmWLSDkK7v=u)&yh6A8txXlv(x!C36VCN!HpR=4!(66MW@4RI zv+O=1+*g$jY$;8t!-P38D(RpKI0aF@P66H z2gBD?_3P_&w(}!5Ak(|bOVyFl=E6F1eZ9>D!bG*?Qx)1!|Tj>?-4M!*PFeO zB>40c5zmo^_{8~ttYKn@9Is}4&x?$KUiCEg#j(}is54lkpf}s*nh>pxXUdZIG_)!s zTU5~hXuTM*#^5L=dvhxl+aUa*1Dk6I?~z>(0;AMvb*E;ImQh7EWOqW?z)rnNpV6Qo zClxr=IHp?+&B5_8n8kI*jA4zIy@K@guJ*HMhYima^;vh^RY$aH$+p1y$w}$lJG*JjUl~OtQyiiZ0(L{tVv`S8IoJD9YV1eSnS=3nEyY( zT>c=4`9D)o`|~!x-*E50%=ZuB%b>#-U;r+K55YUk`(J_Q;Yqj!_P`{J!9^g}2L8bO z|33H%Ou`_Db%DPz-xuou18@cO!rAZ_=Jk)m&tN~?0%9Ft3#@`}SPsuH-+vtLgResk zHbFm}34dj-|2RAb$tSTuVu8d0i3Ji1Bo;_4@Gh``n0u=3x=3`@rDqj^-W;{1V9UUu z7I#+EQvTQjNhvmROn`seznaopTEZ=Zx^Z?^uWp!TeSW%Pmc}dP!Kz^yMNKTuiFGYU z&Q~k1Sr=?)az$Q)9HFe8qEdxEB9SKplv2rm1{%!v% zzC8)=5pv=a@*=b3N0(RfqD8BSmuU=Xyz@WbLR)%MuVN1jV*YAwk8SPvJ&8So7A`}^T$*a~8=|8nSpL+s_h z3NOF`xC8dV4puM?f?_k!e#Ie?DaAnfZL!1eeeW({a{>Z-nv+xky1ACzk*TD)uByqu(PmuRfT0!d%;TN zP%f;AKrhRkCEB61E7nG*kZL2MPP9p}vy@m%kF|G94mwucCWBiPM?j60iwTI{?!Z>@ zg%rxXf^rqr9kbV9i+Ry}na0?Scbvm4arZgoB7@|G;#~RZgbu>EVvV_JkZL0$E5b|I z{%#kkg#-DPjmbKimqE3E?VnyH{tBT zGR1kJRDNx0&A{k7-&pK{x~bV`EwE*_$G1=Lv`F*>QdeLgMsvgZg9!KNM+))nJX-UfE#eqs;%iQZWdne4)AH|;oCE$ywJG&{1@+GNrN<+D!k ztZ)mw1$)>&9w1kWuTcx%#}1zG5GOB z5E)YG*~R>SGjr;b?|-~#v_bN?Z@5YB_s;0Sa5L!d(e zR9Fg!nCssKm%t0m>wg4y!`Gk=L$Dl9gV&kQKMLai8SH{GlwcSxf+g@K^ZJKiKYRoB z!glx+i1z|cg-4m|-wX5bG58(x{ny|XZ{F|LoBXmXT>c5p2xMyr9AguLG0#l6&57v1 zovbZTHIc$Gj!8?y6QR^1FXSr_9T+Q|Bl`^u@7)ObJQ~TiClr&Of7`$E-pL4LsAZry z8!D4;k;TPR5}SyhguId$Z4Di(wUgp?o{W%;ORB9FTOclWupRZLn)Oqnvu=+Od#f59Kq3jDN*fEuZNWqGWPd}*L zzm`|>BCf+dPJ!c$9@}lT)f?-6eoX(W$sigUCu96mC=j(E70HV@Yj!g7N*PamyWE9c zAubPb_c>4C1v%f|FaLedc<)lYD4jRkHtnk2BIt=(O&b~=8*4K?_s`9Dx{fB4ww|5) zI>XCejcYt|F(@qfE?Pp1T1z_JF|D7;BP~2;ZNW=vrmfyn4g`w`c6)c;u<%}amDzD- zM>$a;Znxn1zV}UPi?Pf-%WGfxHg732bFUhjDHp@l{K&vWK9gD1zc!QU?e~|P7CKe? EFF3`)=>Px# literal 0 HcmV?d00001 diff --git a/plugins/inputs/redfish/testdata/dell_hostname.json b/plugins/inputs/redfish/testdata/dell_hostname.json new file mode 100644 index 0000000000000..40de02595acc2 --- /dev/null +++ b/plugins/inputs/redfish/testdata/dell_hostname.json @@ -0,0 +1,329 @@ +{ + "@odata.context": "/redfish/v1/$metadata#ComputerSystem.ComputerSystem", + "@odata.id": "/redfish/v1/Systems/System.Embedded.1", + "@odata.type": "#ComputerSystem.v1_5_0.ComputerSystem", + "Actions": { + "#ComputerSystem.Reset": { + "ResetType@Redfish.AllowableValues": [ + "On", + "ForceOff", + "ForceRestart", + "GracefulShutdown", + "PushPowerButton", + "Nmi" + ], + "target": "/redfish/v1/Systems/System.Embedded.1/Actions/ComputerSystem.Reset" + } + }, + "AssetTag": "", + "Bios": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Bios" + }, + "BiosVersion": "2.3.10", + "Boot": { + "BootOptions": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootOptions" + }, + "BootOrder": [ + "Boot0002", + "Boot0003", + "Boot0005", + "Boot0004" + ], + "BootOrder@odata.count": 4, + "BootSourceOverrideEnabled": "Once", + "BootSourceOverrideMode": "UEFI", + "BootSourceOverrideTarget": "None", + "BootSourceOverrideTarget@Redfish.AllowableValues": [ + "None", + "Pxe", + "Floppy", + "Cd", + "Hdd", + "BiosSetup", + "Utilities", + "UefiTarget", + "SDCard", + "UefiHttp" + ], + "UefiTargetBootSourceOverride": "" + }, + "Description": "Computer System which represents a machine (physical or virtual) and the local resources such as memory, cpu and other devices that can be accessed from that machine.", + "EthernetInterfaces": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/EthernetInterfaces" + }, + "HostName": "tpa-hostname", + "HostWatchdogTimer": { + "FunctionEnabled": true, + "Status": { + "State": "Enabled" + }, + "TimeoutAction": "None" + }, + "HostingRoles": [], + "HostingRoles@odata.count": 0, + "Id": "System.Embedded.1", + "IndicatorLED": "Off", + "Links": { + "Chassis": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "Chassis@odata.count": 1, + "CooledBy": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.1A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.1B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.2A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.2B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.3A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.3B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.4A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.4B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.5A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.5B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.6A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.6B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.7A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.7B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.8A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.8B" + } + ], + "CooledBy@odata.count": 16, + "ManagedBy": [ + { + "@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1" + } + ], + "ManagedBy@odata.count": 1, + "Oem": { + "Dell": { + "BootOrder": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootSources" + }, + "DellNumericSensorCollection": { + "@odata.id": "/redfish/v1/Dell/Systems/System.Embedded.1/DellNumericSensorCollection" + }, + "DellOSDeploymentService": { + "@odata.id": "/redfish/v1/Dell/Systems/System.Embedded.1/DellOSDeploymentService" + }, + "DellPresenceAndStatusSensorCollection": { + "@odata.id": "/redfish/v1/Dell/Systems/System.Embedded.1/DellPresenceAndStatusSensorCollection" + }, + "DellRaidService": { + "@odata.id": "/redfish/v1/Dell/Systems/System.Embedded.1/DellRaidService" + }, + "DellSensorCollection": { + "@odata.id": "/redfish/v1/Dell/Systems/System.Embedded.1/DellSensorCollection" + }, + "DellSoftwareInstallationService": { + "@odata.id": "/redfish/v1/Dell/Systems/System.Embedded.1/DellSoftwareInstallationService" + } + } + }, + "PoweredBy": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power/PowerSupplies/PSU.Slot.1" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power/PowerSupplies/PSU.Slot.2" + } + ], + "PoweredBy@odata.count": 2 + }, + "Manufacturer": "Dell Inc.", + "Memory": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Memory" + }, + "MemorySummary": { + "MemoryMirroring": "System", + "Status": { + "Health": "OK", + "HealthRollup": "OK", + "State": "Enabled" + }, + "TotalSystemMemoryGiB": 476.837376 + }, + "Model": "PowerEdge R640", + "Name": "System", + "NetworkInterfaces": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/NetworkInterfaces" + }, + "Oem": { + "Dell": { + "DellSystem": { + "@odata.context": "/redfish/v1/$metadata#DellSystem.DellSystem", + "@odata.id": "/redfish/v1/Dell/Systems/System.Embedded.1/DellSystem/System.Embedded.1", + "@odata.type": "#DellSystem.v1_0_0.DellSystem", + "BIOSReleaseDate": "08/15/2019", + "BaseBoardChassisSlot": "NA", + "BatteryRollupStatus": "OK", + "BladeGeometry": "NotApplicable", + "CMCIP": null, + "CPURollupStatus": "OK", + "ChassisServiceTag": "CLFV7M2", + "ExpressServiceCode": "27417828170", + "FanRollupStatus": "OK", + "IntrusionRollupStatus": "OK", + "LicensingRollupStatus": "OK", + "MaxDIMMSlots": 24, + "MaxPCIeSlots": 3, + "NodeID": "CLFV7M2", + "PSRollupStatus": "OK", + "PowerCapEnabledState": "Disabled", + "StorageRollupStatus": "OK", + "SysMemPrimaryStatus": "OK", + "SystemGeneration": "14G Monolithic", + "SystemID": 1814, + "TempRollupStatus": "OK", + "UUID": "4c4c4544-004c-4610-8056-c3c04f374d32", + "VoltRollupStatus": "OK" + } + } + }, + "PCIeDevices": [ + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/216-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-31" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-17" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/3-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-28" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-23" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/25-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/24-0" + } + ], + "PCIeDevices@odata.count": 9, + "PCIeFunctions": [ + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/216-0-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/216-0-1" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-31-4" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-17-5" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-31-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/3-0-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-28-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-0-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-23-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-28-4" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/25-0-1" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/25-0-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/24-0-0" + } + ], + "PCIeFunctions@odata.count": 13, + "PartNumber": "0CRT1GA05", + "PowerState": "On", + "ProcessorSummary": { + "Count": 2, + "LogicalProcessorCount": 80, + "Model": "Intel(R) Xeon(R) Gold 6138 CPU @ 2.00GHz", + "Status": { + "Health": "OK", + "HealthRollup": "OK", + "State": "Enabled" + } + }, + "Processors": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Processors" + }, + "SKU": "CLFV7M2", + "SecureBoot": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/SecureBoot" + }, + "SerialNumber": "CNIVC007CV0803", + "SimpleStorage": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/SimpleStorage/Controllers" + }, + "Status": { + "Health": "OK", + "HealthRollup": "OK", + "State": "Enabled" + }, + "Storage": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage" + }, + "SystemType": "Physical", + "TrustedModules": [ + { + "FirmwareVersion": "Unknown", + "Status": { + "State": "Disabled" + } + } + ], + "UUID": "4c4c4544-004c-4610-8056-c3c04f374d32" +} diff --git a/plugins/inputs/redfish/testdata/dell_hostnameinvalid.json b/plugins/inputs/redfish/testdata/dell_hostnameinvalid.json new file mode 100644 index 0000000000000..f3fdc0db8f7d8 --- /dev/null +++ b/plugins/inputs/redfish/testdata/dell_hostnameinvalid.json @@ -0,0 +1,329 @@ +{ + "@odata.context": "/redfish/v1/$metadata#ComputerSystem.ComputerSystem", + "@odata.id": "/redfish/v1/Systems/System.Embedded.1", + "@odata.type": "#ComputerSystem.v1_5_0.ComputerSystem", + "Actions": { + "#ComputerSystem.Reset": { + "ResetType@Redfish.AllowableValues": [ + "On", + "ForceOff", + "ForceRestart", + "GracefulShutdown", + "PushPowerButton", + "Nmi" + ], + "target": "/redfish/v1/Systems/System.Embedded.1/Actions/ComputerSystem.Reset" + } + }, + "AssetTag": "", + "Bios": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Bios" + }, + "BiosVersion": "2.3.10", + "Boot": { + "BootOptions": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootOptions" + }, + "BootOrder": [ + "Boot0002", + "Boot0003", + "Boot0005", + "Boot0004" + ], + "BootOrder@odata.count": 4, + "BootSourceOverrideEnabled": "Once", + "BootSourceOverrideMode": "UEFI", + "BootSourceOverrideTarget": "None", + "BootSourceOverrideTarget@Redfish.AllowableValues": [ + "None", + "Pxe", + "Floppy", + "Cd", + "Hdd", + "BiosSetup", + "Utilities", + "UefiTarget", + "SDCard", + "UefiHttp" + ], + "UefiTargetBootSourceOverride": "" + }, + "Description": "Computer System which represents a machine (physical or virtual) and the local resources such as memory, cpu and other devices that can be accessed from that machine.", + "EthernetInterfaces": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/EthernetInterfaces" + } + "HostName": "tpa-hostname", + "HostWatchdogTimer": { + "FunctionEnabled": true, + "Status": { + "State": "Enabled" + }, + "TimeoutAction": "None" + }, + "HostingRoles": [], + "HostingRoles@odata.count": 0, + "Id": "System.Embedded.1", + "IndicatorLED": "Off", + "Links": { + "Chassis": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "Chassis@odata.count": 1, + "CooledBy": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.1A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.1B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.2A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.2B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.3A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.3B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.4A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.4B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.5A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.5B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.6A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.6B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.7A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.7B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.8A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.8B" + } + ], + "CooledBy@odata.count": 16, + "ManagedBy": [ + { + "@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1" + } + ], + "ManagedBy@odata.count": 1, + "Oem": { + "Dell": { + "BootOrder": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootSources" + }, + "DellNumericSensorCollection": { + "@odata.id": "/redfish/v1/Dell/Systems/System.Embedded.1/DellNumericSensorCollection" + }, + "DellOSDeploymentService": { + "@odata.id": "/redfish/v1/Dell/Systems/System.Embedded.1/DellOSDeploymentService" + }, + "DellPresenceAndStatusSensorCollection": { + "@odata.id": "/redfish/v1/Dell/Systems/System.Embedded.1/DellPresenceAndStatusSensorCollection" + }, + "DellRaidService": { + "@odata.id": "/redfish/v1/Dell/Systems/System.Embedded.1/DellRaidService" + }, + "DellSensorCollection": { + "@odata.id": "/redfish/v1/Dell/Systems/System.Embedded.1/DellSensorCollection" + }, + "DellSoftwareInstallationService": { + "@odata.id": "/redfish/v1/Dell/Systems/System.Embedded.1/DellSoftwareInstallationService" + } + } + }, + "PoweredBy": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power/PowerSupplies/PSU.Slot.1" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power/PowerSupplies/PSU.Slot.2" + } + ], + "PoweredBy@odata.count": 2 + }, + "Manufacturer": "Dell Inc.", + "Memory": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Memory" + }, + "MemorySummary": { + "MemoryMirroring": "System", + "Status": { + "Health": "OK", + "HealthRollup": "OK", + "State": "Enabled" + }, + "TotalSystemMemoryGiB": 476.837376 + }, + "Model": "PowerEdge R640", + "Name": "System", + "NetworkInterfaces": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/NetworkInterfaces" + }, + "Oem": { + "Dell": { + "DellSystem": { + "@odata.context": "/redfish/v1/$metadata#DellSystem.DellSystem", + "@odata.id": "/redfish/v1/Dell/Systems/System.Embedded.1/DellSystem/System.Embedded.1", + "@odata.type": "#DellSystem.v1_0_0.DellSystem", + "BIOSReleaseDate": "08/15/2019", + "BaseBoardChassisSlot": "NA", + "BatteryRollupStatus": "OK", + "BladeGeometry": "NotApplicable", + "CMCIP": null, + "CPURollupStatus": "OK", + "ChassisServiceTag": "CLFV7M2", + "ExpressServiceCode": "27417828170", + "FanRollupStatus": "OK", + "IntrusionRollupStatus": "OK", + "LicensingRollupStatus": "OK", + "MaxDIMMSlots": 24, + "MaxPCIeSlots": 3, + "NodeID": "CLFV7M2", + "PSRollupStatus": "OK", + "PowerCapEnabledState": "Disabled", + "StorageRollupStatus": "OK", + "SysMemPrimaryStatus": "OK", + "SystemGeneration": "14G Monolithic", + "SystemID": 1814, + "TempRollupStatus": "OK", + "UUID": "4c4c4544-004c-4610-8056-c3c04f374d32", + "VoltRollupStatus": "OK" + } + } + }, + "PCIeDevices": [ + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/216-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-31" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-17" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/3-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-28" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-23" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/25-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/24-0" + } + ], + "PCIeDevices@odata.count": 9, + "PCIeFunctions": [ + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/216-0-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/216-0-1" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-31-4" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-17-5" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-31-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/3-0-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-28-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-0-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-23-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/0-28-4" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/25-0-1" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/25-0-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeFunction/24-0-0" + } + ], + "PCIeFunctions@odata.count": 13, + "PartNumber": "0CRT1GA05", + "PowerState": "On", + "ProcessorSummary": { + "Count": 2, + "LogicalProcessorCount": 80, + "Model": "Intel(R) Xeon(R) Gold 6138 CPU @ 2.00GHz", + "Status": { + "Health": "OK", + "HealthRollup": "OK", + "State": "Enabled" + } + }, + "Processors": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Processors" + }, + "SKU": "CLFV7M2", + "SecureBoot": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/SecureBoot" + }, + "SerialNumber": "CNIVC007CV0803", + "SimpleStorage": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/SimpleStorage/Controllers" + }, + "Status": { + "Health": "OK", + "HealthRollup": "OK", + "State": "Enabled" + }, + "Storage": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage" + }, + "SystemType": "Physical", + "TrustedModules": [ + { + "FirmwareVersion": "Unknown", + "Status": { + "State": "Disabled" + } + } + ], + "UUID": "4c4c4544-004c-4610-8056-c3c04f374d32" +} diff --git a/plugins/inputs/redfish/testdata/dell_location.json b/plugins/inputs/redfish/testdata/dell_location.json new file mode 100644 index 0000000000000..48d0db49d60ce --- /dev/null +++ b/plugins/inputs/redfish/testdata/dell_location.json @@ -0,0 +1,187 @@ +{ + "@odata.context": "/redfish/v1/$metadata#Chassis.Chassis", + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1", + "@odata.type": "#Chassis.v1_6_0.Chassis", + "Actions": { + "#Chassis.Reset": { + "ResetType@Redfish.AllowableValues": [ + "On", + "ForceOff" + ], + "target": "/redfish/v1/Chassis/System.Embedded.1/Actions/Chassis.Reset" + } + }, + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "AssetTag": null, + "ChassisType": "RackMount", + "Description": "It represents the properties for physical components for any system.It represent racks, rackmount servers, blades, standalone, modular systems,enclosures, and all other containers.The non-cpu/device centric parts of the schema are all accessed either directly or indirectly through this resource.", + "Id": "System.Embedded.1", + "IndicatorLED": "Off", + "Links": { + "ComputerSystems": [ + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1" + } + ], + "ComputerSystems@odata.count": 1, + "Contains": [ + { + "@odata.id": "/redfish/v1/Chassis/Enclosure.Internal.0-1:RAID.Integrated.1-1" + } + ], + "Contains@odata.count": 1, + "CooledBy": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.1A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.1B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.2A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.2B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.3A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.3B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.4A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.4B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.5A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.5B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.6A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.6B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.7A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.7B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.8A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.8B" + } + ], + "CooledBy@odata.count": 16, + "Drives": [], + "Drives@odata.count": 0, + "ManagedBy": [ + { + "@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1" + } + ], + "ManagedBy@odata.count": 1, + "ManagersInChassis": [ + { + "@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1" + } + ], + "ManagersInChassis@odata.count": 1, + "PCIeDevices": [ + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/216-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-31" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-17" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/3-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-28" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-23" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/25-0" + } + ], + "PCIeDevices@odata.count": 8, + "PoweredBy": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power/PowerSupplies/PSU.Slot.1" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power/PowerSupplies/PSU.Slot.2" + } + ], + "PoweredBy@odata.count": 2, + "Storage": [ + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Integrated.1-1" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/AHCI.Embedded.1-1" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/AHCI.Embedded.2-1" + } + ], + "Storage@odata.count": 3 + }, + "Location": { + "Info": ";;;;1", + "InfoFormat": "DataCenter;RoomName;Aisle;RackName;RackSlot", + "Placement": { + "Rack": "", + "Row": "" + }, + "PostalAddress": { + "Building": "", + "Room": "" + } + }, + "Manufacturer": "Dell Inc.", + "Model": "PowerEdge R640", + "Name": "Computer System Chassis", + "NetworkAdapters": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/NetworkAdapters" + }, + "PartNumber": "0CRT1GA05", + "PhysicalSecurity": { + "IntrusionSensor": "Normal", + "IntrusionSensorNumber": 115, + "IntrusionSensorReArm": "Manual" + }, + "Power": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power" + }, + "PowerState": "On", + "SKU": "CLFV7M2", + "SerialNumber": "CNIVC007CV0803", + "Status": { + "Health": "OK", + "HealthRollup": "OK", + "State": "Enabled" + }, + "Thermal": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Thermal" + } +} diff --git a/plugins/inputs/redfish/testdata/dell_locationinvalid.json b/plugins/inputs/redfish/testdata/dell_locationinvalid.json new file mode 100644 index 0000000000000..c7789a69394b8 --- /dev/null +++ b/plugins/inputs/redfish/testdata/dell_locationinvalid.json @@ -0,0 +1,188 @@ +{ + "@odata.context": "/redfish/v1/$metadata#Chassis.Chassis", + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1", + "@odata.type": "#Chassis.v1_6_0.Chassis", + "Actions": { + "#Chassis.Reset": { + "ResetType@Redfish.AllowableValues": [ + "On", + "ForceOff" + ], + "target": "/redfish/v1/Chassis/System.Embedded.1/Actions/Chassis.Reset" + } + }, + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "AssetTag": null, + "ChassisType": "RackMount", + "Description": "It represents the properties for physical components for any system.It represent racks, rackmount servers, blades, standalone, modular systems,enclosures, and all other containers.The non-cpu/device centric parts of the schema are all accessed either directly or indirectly through this resource.", + "Id": "System.Embedded.1", + "IndicatorLED": "Off", + "Links": { + "ComputerSystems": [ + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1" + } + ], + "ComputerSystems@odata.count": 1, + "Contains": [ + { + "@odata.id": "/redfish/v1/Chassis/Enclosure.Internal.0-1:RAID.Integrated.1-1" + } + ], + "Contains@odata.count": 1, + "CooledBy": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.1A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.1B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.2A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.2B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.3A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.3B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.4A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.4B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.5A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.5B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.6A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.6B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.7A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.7B" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.8A" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.8B" + } + ], + "CooledBy@odata.count": 16, + "Drives": [], + "Drives@odata.count": 0, + "ManagedBy": [ + { + "@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1" + } + ], + "ManagedBy@odata.count": 1, + "ManagersInChassis": [ + { + "@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1" + } + ], + "ManagersInChassis@odata.count": 1, + "PCIeDevices": [ + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/216-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-31" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-17" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/3-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-28" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-0" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/0-23" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/PCIeDevice/25-0" + } + ], + "PCIeDevices@odata.count": 8, + "PoweredBy": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power/PowerSupplies/PSU.Slot.1" + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power/PowerSupplies/PSU.Slot.2" + } + ], + "PoweredBy@odata.count": 2, + "Storage": [ + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/RAID.Integrated.1-1" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/AHCI.Embedded.1-1" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Storage/AHCI.Embedded.2-1" + } + ], + "Storage@odata.count": 3 + }, + "Location": { + "Info": ";;;;1", + "InfoFormat": "DataCenter;RoomName;Aisle;RackName;RackSlot", + "Placement": { + "Rack": "", + "Row": "" + }, + "PostalAddress": { + "Building": "", + "Room": "" + } + }, + "Manufacturer": "Dell Inc.", + "Model": "PowerEdge R640", + "Name": "Computer System Chassis", + "NetworkAdapters": { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/NetworkAdapters" + }, + "PartNumber": "0CRT1GA05", + "PhysicalSecurity": { + "IntrusionSensor": "Normal", + "IntrusionSensorNumber": 115, + "IntrusionSensorReArm": "Manual" + }, + "Power": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power" + }, + "PowerState": "On", + "SKU": "CLFV7M2", + "SerialNumber": "CNIVC007CV0803", + "Status": { + "Health": "OK", + "HealthRollup": "OK", + "State": "Enabled" + }, + "Thermal": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Thermal" + } +} +{ diff --git a/plugins/inputs/redfish/testdata/dell_power.json b/plugins/inputs/redfish/testdata/dell_power.json new file mode 100644 index 0000000000000..7f2b38baa6758 --- /dev/null +++ b/plugins/inputs/redfish/testdata/dell_power.json @@ -0,0 +1,207 @@ +{ + "@odata.context": "/redfish/v1/$metadata#Power.Power", + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power", + "@odata.type": "#Power.v1_5_0.Power", + "Description": "Power", + "Id": "Power", + "Name": "Power", + "PowerControl": [ + { + "@odata.context": "/redfish/v1/$metadata#Power.Power", + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power/PowerControl", + "@odata.type": "#Power.v1_4_0.PowerControl", + "MemberId": "PowerControl", + "Name": "System Power Control", + "PowerAllocatedWatts": 1628, + "PowerAvailableWatts": 0, + "PowerCapacityWatts": 1628, + "PowerConsumedWatts": 429, + "PowerLimit": { + "CorrectionInMs": 0, + "LimitException": "HardPowerOff", + "LimitInWatts": 348 + }, + "PowerMetrics": { + "AverageConsumedWatts": 426, + "IntervalInMin": 1, + "MaxConsumedWatts": 436, + "MinConsumedWatts": 425 + }, + "PowerRequestedWatts": 704, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 2 + } + ], + "PowerControl@odata.count": 1, + "PowerSupplies": [ + { + "@odata.context": "/redfish/v1/$metadata#Power.Power", + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power/PowerSupplies/PSU.Slot.1", + "@odata.type": "#Power.v1_5_0.PowerSupply", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "EfficiencyPercent": 0.9100000262260437, + "FirmwareVersion": "00.1B.53", + "HotPluggable": true, + "InputRanges": [ + { + "InputType": "AC", + "MaximumFrequencyHz": 63, + "MaximumVoltage": 264, + "MinimumFrequencyHz": 47, + "MinimumVoltage": 90, + "OutputWattage": 750 + } + ], + "InputRanges@odata.count": 1, + "LastPowerOutputWatts": null, + "LineInputVoltage": 206, + "LineInputVoltageType": "AC240V", + "Manufacturer": "Dell", + "MemberId": "PSU.Slot.1", + "Model": "PWR SPLY,750W,RDNT,ARTESYN ", + "Name": "PS1 Status", + "Oem": { + "Dell": { + "DellPowerSupply": { + "@odata.context": "/redfish/v1/$metadata#DellPowerSupply.DellPowerSupply", + "@odata.id": "/redfish/v1/Dell/Chassis/System.Embedded.1/Power/PowerSupplies/DellPowerSupply/PSU.Slot.1", + "@odata.type": "#DellPowerSupply.v1_0_0.DellPowerSupply", + "IsSwitchingSupply": true, + "Links": { + "DellPSNumericSensorCollection": [ + { + "@odata.id": "/redfish/v1/Dell/Systems/System.Embedded.1/DellPSNumericSensor/iDRAC.Embedded.1%23PS1Current1" + } + ] + } + }, + "DellPowerSupplyView": { + "@odata.context": "/redfish/v1/$metadata#DellPowerSupplyView.DellPowerSupplyView", + "@odata.id": "/redfish/v1/Dell/Chassis/System.Embedded.1/Power/PowerSupplies/DellPowerSupplyView/PSU.Slot.1", + "@odata.type": "#DellPowerSupplyView.v1_0_0.DellPowerSupplyView", + "DetailedState": "Presence Detected", + "Range1MaxInputPowerWatts": 900 + } + } + }, + "PartNumber": "0PJMDNA01", + "PowerCapacityWatts": 750, + "PowerInputWatts": 900, + "PowerOutputWatts": 203, + "PowerSupplyType": "AC", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "SerialNumber": "PHARP0079G0049", + "SparePartNumber": "0PJMDNA01", + "Status": { + "Health": "OK", + "State": "Enabled" + } + } + ], + "PowerSupplies@odata.count": 1, + "Redundancy": [], + "Redundancy@odata.count": 0, + "Voltages": [ + { + "@odata.context": "/redfish/v1/$metadata#Power.Power", + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Voltages/iDRAC.Embedded.1%23SystemBoardDIMMPG", + "@odata.type": "#Power.v1_3_0.Voltage", + "LowerThresholdCritical": null, + "LowerThresholdFatal": null, + "LowerThresholdNonCritical": null, + "MaxReadingRange": 0, + "MemberId": "iDRAC.Embedded.1#SystemBoardDIMMPG", + "MinReadingRange": 0, + "Name": "System Board DIMM PG", + "PhysicalContext": "SystemBoard", + "ReadingVolts": 1, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "SensorNumber": 7, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.context": "/redfish/v1/$metadata#Power.Power", + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Voltages/iDRAC.Embedded.1%23SystemBoardNDCPG", + "@odata.type": "#Power.v1_3_0.Voltage", + "LowerThresholdCritical": null, + "LowerThresholdFatal": null, + "LowerThresholdNonCritical": null, + "MaxReadingRange": 197, + "MemberId": "iDRAC.Embedded.1#SystemBoardNDCPG", + "MinReadingRange": 139, + "Name": "System Board NDC PG", + "PhysicalContext": "SystemBoard", + "ReadingVolts": 1, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "SensorNumber": 8, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.context": "/redfish/v1/$metadata#Power.Power", + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Voltages/iDRAC.Embedded.1%23SystemBoardPS1PGFAIL", + "@odata.type": "#Power.v1_3_0.Voltage", + "LowerThresholdCritical": null, + "LowerThresholdFatal": null, + "LowerThresholdNonCritical": null, + "MaxReadingRange": 197, + "MemberId": "iDRAC.Embedded.1#SystemBoardPS1PGFAIL", + "MinReadingRange": 139, + "Name": "System Board PS1 PG FAIL", + "PhysicalContext": "SystemBoard", + "ReadingVolts": 1, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "SensorNumber": 9, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + } + ], + "Voltages@odata.count": 4 +} diff --git a/plugins/inputs/redfish/testdata/dell_powerinvalid.json b/plugins/inputs/redfish/testdata/dell_powerinvalid.json new file mode 100644 index 0000000000000..59f31503fa237 --- /dev/null +++ b/plugins/inputs/redfish/testdata/dell_powerinvalid.json @@ -0,0 +1,207 @@ +{ + "@odata.context": "/redfish/v1/$metadata#Power.Power", + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power", + "@odata.type": "#Power.v1_5_0.Power", + "Description": "Power", + "Id": "Power", + "Name": "Power", + "PowerControl": [ + { + "@odata.context": "/redfish/v1/$metadata#Power.Power", + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power/PowerControl", + "@odata.type": "#Power.v1_4_0.PowerControl", + "MemberId": "PowerControl", + "Name": "System Power Control", + "PowerAllocatedWatts": 1628, + "PowerAvailableWatts": 0, + "PowerCapacityWatts": 1628, + "PowerConsumedWatts": 429, + "PowerLimit": { + "CorrectionInMs": 0, + "LimitException": "HardPowerOff", + "LimitInWatts": 348 + }, + "PowerMetrics": { + "AverageConsumedWatts": 426, + "IntervalInMin": 1, + "MaxConsumedWatts": 436, + "MinConsumedWatts": 425 + }, + "PowerRequestedWatts": 704, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + }, + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 2 + } + ], + "PowerControl@odata.count": 1, + "PowerSupplies": [ + { + "@odata.context": "/redfish/v1/$metadata#Power.Power", + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Power/PowerSupplies/PSU.Slot.1", + "@odata.type": "#Power.v1_5_0.PowerSupply", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "EfficiencyPercent": 0.9100000262260437, + "FirmwareVersion": "00.1B.53", + "HotPluggable": true, + "InputRanges": [ + { + "InputType": "AC", + "MaximumFrequencyHz": 63, + "MaximumVoltage": 264, + "MinimumFrequencyHz": 47, + "MinimumVoltage": 90, + "OutputWattage": 750 + } + ], + "InputRanges@odata.count": 1, + "LastPowerOutputWatts": null, + "LineInputVoltage": 206, + "LineInputVoltageType": "AC240V", + "Manufacturer": "Dell", + "MemberId": "PSU.Slot.1", + "Model": "PWR SPLY,750W,RDNT,ARTESYN ", + "Name": PS1 Status, + "Oem": { + "Dell": { + "DellPowerSupply": { + "@odata.context": "/redfish/v1/$metadata#DellPowerSupply.DellPowerSupply", + "@odata.id": "/redfish/v1/Dell/Chassis/System.Embedded.1/Power/PowerSupplies/DellPowerSupply/PSU.Slot.1", + "@odata.type": "#DellPowerSupply.v1_0_0.DellPowerSupply", + "IsSwitchingSupply": true, + "Links": { + "DellPSNumericSensorCollection": [ + { + "@odata.id": "/redfish/v1/Dell/Systems/System.Embedded.1/DellPSNumericSensor/iDRAC.Embedded.1%23PS1Current1" + } + ] + } + }, + "DellPowerSupplyView": { + "@odata.context": "/redfish/v1/$metadata#DellPowerSupplyView.DellPowerSupplyView", + "@odata.id": "/redfish/v1/Dell/Chassis/System.Embedded.1/Power/PowerSupplies/DellPowerSupplyView/PSU.Slot.1", + "@odata.type": "#DellPowerSupplyView.v1_0_0.DellPowerSupplyView", + "DetailedState": "Presence Detected", + "Range1MaxInputPowerWatts": 900 + } + } + }, + "PartNumber": "0PJMDNA01", + "PowerCapacityWatts": 750, + "PowerInputWatts": 900, + "PowerOutputWatts": 203, + "PowerSupplyType": "AC", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "SerialNumber": "PHARP0079G0049", + "SparePartNumber": "0PJMDNA01", + "Status": { + "Health": "OK", + "State": "Enabled" + } + } + ], + "PowerSupplies@odata.count": 1, + "Redundancy": [], + "Redundancy@odata.count": 0, + "Voltages": [ + { + "@odata.context": "/redfish/v1/$metadata#Power.Power", + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Voltages/iDRAC.Embedded.1%23SystemBoardDIMMPG", + "@odata.type": "#Power.v1_3_0.Voltage", + "LowerThresholdCritical": null, + "LowerThresholdFatal": null, + "LowerThresholdNonCritical": null, + "MaxReadingRange": 0, + "MemberId": "iDRAC.Embedded.1#SystemBoardDIMMPG", + "MinReadingRange": 0, + "Name": "System Board DIMM PG", + "PhysicalContext": "SystemBoard", + "ReadingVolts": 1, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "SensorNumber": 7, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.context": "/redfish/v1/$metadata#Power.Power", + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Voltages/iDRAC.Embedded.1%23SystemBoardNDCPG", + "@odata.type": "#Power.v1_3_0.Voltage", + "LowerThresholdCritical": null, + "LowerThresholdFatal": null, + "LowerThresholdNonCritical": null, + "MaxReadingRange": 197, + "MemberId": "iDRAC.Embedded.1#SystemBoardNDCPG", + "MinReadingRange": 139, + "Name": "System Board NDC PG", + "PhysicalContext": "SystemBoard", + "ReadingVolts": 1, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "SensorNumber": 8, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.context": "/redfish/v1/$metadata#Power.Power", + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Voltages/iDRAC.Embedded.1%23SystemBoardPS1PGFAIL", + "@odata.type": "#Power.v1_3_0.Voltage", + "LowerThresholdCritical": null, + "LowerThresholdFatal": null, + "LowerThresholdNonCritical": null, + "MaxReadingRange": 197, + "MemberId": "iDRAC.Embedded.1#SystemBoardPS1PGFAIL", + "MinReadingRange": 139, + "Name": "System Board PS1 PG FAIL", + "PhysicalContext": "SystemBoard", + "ReadingVolts": 1, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "SensorNumber": 9, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + } + ], + "Voltages@odata.count": 4 +} diff --git a/plugins/inputs/redfish/testdata/dell_thermal.json b/plugins/inputs/redfish/testdata/dell_thermal.json new file mode 100644 index 0000000000000..07e7fe4c29dbd --- /dev/null +++ b/plugins/inputs/redfish/testdata/dell_thermal.json @@ -0,0 +1,589 @@ +{ + "@odata.context": "/redfish/v1/$metadata#Thermal.Thermal", + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Thermal", + "@odata.type": "#Thermal.v1_4_0.Thermal", + "Description": "Represents the properties for Temperature and Cooling", + "Fans": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.1A", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan1A", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.1A", + "MinReadingRange": 600, + "Name": "System Board Fan1A", + "PhysicalContext": "SystemBoard", + "Reading": 17760, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.1B", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan1B", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.1B", + "MinReadingRange": 600, + "Name": "System Board Fan1B", + "PhysicalContext": "SystemBoard", + "Reading": 15360, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.2A", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan2A", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.2A", + "MinReadingRange": 600, + "Name": "System Board Fan2A", + "PhysicalContext": "SystemBoard", + "Reading": 17880, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.2B", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan2B", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.2B", + "MinReadingRange": 600, + "Name": "System Board Fan2B", + "PhysicalContext": "SystemBoard", + "Reading": 15120, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.3A", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan3A", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.3A", + "MinReadingRange": 600, + "Name": "System Board Fan3A", + "PhysicalContext": "SystemBoard", + "Reading": 18000, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.3B", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan3B", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.3B", + "MinReadingRange": 600, + "Name": "System Board Fan3B", + "PhysicalContext": "SystemBoard", + "Reading": 15600, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.4A", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan4A", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.4A", + "MinReadingRange": 600, + "Name": "System Board Fan4A", + "PhysicalContext": "SystemBoard", + "Reading": 17280, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.4B", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan4B", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.4B", + "MinReadingRange": 600, + "Name": "System Board Fan4B", + "PhysicalContext": "SystemBoard", + "Reading": 15360, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.5A", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan5A", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.5A", + "MinReadingRange": 600, + "Name": "System Board Fan5A", + "PhysicalContext": "SystemBoard", + "Reading": 17640, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.5B", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan5B", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.5B", + "MinReadingRange": 600, + "Name": "System Board Fan5B", + "PhysicalContext": "SystemBoard", + "Reading": 15600, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.6A", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan6A", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.6A", + "MinReadingRange": 600, + "Name": "System Board Fan6A", + "PhysicalContext": "SystemBoard", + "Reading": 17760, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.6B", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan6B", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.6B", + "MinReadingRange": 600, + "Name": "System Board Fan6B", + "PhysicalContext": "SystemBoard", + "Reading": 15600, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.7A", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan7A", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.7A", + "MinReadingRange": 600, + "Name": "System Board Fan7A", + "PhysicalContext": "SystemBoard", + "Reading": 17400, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.7B", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan7B", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.7B", + "MinReadingRange": 600, + "Name": "System Board Fan7B", + "PhysicalContext": "SystemBoard", + "Reading": 15720, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.8A", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan8A", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.8A", + "MinReadingRange": 600, + "Name": "System Board Fan8A", + "PhysicalContext": "SystemBoard", + "Reading": 18000, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.8B", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan8B", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.8B", + "MinReadingRange": 600, + "Name": "System Board Fan8B", + "PhysicalContext": "SystemBoard", + "Reading": 15840, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + } + ], + "Fans@odata.count": 16, + "Id": "Thermal", + "Name": "Thermal", + "Redundancy": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Thermal/Redundancy/iDRAC.Embedded.1%23SystemBoardFanRedundancy", + "@odata.type": "#Redundancy.v1_3_0.Redundancy", + "MaxNumSupported": 0, + "MemberId": "iDRAC.Embedded.1#SystemBoardFanRedundancy", + "MinNumNeeded": 0, + "Mode": "N+m", + "Name": "System Board Fan Redundancy", + "RedundancyEnabled": true, + "RedundancySet": [], + "RedundancySet@odata.count": 0, + "Status": { + "Health": "OK", + "State": "Enabled" + } + } + ], + "Redundancy@odata.count": 1, + "Temperatures": [ + { + "@odata.context": "/redfish/v1/$metadata#Thermal.Thermal", + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Temperatures/iDRAC.Embedded.1%23CPU1Temp", + "@odata.type": "#Thermal.v1_4_0.Temperature", + "LowerThresholdCritical": 3, + "LowerThresholdFatal": 3, + "LowerThresholdNonCritical": null, + "MaxReadingRangeTemp": 93, + "MemberId": "iDRAC.Embedded.1#CPU1Temp", + "MinReadingRangeTemp": 3, + "Name": "CPU1 Temp", + "PhysicalContext": "CPU", + "ReadingCelsius": 40, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Processors/CPU.Socket.1" + } + ], + "RelatedItem@odata.count": 1, + "SensorNumber": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": 93, + "UpperThresholdFatal": 93, + "UpperThresholdNonCritical": null + } + ], + "Temperatures@odata.count": 4 +} diff --git a/plugins/inputs/redfish/testdata/dell_thermalinvalid.json b/plugins/inputs/redfish/testdata/dell_thermalinvalid.json new file mode 100644 index 0000000000000..139322ad1378e --- /dev/null +++ b/plugins/inputs/redfish/testdata/dell_thermalinvalid.json @@ -0,0 +1,589 @@ +{ + "@odata.context": "/redfish/v1/$metadata#Thermal.Thermal", + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Thermal", + "@odata.type": "#Thermal.v1_4_0.Thermal", + "Description": "Represents the properties for Temperature and Cooling", + "Fans": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.1A", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan1A", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.1A", + "MinReadingRange": 600, + "Name": System Board Fan1A, + "PhysicalContext": "SystemBoard", + "Reading": 17760, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.1B", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan1B", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.1B", + "MinReadingRange": 600, + "Name": "System Board Fan1B", + "PhysicalContext": "SystemBoard", + "Reading": 15360, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.2A", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan2A", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.2A", + "MinReadingRange": 600, + "Name": "System Board Fan2A", + "PhysicalContext": "SystemBoard", + "Reading": 17880, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.2B", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan2B", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.2B", + "MinReadingRange": 600, + "Name": "System Board Fan2B", + "PhysicalContext": "SystemBoard", + "Reading": 15120, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.3A", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan3A", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.3A", + "MinReadingRange": 600, + "Name": "System Board Fan3A", + "PhysicalContext": "SystemBoard", + "Reading": 18000, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.3B", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan3B", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.3B", + "MinReadingRange": 600, + "Name": "System Board Fan3B", + "PhysicalContext": "SystemBoard", + "Reading": 15600, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.4A", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan4A", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.4A", + "MinReadingRange": 600, + "Name": "System Board Fan4A", + "PhysicalContext": "SystemBoard", + "Reading": 17280, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.4B", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan4B", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.4B", + "MinReadingRange": 600, + "Name": "System Board Fan4B", + "PhysicalContext": "SystemBoard", + "Reading": 15360, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.5A", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan5A", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.5A", + "MinReadingRange": 600, + "Name": "System Board Fan5A", + "PhysicalContext": "SystemBoard", + "Reading": 17640, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.5B", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan5B", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.5B", + "MinReadingRange": 600, + "Name": "System Board Fan5B", + "PhysicalContext": "SystemBoard", + "Reading": 15600, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.6A", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan6A", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.6A", + "MinReadingRange": 600, + "Name": "System Board Fan6A", + "PhysicalContext": "SystemBoard", + "Reading": 17760, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.6B", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan6B", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.6B", + "MinReadingRange": 600, + "Name": "System Board Fan6B", + "PhysicalContext": "SystemBoard", + "Reading": 15600, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.7A", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan7A", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.7A", + "MinReadingRange": 600, + "Name": "System Board Fan7A", + "PhysicalContext": "SystemBoard", + "Reading": 17400, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.7B", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan7B", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.7B", + "MinReadingRange": 600, + "Name": "System Board Fan7B", + "PhysicalContext": "SystemBoard", + "Reading": 15720, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.8A", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan8A", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.8A", + "MinReadingRange": 600, + "Name": "System Board Fan8A", + "PhysicalContext": "SystemBoard", + "Reading": 18000, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + }, + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Fans/0x17%7C%7CFan.Embedded.8B", + "@odata.type": "#Thermal.v1_4_0.Fan", + "Assembly": { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Assembly" + }, + "FanName": "System Board Fan8B", + "LowerThresholdCritical": 600, + "LowerThresholdFatal": 600, + "LowerThresholdNonCritical": 960, + "MaxReadingRange": null, + "MemberId": "0x17||Fan.Embedded.8B", + "MinReadingRange": 600, + "Name": "System Board Fan8B", + "PhysicalContext": "SystemBoard", + "Reading": 15840, + "ReadingUnits": "RPM", + "Redundancy": [], + "Redundancy@odata.count": 0, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1" + } + ], + "RelatedItem@odata.count": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": null, + "UpperThresholdFatal": null, + "UpperThresholdNonCritical": null + } + ], + "Fans@odata.count": 16, + "Id": "Thermal", + "Name": "Thermal", + "Redundancy": [ + { + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Thermal/Redundancy/iDRAC.Embedded.1%23SystemBoardFanRedundancy", + "@odata.type": "#Redundancy.v1_3_0.Redundancy", + "MaxNumSupported": 0, + "MemberId": "iDRAC.Embedded.1#SystemBoardFanRedundancy", + "MinNumNeeded": 0, + "Mode": "N+m", + "Name": "System Board Fan Redundancy", + "RedundancyEnabled": true, + "RedundancySet": [], + "RedundancySet@odata.count": 0, + "Status": { + "Health": "OK", + "State": "Enabled" + } + } + ], + "Redundancy@odata.count": 1, + "Temperatures": [ + { + "@odata.context": "/redfish/v1/$metadata#Thermal.Thermal", + "@odata.id": "/redfish/v1/Chassis/System.Embedded.1/Sensors/Temperatures/iDRAC.Embedded.1%23CPU1Temp", + "@odata.type": "#Thermal.v1_4_0.Temperature", + "LowerThresholdCritical": 3, + "LowerThresholdFatal": 3, + "LowerThresholdNonCritical": null, + "MaxReadingRangeTemp": 93, + "MemberId": "iDRAC.Embedded.1#CPU1Temp", + "MinReadingRangeTemp": 3, + "Name": "CPU1 Temp", + "PhysicalContext": "CPU", + "ReadingCelsius": 40, + "RelatedItem": [ + { + "@odata.id": "/redfish/v1/Systems/System.Embedded.1/Processors/CPU.Socket.1" + } + ], + "RelatedItem@odata.count": 1, + "SensorNumber": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": 93, + "UpperThresholdFatal": 93, + "UpperThresholdNonCritical": null + } + ], + "Temperatures@odata.count": 4 +} diff --git a/plugins/inputs/redfish/testdata/hp_hostname.json b/plugins/inputs/redfish/testdata/hp_hostname.json new file mode 100644 index 0000000000000..2280f1bfa0343 --- /dev/null +++ b/plugins/inputs/redfish/testdata/hp_hostname.json @@ -0,0 +1,319 @@ +{ + "@odata.context": "/redfish/v1/$metadata#ComputerSystem.ComputerSystem", + "@odata.etag": "W/\"43E302D1\"", + "@odata.id": "/redfish/v1/Systems/1/", + "@odata.type": "#ComputerSystem.v1_4_0.ComputerSystem", + "Id": "1", + "Actions": { + "#ComputerSystem.Reset": { + "ResetType@Redfish.AllowableValues": [ + "On", + "ForceOff", + "ForceRestart", + "Nmi", + "PushPowerButton" + ], + "target": "/redfish/v1/Systems/1/Actions/ComputerSystem.Reset/" + } + }, + "AssetTag": "", + "Bios": { + "@odata.id": "/redfish/v1/systems/1/bios/" + }, + "BiosVersion": "U32 v2.10 (05/21/2019)", + "Boot": { + "BootSourceOverrideEnabled": "Disabled", + "BootSourceOverrideMode": "UEFI", + "BootSourceOverrideTarget": "None", + "BootSourceOverrideTarget@Redfish.AllowableValues": [ + "None", + "Cd", + "Hdd", + "Usb", + "SDCard", + "Utilities", + "Diags", + "BiosSetup", + "Pxe", + "UefiShell", + "UefiHttp", + "UefiTarget" + ], + "UefiTargetBootSourceOverride": "None", + "UefiTargetBootSourceOverride@Redfish.AllowableValues": [ + "HD(1,GPT,0E3A0969-7AFC-4B55-8B24-AEFA09F33D2D,0x800,0x12C000)/\\EFI\\redhat\\shimx64.efi", + "UsbClass(0xFFFF,0xFFFF,0xFF,0xFF,0xFF)", + "PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)/MAC(8030E0421B1C,0x1)/IPv4(0.0.0.0)/Uri()", + "PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)/MAC(8030E0421B1C,0x1)/IPv4(0.0.0.0)", + "PciRoot(0x3)/Pci(0x2,0x0)/Pci(0x0,0x0)/MAC(48DF37959430,0x1)/IPv4(0.0.0.0)/Uri()", + "PciRoot(0x3)/Pci(0x2,0x0)/Pci(0x0,0x0)/MAC(48DF37959430,0x1)/IPv4(0.0.0.0)", + "PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)/MAC(8030E0421B1C,0x1)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)/Uri()", + "PciRoot(0x3)/Pci(0x2,0x0)/Pci(0x0,0x0)/MAC(48DF37959430,0x1)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)/Uri()", + "PciRoot(0x3)/Pci(0x2,0x0)/Pci(0x0,0x0)/MAC(48DF37959430,0x1)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)", + "PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)/MAC(8030E0421B1C,0x1)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)", + "PciRoot(0x9)/Pci(0x0,0x0)/Pci(0x0,0x0)/MAC(B88303866AE8,0x1)/IPv4(0.0.0.0)/Uri()", + "PciRoot(0x9)/Pci(0x0,0x0)/Pci(0x0,0x0)/MAC(B88303866AE8,0x1)/IPv4(0.0.0.0)", + "PciRoot(0x9)/Pci(0x0,0x0)/Pci(0x0,0x0)/MAC(B88303866AE8,0x1)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)/Uri()", + "PciRoot(0x9)/Pci(0x0,0x0)/Pci(0x0,0x0)/MAC(B88303866AE8,0x1)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)", + "PciRoot(0x0)/Pci(0x14,0x0)/USB(0x13,0x0)", + "PciRoot(0x3)/Pci(0x0,0x0)/Pci(0x0,0x0)/Scsi(0x0,0x0)" + ] + }, + "EthernetInterfaces": { + "@odata.id": "/redfish/v1/Systems/1/EthernetInterfaces/" + }, + "HostName": "tpa-hostname", + "IndicatorLED": "Off", + "Links": { + "ManagedBy": [ + { + "@odata.id": "/redfish/v1/Managers/1/" + } + ], + "Chassis": [ + { + "@odata.id": "/redfish/v1/Chassis/1/" + } + ] + }, + "LogServices": { + "@odata.id": "/redfish/v1/Systems/1/LogServices/" + }, + "Manufacturer": "HPE", + "Memory": { + "@odata.id": "/redfish/v1/Systems/1/Memory/" + }, + "MemoryDomains": { + "@odata.id": "/redfish/v1/Systems/1/MemoryDomains/" + }, + "MemorySummary": { + "Status": { + "HealthRollup": "OK" + }, + "TotalSystemMemoryGiB": 384, + "TotalSystemPersistentMemoryGiB": 0 + }, + "Model": "ProLiant DL360 Gen10", + "Name": "Computer System", + "NetworkInterfaces": { + "@odata.id": "/redfish/v1/Systems/1/NetworkInterfaces/" + }, + "Oem": { + "Hpe": { + "@odata.context": "/redfish/v1/$metadata#HpeComputerSystemExt.HpeComputerSystemExt", + "@odata.type": "#HpeComputerSystemExt.v2_6_1.HpeComputerSystemExt", + "Actions": { + "#HpeComputerSystemExt.PowerButton": { + "PushType@Redfish.AllowableValues": [ + "Press", + "PressAndHold" + ], + "target": "/redfish/v1/Systems/1/Actions/Oem/Hpe/HpeComputerSystemExt.PowerButton/" + }, + "#HpeComputerSystemExt.SecureSystemErase": { + "target": "/redfish/v1/Systems/1/Actions/Oem/Hpe/HpeComputerSystemExt.SecureSystemErase/" + }, + "#HpeComputerSystemExt.SystemReset": { + "ResetType@Redfish.AllowableValues": [ + "ColdBoot", + "AuxCycle" + ], + "target": "/redfish/v1/Systems/1/Actions/Oem/Hpe/HpeComputerSystemExt.SystemReset/" + } + }, + "AggregateHealthStatus": { + "AgentlessManagementService": "Unavailable", + "BiosOrHardwareHealth": { + "Status": { + "Health": "OK" + } + }, + "FanRedundancy": "Redundant", + "Fans": { + "Status": { + "Health": "OK" + } + }, + "Memory": { + "Status": { + "Health": "OK" + } + }, + "Network": { + "Status": { + "Health": "OK" + } + }, + "PowerSupplies": { + "PowerSuppliesMismatch": false, + "Status": { + "Health": "OK" + } + }, + "PowerSupplyRedundancy": "Redundant", + "Processors": { + "Status": { + "Health": "OK" + } + }, + "SmartStorageBattery": { + "Status": { + "Health": "OK" + } + }, + "Storage": { + "Status": { + "Health": "OK" + } + }, + "Temperatures": { + "Status": { + "Health": "OK" + } + } + }, + "Bios": { + "Backup": { + "Date": "05/21/2019", + "Family": "U32", + "VersionString": "U32 v2.10 (05/21/2019)" + }, + "Current": { + "Date": "05/21/2019", + "Family": "U32", + "VersionString": "U32 v2.10 (05/21/2019)" + }, + "UefiClass": 2 + }, + "CurrentPowerOnTimeSeconds": 29290, + "DeviceDiscoveryComplete": { + "AMSDeviceDiscovery": "NoAMS", + "DeviceDiscovery": "vMainDeviceDiscoveryComplete", + "SmartArrayDiscovery": "Complete" + }, + "ElapsedEraseTimeInMinutes": 0, + "EndOfPostDelaySeconds": null, + "EstimatedEraseTimeInMinutes": 0, + "IntelligentProvisioningAlwaysOn": true, + "IntelligentProvisioningIndex": 9, + "IntelligentProvisioningLocation": "System Board", + "IntelligentProvisioningVersion": "3.30.213", + "IsColdBooting": false, + "Links": { + "PCIDevices": { + "@odata.id": "/redfish/v1/Systems/1/PCIDevices/" + }, + "PCISlots": { + "@odata.id": "/redfish/v1/Systems/1/PCISlots/" + }, + "NetworkAdapters": { + "@odata.id": "/redfish/v1/Systems/1/BaseNetworkAdapters/" + }, + "SmartStorage": { + "@odata.id": "/redfish/v1/Systems/1/SmartStorage/" + }, + "USBPorts": { + "@odata.id": "/redfish/v1/Systems/1/USBPorts/" + }, + "USBDevices": { + "@odata.id": "/redfish/v1/Systems/1/USBDevices/" + }, + "EthernetInterfaces": { + "@odata.id": "/redfish/v1/Systems/1/EthernetInterfaces/" + }, + "WorkloadPerformanceAdvisor": { + "@odata.id": "/redfish/v1/Systems/1/WorkloadPerformanceAdvisor/" + } + }, + "PCAPartNumber": "847479-002", + "PCASerialNumber": "PWUFL0ARHCF3KR", + "PostDiscoveryCompleteTimeStamp": "2020-02-24T02:43:43Z", + "PostDiscoveryMode": null, + "PostMode": null, + "PostState": "FinishedPost", + "PowerAllocationLimit": 1600, + "PowerAutoOn": "Restore", + "PowerOnDelay": "Minimum", + "PowerOnMinutes": 95715, + "PowerRegulatorMode": "Max", + "PowerRegulatorModesSupported": [ + "OSControl", + "Dynamic", + "Max", + "Min" + ], + "ProcessorJitterControl": { + "ConfiguredFrequencyLimitMHz": 0, + "Mode": "Disabled" + }, + "SMBIOS": { + "extref": "/smbios" + }, + "ServerFQDN": "TPAVCPAR088S4.vici.verizon.com", + "SmartStorageConfig": [ + { + "@odata.id": "/redfish/v1/systems/1/smartstorageconfig/" + } + ], + "SystemROMAndiLOEraseComponentStatus": { + "BIOSSettingsEraseStatus": "Idle", + "iLOSettingsEraseStatus": "Idle" + }, + "SystemROMAndiLOEraseStatus": "Idle", + "SystemUsage": { + "AvgCPU0Freq": 0, + "AvgCPU1Freq": 6, + "CPU0Power": 50, + "CPU1Power": 51, + "CPUICUtil": 0, + "CPUUtil": 0, + "IOBusUtil": 0, + "JitterCount": 35, + "MemoryBusUtil": 0 + }, + "UserDataEraseComponentStatus": {}, + "UserDataEraseStatus": "Idle", + "VirtualProfile": "Inactive" + } + }, + "PowerState": "On", + "ProcessorSummary": { + "Count": 2, + "Model": "Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz", + "Status": { + "HealthRollup": "OK" + } + }, + "Processors": { + "@odata.id": "/redfish/v1/Systems/1/Processors/" + }, + "SKU": "867959-B21", + "SecureBoot": { + "@odata.id": "/redfish/v1/Systems/1/SecureBoot/" + }, + "SerialNumber": "MXQ93003RB", + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "Storage": { + "@odata.id": "/redfish/v1/Systems/1/Storage/" + }, + "SystemType": "Physical", + "TrustedModules": [ + { + "FirmwareVersion": "73.0", + "InterfaceType": "TPM1_2", + "Oem": { + "Hpe": { + "@odata.context": "/redfish/v1/$metadata#HpeTrustedModuleExt.HpeTrustedModuleExt", + "@odata.type": "#HpeTrustedModuleExt.v2_0_0.HpeTrustedModuleExt", + "VendorName": "STMicro" + } + }, + "Status": { + "State": "Disabled" + } + } + ] +} diff --git a/plugins/inputs/redfish/testdata/hp_hostnameinvalid.json b/plugins/inputs/redfish/testdata/hp_hostnameinvalid.json new file mode 100644 index 0000000000000..d07c1e5a05e9b --- /dev/null +++ b/plugins/inputs/redfish/testdata/hp_hostnameinvalid.json @@ -0,0 +1,320 @@ +{ + "@odata.context": "/redfish/v1/$metadata#ComputerSystem.ComputerSystem", + "@odata.etag": "W/\"43E302D1\"", + "@odata.id": "/redfish/v1/Systems/1/", + "@odata.type": "#ComputerSystem.v1_4_0.ComputerSystem", + "Id": "1", + "Actions": { + "#ComputerSystem.Reset": { + "ResetType@Redfish.AllowableValues": [ + "On", + "ForceOff", + "ForceRestart", + "Nmi", + "PushPowerButton" + ], + "target": "/redfish/v1/Systems/1/Actions/ComputerSystem.Reset/" + } + }, + "AssetTag": "", + "Bios": { + "@odata.id": "/redfish/v1/systems/1/bios/" + }, + "BiosVersion": "U32 v2.10 (05/21/2019)", + "Boot": { + "BootSourceOverrideEnabled": "Disabled", + "BootSourceOverrideMode": "UEFI", + "BootSourceOverrideTarget": "None", + "BootSourceOverrideTarget@Redfish.AllowableValues": [ + "None", + "Cd", + "Hdd", + "Usb", + "SDCard", + "Utilities", + "Diags", + "BiosSetup", + "Pxe", + "UefiShell", + "UefiHttp", + "UefiTarget" + ], + "UefiTargetBootSourceOverride": "None", + "UefiTargetBootSourceOverride@Redfish.AllowableValues": [ + "HD(1,GPT,0E3A0969-7AFC-4B55-8B24-AEFA09F33D2D,0x800,0x12C000)/\\EFI\\redhat\\shimx64.efi", + "UsbClass(0xFFFF,0xFFFF,0xFF,0xFF,0xFF)", + "PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)/MAC(8030E0421B1C,0x1)/IPv4(0.0.0.0)/Uri()", + "PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)/MAC(8030E0421B1C,0x1)/IPv4(0.0.0.0)", + "PciRoot(0x3)/Pci(0x2,0x0)/Pci(0x0,0x0)/MAC(48DF37959430,0x1)/IPv4(0.0.0.0)/Uri()", + "PciRoot(0x3)/Pci(0x2,0x0)/Pci(0x0,0x0)/MAC(48DF37959430,0x1)/IPv4(0.0.0.0)", + "PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)/MAC(8030E0421B1C,0x1)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)/Uri()", + "PciRoot(0x3)/Pci(0x2,0x0)/Pci(0x0,0x0)/MAC(48DF37959430,0x1)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)/Uri()", + "PciRoot(0x3)/Pci(0x2,0x0)/Pci(0x0,0x0)/MAC(48DF37959430,0x1)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)", + "PciRoot(0x0)/Pci(0x1C,0x0)/Pci(0x0,0x0)/MAC(8030E0421B1C,0x1)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)", + "PciRoot(0x9)/Pci(0x0,0x0)/Pci(0x0,0x0)/MAC(B88303866AE8,0x1)/IPv4(0.0.0.0)/Uri()", + "PciRoot(0x9)/Pci(0x0,0x0)/Pci(0x0,0x0)/MAC(B88303866AE8,0x1)/IPv4(0.0.0.0)", + "PciRoot(0x9)/Pci(0x0,0x0)/Pci(0x0,0x0)/MAC(B88303866AE8,0x1)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)/Uri()", + "PciRoot(0x9)/Pci(0x0,0x0)/Pci(0x0,0x0)/MAC(B88303866AE8,0x1)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000)", + "PciRoot(0x0)/Pci(0x14,0x0)/USB(0x13,0x0)", + "PciRoot(0x3)/Pci(0x0,0x0)/Pci(0x0,0x0)/Scsi(0x0,0x0)" + ] + }, + "EthernetInterfaces": { + "@odata.id": "/redfish/v1/Systems/1/EthernetInterfaces/" + }, + "HostName": "tpa-hostname", + "IndicatorLED": "Off", + "Links": { + "ManagedBy": [ + { + "@odata.id": "/redfish/v1/Managers/1/" + } + ], + "Chassis": [ + { + "@odata.id": "/redfish/v1/Chassis/1/" + } + ] + }, + "LogServices": { + "@odata.id": "/redfish/v1/Systems/1/LogServices/" + }, + "Manufacturer": "HPE", + "Memory": { + "@odata.id": "/redfish/v1/Systems/1/Memory/" + }, + "MemoryDomains": { + "@odata.id": "/redfish/v1/Systems/1/MemoryDomains/" + }, + "MemorySummary": { + "Status": { + "HealthRollup": "OK" + }, + "TotalSystemMemoryGiB": 384, + "TotalSystemPersistentMemoryGiB": 0 + }, + "Model": "ProLiant DL360 Gen10", + "Name": "Computer System", + "NetworkInterfaces": { + "@odata.id": "/redfish/v1/Systems/1/NetworkInterfaces/" + }, + "Oem": { + "Hpe": { + "@odata.context": "/redfish/v1/$metadata#HpeComputerSystemExt.HpeComputerSystemExt", + "@odata.type": "#HpeComputerSystemExt.v2_6_1.HpeComputerSystemExt", + "Actions": { + "#HpeComputerSystemExt.PowerButton": { + "PushType@Redfish.AllowableValues": [ + "Press", + "PressAndHold" + ], + "target": "/redfish/v1/Systems/1/Actions/Oem/Hpe/HpeComputerSystemExt.PowerButton/" + }, + "#HpeComputerSystemExt.SecureSystemErase": { + "target": "/redfish/v1/Systems/1/Actions/Oem/Hpe/HpeComputerSystemExt.SecureSystemErase/" + }, + "#HpeComputerSystemExt.SystemReset": { + "ResetType@Redfish.AllowableValues": [ + "ColdBoot", + "AuxCycle" + ], + "target": "/redfish/v1/Systems/1/Actions/Oem/Hpe/HpeComputerSystemExt.SystemReset/" + } + }, + "AggregateHealthStatus": { + "AgentlessManagementService": "Unavailable", + "BiosOrHardwareHealth": { + "Status": { + "Health": "OK" + } + }, + "FanRedundancy": "Redundant", + "Fans": { + "Status": { + "Health": "OK" + } + }, + "Memory": { + "Status": { + "Health": "OK" + } + }, + "Network": { + "Status": { + "Health": "OK" + } + }, + "PowerSupplies": { + "PowerSuppliesMismatch": false, + "Status": { + "Health": "OK" + } + }, + "PowerSupplyRedundancy": "Redundant", + "Processors": { + "Status": { + "Health": "OK" + } + }, + "SmartStorageBattery": { + "Status": { + "Health": "OK" + } + }, + "Storage": { + "Status": { + "Health": "OK" + } + }, + "Temperatures": { + "Status": { + "Health": "OK" + } + } + }, + "Bios": { + "Backup": { + "Date": "05/21/2019", + "Family": "U32", + "VersionString": "U32 v2.10 (05/21/2019)" + }, + "Current": { + "Date": "05/21/2019", + "Family": "U32", + "VersionString": "U32 v2.10 (05/21/2019)" + }, + "UefiClass": 2 + }, + "CurrentPowerOnTimeSeconds": 29290, + "DeviceDiscoveryComplete": { + "AMSDeviceDiscovery": "NoAMS", + "DeviceDiscovery": "vMainDeviceDiscoveryComplete", + "SmartArrayDiscovery": "Complete" + }, + "ElapsedEraseTimeInMinutes": 0, + "EndOfPostDelaySeconds": null, + "EstimatedEraseTimeInMinutes": 0, + "IntelligentProvisioningAlwaysOn": true, + "IntelligentProvisioningIndex": 9, + "IntelligentProvisioningLocation": "System Board", + "IntelligentProvisioningVersion": "3.30.213", + "IsColdBooting": false, + "Links": { + "PCIDevices": { + "@odata.id": "/redfish/v1/Systems/1/PCIDevices/" + }, + "PCISlots": { + "@odata.id": "/redfish/v1/Systems/1/PCISlots/" + }, + "NetworkAdapters": { + "@odata.id": "/redfish/v1/Systems/1/BaseNetworkAdapters/" + }, + "SmartStorage": { + "@odata.id": "/redfish/v1/Systems/1/SmartStorage/" + }, + "USBPorts": { + "@odata.id": "/redfish/v1/Systems/1/USBPorts/" + }, + "USBDevices": { + "@odata.id": "/redfish/v1/Systems/1/USBDevices/" + }, + "EthernetInterfaces": { + "@odata.id": "/redfish/v1/Systems/1/EthernetInterfaces/" + }, + "WorkloadPerformanceAdvisor": { + "@odata.id": "/redfish/v1/Systems/1/WorkloadPerformanceAdvisor/" + } + }, + "PCAPartNumber": "847479-002", + "PCASerialNumber": "PWUFL0ARHCF3KR", + "PostDiscoveryCompleteTimeStamp": "2020-02-24T02:43:43Z", + "PostDiscoveryMode": null, + "PostMode": null, + "PostState": "FinishedPost", + "PowerAllocationLimit": 1600, + "PowerAutoOn": "Restore", + "PowerOnDelay": "Minimum", + "PowerOnMinutes": 95715, + "PowerRegulatorMode": "Max", + "PowerRegulatorModesSupported": [ + "OSControl", + "Dynamic", + "Max", + "Min" + ], + "ProcessorJitterControl": { + "ConfiguredFrequencyLimitMHz": 0, + "Mode": "Disabled" + }, + "SMBIOS": { + "extref": "/smbios" + }, + "ServerFQDN": "TPAVCPAR088S4.vici.verizon.com", + "SmartStorageConfig": [ + { + "@odata.id": "/redfish/v1/systems/1/smartstorageconfig/" + } + ], + "SystemROMAndiLOEraseComponentStatus": { + "BIOSSettingsEraseStatus": "Idle", + "iLOSettingsEraseStatus": "Idle" + }, + "SystemROMAndiLOEraseStatus": "Idle", + "SystemUsage": { + "AvgCPU0Freq": 0, + "AvgCPU1Freq": 6, + "CPU0Power": 50, + "CPU1Power": 51, + "CPUICUtil": 0, + "CPUUtil": 0, + "IOBusUtil": 0, + "JitterCount": 35, + "MemoryBusUtil": 0 + }, + "UserDataEraseComponentStatus": {}, + "UserDataEraseStatus": "Idle", + "VirtualProfile": "Inactive" + } + }, + "PowerState": "On", + "ProcessorSummary": { + "Count": 2, + "Model": "Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz", + "Status": { + "HealthRollup": "OK" + } + }, + "Processors": { + "@odata.id": "/redfish/v1/Systems/1/Processors/" + }, + "SKU": "867959-B21", + "SecureBoot": { + "@odata.id": "/redfish/v1/Systems/1/SecureBoot/" + }, + "SerialNumber": "MXQ93003RB", + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "Storage": { + "@odata.id": "/redfish/v1/Systems/1/Storage/" + }, + "SystemType": "Physical", + "TrustedModules": [ + { + "FirmwareVersion": "73.0", + "InterfaceType": "TPM1_2", + "Oem": { + "Hpe": { + "@odata.context": "/redfish/v1/$metadata#HpeTrustedModuleExt.HpeTrustedModuleExt", + "@odata.type": "#HpeTrustedModuleExt.v2_0_0.HpeTrustedModuleExt", + "VendorName": "STMicro" + } + }, + "Status": { + "State": "Disabled" + } + } + ] +} +{ diff --git a/plugins/inputs/redfish/testdata/hp_power.json b/plugins/inputs/redfish/testdata/hp_power.json new file mode 100644 index 0000000000000..cc00b063fe6da --- /dev/null +++ b/plugins/inputs/redfish/testdata/hp_power.json @@ -0,0 +1,144 @@ +{ + "@odata.context": "/redfish/v1/$metadata#Power.Power", + "@odata.etag": "W/\"2E43EED0\"", + "@odata.id": "/redfish/v1/Chassis/1/Power", + "@odata.type": "#Power.v1_3_0.Power", + "Id": "Power", + "Name": "PowerMetrics", + "Oem": { + "Hpe": { + "@odata.context": "/redfish/v1/$metadata#HpePowerMetricsExt.HpePowerMetricsExt", + "@odata.type": "#HpePowerMetricsExt.v2_2_0.HpePowerMetricsExt", + "BrownoutRecoveryEnabled": true, + "HasCpuPowerMetering": true, + "HasDimmPowerMetering": true, + "HasGpuPowerMetering": false, + "HasPowerMetering": true, + "HighEfficiencyMode": "Balanced", + "Links": { + "PowerMeter": { + "@odata.id": "/redfish/v1/Chassis/1/Power/PowerMeter" + }, + "FastPowerMeter": { + "@odata.id": "/redfish/v1/Chassis/1/Power/FastPowerMeter" + }, + "FederatedGroupCapping": { + "@odata.id": "/redfish/v1/Chassis/1/Power/FederatedGroupCapping" + } + }, + "MinimumSafelyAchievableCap": null, + "MinimumSafelyAchievableCapValid": false, + "SNMPPowerThresholdAlert": { + "DurationInMin": 0, + "ThresholdWatts": 0, + "Trigger": "Disabled" + } + } + }, + "PowerControl": [ + { + "@odata.id": "/redfish/v1/Chassis/1/Power#PowerControl/0", + "MemberId": "0", + "PowerCapacityWatts": 1600, + "PowerConsumedWatts": 221, + "PowerMetrics": { + "AverageConsumedWatts": 221, + "IntervalInMin": 20, + "MaxConsumedWatts": 252, + "MinConsumedWatts": 220 + } + } + ], + "PowerSupplies": [ + { + "@odata.id": "/redfish/v1/Chassis/1/Power#PowerSupplies/0", + "FirmwareVersion": "1.02", + "LastPowerOutputWatts": 0, + "LineInputVoltage": 205, + "LineInputVoltageType": "ACHighLine", + "Manufacturer": "CHCNY", + "MemberId": "0", + "Model": "865414-B21", + "Name": "HpeServerPowerSupply", + "Oem": { + "Hpe": { + "@odata.context": "/redfish/v1/$metadata#HpeServerPowerSupply.HpeServerPowerSupply", + "@odata.type": "#HpeServerPowerSupply.v2_0_0.HpeServerPowerSupply", + "AveragePowerOutputWatts": 0, + "BayNumber": 1, + "HotplugCapable": true, + "MaxPowerOutputWatts": 143, + "Mismatched": false, + "PowerSupplyStatus": { + "State": "Ok" + }, + "iPDUCapable": false + } + }, + "PowerCapacityWatts": 800, + "PowerSupplyType": "AC", + "SerialNumber": "5WEBP0B8JAQ2K9", + "SparePartNumber": "866730-001", + "Status": { + "Health": "OK", + "State": "Enabled" + } + }, + { + "@odata.id": "/redfish/v1/Chassis/1/Power#PowerSupplies/1", + "FirmwareVersion": "1.02", + "LastPowerOutputWatts": 90, + "LineInputVoltage": 205, + "LineInputVoltageType": "ACHighLine", + "Manufacturer": "CHCNY", + "MemberId": "1", + "Model": "865414-B21", + "Name": "HpeServerPowerSupply", + "Oem": { + "Hpe": { + "@odata.context": "/redfish/v1/$metadata#HpeServerPowerSupply.HpeServerPowerSupply", + "@odata.type": "#HpeServerPowerSupply.v2_0_0.HpeServerPowerSupply", + "AveragePowerOutputWatts": 90, + "BayNumber": 2, + "HotplugCapable": true, + "MaxPowerOutputWatts": 99, + "Mismatched": false, + "PowerSupplyStatus": { + "State": "Ok" + }, + "iPDUCapable": false + } + }, + "PowerCapacityWatts": 800, + "PowerSupplyType": "AC", + "SerialNumber": "5WEBP0B8JAQ2KL", + "SparePartNumber": "866730-001", + "Status": { + "Health": "OK", + "State": "Enabled" + } + } + ], + "Redundancy": [ + { + "@odata.id": "/redfish/v1/Chassis/1/Power#Redundancy/0", + "MaxNumSupported": 2, + "MemberId": "0", + "MinNumNeeded": 2, + "Mode": "Failover", + "Name": "PowerSupply Redundancy Group 1", + "RedundancySet": [ + { + "@odata.id": "/redfish/v1/Chassis/1/Power#PowerSupplies/0" + }, + { + "@odata.id": "/redfish/v1/Chassis/1/Power#PowerSupplies/1" + } + ], + "Status": { + "Health": "OK", + "State": "Enabled" + } + } + ] +} diff --git a/plugins/inputs/redfish/testdata/hp_powerinvalid.json b/plugins/inputs/redfish/testdata/hp_powerinvalid.json new file mode 100644 index 0000000000000..b3e8a7f7a1a87 --- /dev/null +++ b/plugins/inputs/redfish/testdata/hp_powerinvalid.json @@ -0,0 +1,145 @@ +{ + "@odata.context": "/redfish/v1/$metadata#Power.Power", + "@odata.etag": "W/\"2E43EED0\"", + "@odata.id": "/redfish/v1/Chassis/1/Power", + "@odata.type": "#Power.v1_3_0.Power", + "Id": "Power", + "Name": "PowerMetrics", + "Oem": { + "Hpe": { + "@odata.context": "/redfish/v1/$metadata#HpePowerMetricsExt.HpePowerMetricsExt", + "@odata.type": "#HpePowerMetricsExt.v2_2_0.HpePowerMetricsExt", + "BrownoutRecoveryEnabled": true, + "HasCpuPowerMetering": true, + "HasDimmPowerMetering": true, + "HasGpuPowerMetering": false, + "HasPowerMetering": true, + "HighEfficiencyMode": "Balanced", + "Links": { + "PowerMeter": { + "@odata.id": "/redfish/v1/Chassis/1/Power/PowerMeter" + }, + "FastPowerMeter": { + "@odata.id": "/redfish/v1/Chassis/1/Power/FastPowerMeter" + }, + "FederatedGroupCapping": { + "@odata.id": "/redfish/v1/Chassis/1/Power/FederatedGroupCapping" + } + }, + "MinimumSafelyAchievableCap": null, + "MinimumSafelyAchievableCapValid": false, + "SNMPPowerThresholdAlert": { + "DurationInMin": 0, + "ThresholdWatts": 0, + "Trigger": "Disabled" + } + } + }, + "PowerControl": [ + { + "@odata.id": "/redfish/v1/Chassis/1/Power#PowerControl/0", + "MemberId": "0", + "PowerCapacityWatts": 1600, + "PowerConsumedWatts": 221, + "PowerMetrics": { + "AverageConsumedWatts": 221, + "IntervalInMin": 20, + "MaxConsumedWatts": 252, + "MinConsumedWatts": 220 + } + } + ], + "PowerSupplies": [ + { + "@odata.id": "/redfish/v1/Chassis/1/Power#PowerSupplies/0", + "FirmwareVersion": "1.02", + "LastPowerOutputWatts": 0, + "LineInputVoltage": 205, + "LineInputVoltageType": "ACHighLine", + "Manufacturer": "CHCNY", + "MemberId": "0", + "Model": "865414-B21", + "Name": "HpeServerPowerSupply", + "Oem": { + "Hpe": { + "@odata.context": "/redfish/v1/$metadata#HpeServerPowerSupply.HpeServerPowerSupply", + "@odata.type": "#HpeServerPowerSupply.v2_0_0.HpeServerPowerSupply", + "AveragePowerOutputWatts": 0, + "BayNumber": 1, + "HotplugCapable": true, + "MaxPowerOutputWatts": 143, + "Mismatched": false, + "PowerSupplyStatus": { + "State": "Ok" + }, + "iPDUCapable": false + } + }, + "PowerCapacityWatts": 800, + "PowerSupplyType": "AC", + "SerialNumber": "5WEBP0B8JAQ2K9", + "SparePartNumber": "866730-001", + "Status": { + "Health": "OK", + "State": "Enabled" + } + }, + { + "@odata.id": "/redfish/v1/Chassis/1/Power#PowerSupplies/1", + "FirmwareVersion": "1.02", + "LastPowerOutputWatts": 90, + "LineInputVoltage": 205, + "LineInputVoltageType": "ACHighLine", + "Manufacturer": "CHCNY", + "MemberId": "1", + "Model": "865414-B21", + "Name": "HpeServerPowerSupply", + "Oem": { + "Hpe": { + "@odata.context": "/redfish/v1/$metadata#HpeServerPowerSupply.HpeServerPowerSupply", + "@odata.type": "#HpeServerPowerSupply.v2_0_0.HpeServerPowerSupply", + "AveragePowerOutputWatts": 90, + "BayNumber": 2, + "HotplugCapable": true, + "MaxPowerOutputWatts": 99, + "Mismatched": false, + "PowerSupplyStatus": { + "State": "Ok" + }, + "iPDUCapable": false + } + }, + "PowerCapacityWatts": 800, + "PowerSupplyType": "AC", + "SerialNumber": "5WEBP0B8JAQ2KL", + "SparePartNumber": "866730-001", + "Status": { + "Health": "OK", + "State": "Enabled" + } + } + ], + "Redundancy": [ + { + "@odata.id": "/redfish/v1/Chassis/1/Power#Redundancy/0", + "MaxNumSupported": 2, + "MemberId": "0", + "MinNumNeeded": 2, + "Mode": "Failover", + "Name": "PowerSupply Redundancy Group 1", + "RedundancySet": [ + { + "@odata.id": "/redfish/v1/Chassis/1/Power#PowerSupplies/0" + }, + { + "@odata.id": "/redfish/v1/Chassis/1/Power#PowerSupplies/1" + } + ], + "Status": { + "Health": "OK", + "State": "Enabled" + } + } + ] +} +{ diff --git a/plugins/inputs/redfish/testdata/hp_thermal.json b/plugins/inputs/redfish/testdata/hp_thermal.json new file mode 100644 index 0000000000000..47c2ed1393f8a --- /dev/null +++ b/plugins/inputs/redfish/testdata/hp_thermal.json @@ -0,0 +1,116 @@ +{ + "@odata.context": "/redfish/v1/$metadata#Thermal.Thermal", + "@odata.etag": "W/\"14E8662D\"", + "@odata.id": "/redfish/v1/Chassis/1/Thermal", + "@odata.type": "#Thermal.v1_1_0.Thermal", + "Id": "Thermal", + "Fans": [ + { + "@odata.id": "/redfish/v1/Chassis/1/Thermal#Fans/0", + "MemberId": "0", + "Name": "Fan 1", + "Oem": { + "Hpe": { + "@odata.context": "/redfish/v1/$metadata#HpeServerFan.HpeServerFan", + "@odata.type": "#HpeServerFan.v2_0_0.HpeServerFan", + "HotPluggable": true, + "Location": "System", + "Redundant": true + } + }, + "Reading": 23, + "ReadingUnits": "Percent", + "Status": { + "Health": "OK", + "State": "Enabled" + } + }, + { + "@odata.id": "/redfish/v1/Chassis/1/Thermal#Fans/1", + "MemberId": "1", + "Name": "Fan 2", + "Oem": { + "Hpe": { + "@odata.context": "/redfish/v1/$metadata#HpeServerFan.HpeServerFan", + "@odata.type": "#HpeServerFan.v2_0_0.HpeServerFan", + "HotPluggable": true, + "Location": "System", + "Redundant": true + } + }, + "Reading": 23, + "ReadingUnits": "Percent", + "Status": { + "Health": "OK", + "State": "Enabled" + } + }, + { + "@odata.id": "/redfish/v1/Chassis/1/Thermal#Fans/2", + "MemberId": "2", + "Name": "Fan 3", + "Oem": { + "Hpe": { + "@odata.context": "/redfish/v1/$metadata#HpeServerFan.HpeServerFan", + "@odata.type": "#HpeServerFan.v2_0_0.HpeServerFan", + "HotPluggable": true, + "Location": "System", + "Redundant": true + } + }, + "Reading": 23, + "ReadingUnits": "Percent", + "Status": { + "Health": "OK", + "State": "Enabled" + } + } + ], + "Name": "Thermal", + "Temperatures": [ + { + "@odata.id": "/redfish/v1/Chassis/1/Thermal#Temperatures/0", + "MemberId": "0", + "Name": "01-Inlet Ambient", + "Oem": { + "Hpe": { + "@odata.context": "/redfish/v1/$metadata#HpeSeaOfSensors.HpeSeaOfSensors", + "@odata.type": "#HpeSeaOfSensors.v2_0_0.HpeSeaOfSensors", + "LocationXmm": 15, + "LocationYmm": 0 + } + }, + "PhysicalContext": "Intake", + "ReadingCelsius": 19, + "SensorNumber": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": 42, + "UpperThresholdFatal": 47 + }, + { + "@odata.id": "/redfish/v1/Chassis/1/Thermal#Temperatures/42", + "MemberId": "42", + "Name": "44-P/S 2 Zone", + "Oem": { + "Hpe": { + "@odata.context": "/redfish/v1/$metadata#HpeSeaOfSensors.HpeSeaOfSensors", + "@odata.type": "#HpeSeaOfSensors.v2_0_0.HpeSeaOfSensors", + "LocationXmm": 4, + "LocationYmm": 7 + } + }, + "PhysicalContext": "PowerSupply", + "ReadingCelsius": 34, + "SensorNumber": 43, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": 75, + "UpperThresholdFatal": 80 + } + ] +} diff --git a/plugins/inputs/redfish/testdata/hp_thermalinvalid.json b/plugins/inputs/redfish/testdata/hp_thermalinvalid.json new file mode 100644 index 0000000000000..e7f246310ec6f --- /dev/null +++ b/plugins/inputs/redfish/testdata/hp_thermalinvalid.json @@ -0,0 +1,117 @@ +{ + "@odata.context": "/redfish/v1/$metadata#Thermal.Thermal", + "@odata.etag": "W/\"14E8662D\"", + "@odata.id": "/redfish/v1/Chassis/1/Thermal", + "@odata.type": "#Thermal.v1_1_0.Thermal", + "Id": "Thermal", + "Fans": [ + { + "@odata.id": "/redfish/v1/Chassis/1/Thermal#Fans/0", + "MemberId": "0", + "Name": "Fan 1", + "Oem": { + "Hpe": { + "@odata.context": "/redfish/v1/$metadata#HpeServerFan.HpeServerFan", + "@odata.type": "#HpeServerFan.v2_0_0.HpeServerFan", + "HotPluggable": true, + "Location": "System", + "Redundant": true + } + }, + "Reading": 23, + "ReadingUnits": "Percent", + "Status": { + "Health": "OK", + "State": "Enabled" + } + }, + { + "@odata.id": "/redfish/v1/Chassis/1/Thermal#Fans/1", + "MemberId": "1", + "Name": "Fan 2", + "Oem": { + "Hpe": { + "@odata.context": "/redfish/v1/$metadata#HpeServerFan.HpeServerFan", + "@odata.type": "#HpeServerFan.v2_0_0.HpeServerFan", + "HotPluggable": true, + "Location": "System", + "Redundant": true + } + }, + "Reading": 23, + "ReadingUnits": "Percent", + "Status": { + "Health": "OK", + "State": "Enabled" + } + }, + { + "@odata.id": "/redfish/v1/Chassis/1/Thermal#Fans/2", + "MemberId": "2", + "Name": "Fan 3", + "Oem": { + "Hpe": { + "@odata.context": "/redfish/v1/$metadata#HpeServerFan.HpeServerFan", + "@odata.type": "#HpeServerFan.v2_0_0.HpeServerFan", + "HotPluggable": true, + "Location": "System", + "Redundant": true + } + }, + "Reading": 23, + "ReadingUnits": "Percent", + "Status": { + "Health": "OK", + "State": "Enabled" + } + } + ], + "Name": "Thermal", + "Temperatures": [ + { + "@odata.id": "/redfish/v1/Chassis/1/Thermal#Temperatures/0", + "MemberId": "0", + "Name": "01-Inlet Ambient", + "Oem": { + "Hpe": { + "@odata.context": "/redfish/v1/$metadata#HpeSeaOfSensors.HpeSeaOfSensors", + "@odata.type": "#HpeSeaOfSensors.v2_0_0.HpeSeaOfSensors", + "LocationXmm": 15, + "LocationYmm": 0 + } + }, + "PhysicalContext": "Intake", + "ReadingCelsius": 19, + "SensorNumber": 1, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": 42, + "UpperThresholdFatal": 47 + }, + { + "@odata.id": "/redfish/v1/Chassis/1/Thermal#Temperatures/42", + "MemberId": "42", + "Name": "44-P/S 2 Zone", + "Oem": { + "Hpe": { + "@odata.context": "/redfish/v1/$metadata#HpeSeaOfSensors.HpeSeaOfSensors", + "@odata.type": "#HpeSeaOfSensors.v2_0_0.HpeSeaOfSensors", + "LocationXmm": 4, + "LocationYmm": 7 + } + }, + "PhysicalContext": "PowerSupply", + "ReadingCelsius": 34, + "SensorNumber": 43, + "Status": { + "Health": "OK", + "State": "Enabled" + }, + "UpperThresholdCritical": 75, + "UpperThresholdFatal": 80 + } + ] +} +{ From 0045edde692cb7bb4121f028edb9423d8bc3b759 Mon Sep 17 00:00:00 2001 From: sarvanikonda <61405486+sarvanikonda@users.noreply.github.com> Date: Tue, 25 Feb 2020 01:14:56 -0800 Subject: [PATCH 02/12] Update redfish_test.go --- plugins/inputs/redfish/redfish_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/inputs/redfish/redfish_test.go b/plugins/inputs/redfish/redfish_test.go index 7fba0111885a1..3d5c6042087e1 100644 --- a/plugins/inputs/redfish/redfish_test.go +++ b/plugins/inputs/redfish/redfish_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/assert" ) -func TestThermal(t *testing.T) { +func TestApis(t *testing.T) { ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { From 75f5ba03facee47524b144d039ba0fc3b07a1ce3 Mon Sep 17 00:00:00 2001 From: admin account Date: Tue, 25 Feb 2020 09:39:47 +0000 Subject: [PATCH 03/12] Did make check Signed-off-by: admin account --- plugins/inputs/redfish/redfish.go | 519 +++++---- plugins/inputs/redfish/redfish_test.go | 1359 ++++++++++++------------ 2 files changed, 930 insertions(+), 948 deletions(-) diff --git a/plugins/inputs/redfish/redfish.go b/plugins/inputs/redfish/redfish.go index 2c7862b2b331b..520251b93a914 100644 --- a/plugins/inputs/redfish/redfish.go +++ b/plugins/inputs/redfish/redfish.go @@ -1,105 +1,106 @@ package redfish + import ( + "crypto/tls" + "encoding/base64" + "encoding/json" + "fmt" "github.com/influxdata/telegraf" - "github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/internal" + "github.com/influxdata/telegraf/plugins/inputs" "github.com/influxdata/telegraf/plugins/parsers" - "fmt" - "net/http" "io/ioutil" - "encoding/base64" - "crypto/tls" - "encoding/json" + "net/http" "strconv" ) -type Redfish struct{ - Host string `toml:"host"` - BasicAuthUsername string `toml:"basicauthusername"` - BasicAuthPassword string `toml:"basicauthpassword"` - Id string `toml:"id"` - Server string `toml:"server"` - parser parsers.Parser `toml:"parser"` - Timeout internal.Duration `toml:"timeout"` + +type Redfish struct { + Host string `toml:"host"` + BasicAuthUsername string `toml:"basicauthusername"` + BasicAuthPassword string `toml:"basicauthpassword"` + Id string `toml:"id"` + Server string `toml:"server"` + parser parsers.Parser `toml:"parser"` + Timeout internal.Duration `toml:"timeout"` } type Hostname struct { - Hostname string `json:"HostName"` + Hostname string `json:"HostName"` } type Cpu struct { - Name string `json:"Name"` - Temperature int64 `json:"ReadingCelsius"` - Status CpuStatus `json:"Status"` + Name string `json:"Name"` + Temperature int64 `json:"ReadingCelsius"` + Status CpuStatus `json:"Status"` } type Temperatures struct { - Temperatures []Cpu `json:"Temperatures"` + Temperatures []Cpu `json:"Temperatures"` } type CpuStatus struct { - State string `json:"State"` - Health string `json:"Health"` + State string `json:"State"` + Health string `json:"Health"` } type Fans struct { - Fans []speed `json:"Fans"` + Fans []speed `json:"Fans"` } type speed struct { - Name string `json:"Name"` - Speed int64 `json:"Reading"` - Status FansStatus `json:"Status"` + Name string `json:"Name"` + Speed int64 `json:"Reading"` + Status FansStatus `json:"Status"` } type FansStatus struct { - State string `json:"State"` - Health string `json:"Health"` + State string `json:"State"` + Health string `json:"Health"` } type PowerSupplies struct { - PowerSupplies []watt `json:"PowerSupplies"` + PowerSupplies []watt `json:"PowerSupplies"` } type PowerSupplieshp struct { - PowerSupplieshp []watthp `json:"PowerSupplies"` + PowerSupplieshp []watthp `json:"PowerSupplies"` } type watt struct { - Name string `json:"Name"` - PowerInputWatts float64 `json:"PowerInputWatts"` - PowerCapacityWatts float64 `json:"PowerCapacityWatts"` - PowerOutputWatts float64 `json:"PowerOutputWatts"` - Status PowerStatus `json:"Status"` + Name string `json:"Name"` + PowerInputWatts float64 `json:"PowerInputWatts"` + PowerCapacityWatts float64 `json:"PowerCapacityWatts"` + PowerOutputWatts float64 `json:"PowerOutputWatts"` + Status PowerStatus `json:"Status"` } -type watthp struct{ - Name string `json:"Name"` - MemberId string `json:"MemberId"` - PowerCapacityWatts float64 `json:"PowerCapacityWatts"` - LastPowerOutputWatts float64 `json:"LastPowerOutputWatts"` - LineInputVoltage float64 `json:"LineInputVoltage"` +type watthp struct { + Name string `json:"Name"` + MemberId string `json:"MemberId"` + PowerCapacityWatts float64 `json:"PowerCapacityWatts"` + LastPowerOutputWatts float64 `json:"LastPowerOutputWatts"` + LineInputVoltage float64 `json:"LineInputVoltage"` } type PowerStatus struct { - State string `json:"State"` - Health string `json:"Health"` + State string `json:"State"` + Health string `json:"Health"` } type Voltages struct { - Voltages []volt `json:"Voltages"` + Voltages []volt `json:"Voltages"` } -type volt struct{ - Name string `json:"Name"` - ReadingVolts int64 `json:"ReadingVolts"` - Status VoltStatus `json:"Status"` +type volt struct { + Name string `json:"Name"` + ReadingVolts int64 `json:"ReadingVolts"` + Status VoltStatus `json:"Status"` } type VoltStatus struct { - State string `json:"State"` - Health string `json:"Health"` + State string `json:"State"` + Health string `json:"Health"` } -type Location struct{ - Location Address `json:"Location"` +type Location struct { + Location Address `json:"Location"` } -type Address struct{ - PostalAddress PostalAddress `json:"PostalAddress"` - Placement Placement `json:"Placement"` +type Address struct { + PostalAddress PostalAddress `json:"PostalAddress"` + Placement Placement `json:"Placement"` } -type PostalAddress struct{ - DataCenter string `json:"Building"` - Room string `json:"Room"` - } -type Placement struct{ - Rack string `json:"Rack"` - Row string `json:"Row"` +type PostalAddress struct { + DataCenter string `json:"Building"` + Room string `json:"Room"` +} +type Placement struct { + Rack string `json:"Rack"` + Row string `json:"Row"` } - var h Hostname var t Temperatures @@ -110,138 +111,136 @@ var php PowerSupplieshp var l Location func basicAuth(username, password string) string { - auth := username + ":" + password - return base64.StdEncoding.EncodeToString([]byte(auth)) + auth := username + ":" + password + return base64.StdEncoding.EncodeToString([]byte(auth)) } -func getThermal(host,username,password,id string) (error){ - r := fmt.Sprint(host,"/redfish/v1/Chassis/",id,"/Thermal") - client := &http.Client{} - http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} - req, err := http.NewRequest("GET", r, nil) - req.Header.Add("Authorization","Basic "+ basicAuth(username,password)) - req.Header.Set("Accept","application/json") - req.Header.Set("Content-Type", "application/json") - resp, err := client.Do(req) - if err != nil{ - return err - } - if resp.StatusCode == 200 { - body, _ := ioutil.ReadAll(resp.Body) - jsonErr := json.Unmarshal(body,&t) - if jsonErr != nil { - return fmt.Errorf("error parsing input: %v", jsonErr) - } - jsonErr = json.Unmarshal(body,&f) - if jsonErr != nil { - return fmt.Errorf("error parsing input: %v", jsonErr) - } - }else { - return fmt.Errorf("received status code %d (%s), expected 200", +func getThermal(host, username, password, id string) error { + r := fmt.Sprint(host, "/redfish/v1/Chassis/", id, "/Thermal") + client := &http.Client{} + http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + req, err := http.NewRequest("GET", r, nil) + req.Header.Add("Authorization", "Basic "+basicAuth(username, password)) + req.Header.Set("Accept", "application/json") + req.Header.Set("Content-Type", "application/json") + resp, err := client.Do(req) + if err != nil { + return err + } + if resp.StatusCode == 200 { + body, _ := ioutil.ReadAll(resp.Body) + jsonErr := json.Unmarshal(body, &t) + if jsonErr != nil { + return fmt.Errorf("error parsing input: %v", jsonErr) + } + jsonErr = json.Unmarshal(body, &f) + if jsonErr != nil { + return fmt.Errorf("error parsing input: %v", jsonErr) + } + } else { + return fmt.Errorf("received status code %d (%s), expected 200", resp.StatusCode, http.StatusText(resp.StatusCode)) - } - return nil + } + return nil } -func getPower(host,username,password,id,server string)(error){ - r := fmt.Sprint(host,"/redfish/v1/Chassis/",id,"/Power") - client := &http.Client{} - http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} - req, err := http.NewRequest("GET", r, nil) - req.Header.Add("Authorization","Basic "+ basicAuth(username,password)) - req.Header.Set("Accept","application/json") - req.Header.Set("Content-Type", "application/json") - resp, err := client.Do(req) - if err != nil{ - return err - } - if resp.StatusCode == 200 { - body, _ := ioutil.ReadAll(resp.Body) - if server == "dell"{ - jsonErr := json.Unmarshal(body,&p) - if jsonErr != nil { - return fmt.Errorf("error parsing input: %v", jsonErr) - } - jsonErr = json.Unmarshal(body,&v) - if jsonErr != nil { - return fmt.Errorf("error parsing input: %v", jsonErr) - } - } - if server == "hp"{ - jsonErr := json.Unmarshal(body,&php) - if jsonErr != nil { - return fmt.Errorf("error parsing input: %v", jsonErr) - } +func getPower(host, username, password, id, server string) error { + r := fmt.Sprint(host, "/redfish/v1/Chassis/", id, "/Power") + client := &http.Client{} + http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + req, err := http.NewRequest("GET", r, nil) + req.Header.Add("Authorization", "Basic "+basicAuth(username, password)) + req.Header.Set("Accept", "application/json") + req.Header.Set("Content-Type", "application/json") + resp, err := client.Do(req) + if err != nil { + return err + } + if resp.StatusCode == 200 { + body, _ := ioutil.ReadAll(resp.Body) + if server == "dell" { + jsonErr := json.Unmarshal(body, &p) + if jsonErr != nil { + return fmt.Errorf("error parsing input: %v", jsonErr) + } + jsonErr = json.Unmarshal(body, &v) + if jsonErr != nil { + return fmt.Errorf("error parsing input: %v", jsonErr) + } } - return nil - }else { - return fmt.Errorf("received status code %d (%s), expected 200", - resp.StatusCode, - http.StatusText(resp.StatusCode)) + if server == "hp" { + jsonErr := json.Unmarshal(body, &php) + if jsonErr != nil { + return fmt.Errorf("error parsing input: %v", jsonErr) + } } + return nil + } else { + return fmt.Errorf("received status code %d (%s), expected 200", + resp.StatusCode, + http.StatusText(resp.StatusCode)) + } } -func getHostname(host,username,password,id string) (error){ - url := fmt.Sprint(host,"/redfish/v1/Systems/",id) - client := &http.Client{} - http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} - req, err := http.NewRequest("GET", url, nil) - req.Header.Add("Authorization","Basic "+ basicAuth(username,password)) - req.Header.Set("Accept","*/*") - req.Header.Set("Content-Type", "application/json") - resp, err := client.Do(req) - if err != nil{ - return err - } +func getHostname(host, username, password, id string) error { + url := fmt.Sprint(host, "/redfish/v1/Systems/", id) + client := &http.Client{} + http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + req, err := http.NewRequest("GET", url, nil) + req.Header.Add("Authorization", "Basic "+basicAuth(username, password)) + req.Header.Set("Accept", "*/*") + req.Header.Set("Content-Type", "application/json") + resp, err := client.Do(req) + if err != nil { + return err + } if resp.StatusCode == 200 { - body, _ := ioutil.ReadAll(resp.Body) - jsonErr := json.Unmarshal(body,&h) - if jsonErr != nil { - return fmt.Errorf("error parsing input: %v", jsonErr) - } + body, _ := ioutil.ReadAll(resp.Body) + jsonErr := json.Unmarshal(body, &h) + if jsonErr != nil { + return fmt.Errorf("error parsing input: %v", jsonErr) + } } else { - return fmt.Errorf("received status code %d (%s), expected 200", - resp.StatusCode, - http.StatusText(resp.StatusCode)) - } - return nil + return fmt.Errorf("received status code %d (%s), expected 200", + resp.StatusCode, + http.StatusText(resp.StatusCode)) + } + return nil } -func getLocation(host,Username,password,id string)(error){ - r := fmt.Sprint(host,"/redfish/v1/Chassis/",id,"/") - client := &http.Client{} - http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} - req, err := http.NewRequest("GET", r, nil) - req.Header.Add("Authorization","Basic "+ basicAuth(Username,password)) - req.Header.Set("Accept","application/json") - req.Header.Set("Content-Type", "application/json") - resp, err := client.Do(req) - if err != nil{ - return err - } - if resp.StatusCode == 200 { - body, _ := ioutil.ReadAll(resp.Body) - jsonErr := json.Unmarshal(body,&l) - if jsonErr != nil { - return fmt.Errorf("error parsing input: %v", jsonErr) - } - } else { - return fmt.Errorf("received status code %d (%s), expected 200", - resp.StatusCode, - http.StatusText(resp.StatusCode)) - } +func getLocation(host, Username, password, id string) error { + r := fmt.Sprint(host, "/redfish/v1/Chassis/", id, "/") + client := &http.Client{} + http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} + req, err := http.NewRequest("GET", r, nil) + req.Header.Add("Authorization", "Basic "+basicAuth(Username, password)) + req.Header.Set("Accept", "application/json") + req.Header.Set("Content-Type", "application/json") + resp, err := client.Do(req) + if err != nil { + return err + } + if resp.StatusCode == 200 { + body, _ := ioutil.ReadAll(resp.Body) + jsonErr := json.Unmarshal(body, &l) + if jsonErr != nil { + return fmt.Errorf("error parsing input: %v", jsonErr) + } + } else { + return fmt.Errorf("received status code %d (%s), expected 200", + resp.StatusCode, + http.StatusText(resp.StatusCode)) + } - return nil + return nil } - - func (r *Redfish) Description() string { - return "Read CPU, Fans, Powersupply and Voltage metrics of Dell/HP hardware server through redfish APIs" + return "Read CPU, Fans, Powersupply and Voltage metrics of Dell/HP hardware server through redfish APIs" } -var redfishConfig =` +var redfishConfig = ` ## Server OOB-IP host = "https://192.0.0.1" @@ -256,139 +255,137 @@ id="System.Embedded.1" ## Amount of time allowed to complete the HTTP request # timeout = "5s" ` + func (r *Redfish) SampleConfig() string { - return redfishConfig + return redfishConfig } - func (r *Redfish) SetParser(parser parsers.Parser) { - r.parser = parser + r.parser = parser } - func (r *Redfish) Init() error { - return nil + return nil } func (r *Redfish) Gather(acc telegraf.Accumulator) error { - if len(r.Host) > 0 && len(r.BasicAuthUsername) > 0 && len(r.BasicAuthPassword) > 0 && len(r.Server) > 0 && len(r.Id) > 0 && (r.Server == "dell" || r.Server == "hp"){ - err := getThermal(r.Host,r.BasicAuthUsername,r.BasicAuthPassword,r.Id) + if len(r.Host) > 0 && len(r.BasicAuthUsername) > 0 && len(r.BasicAuthPassword) > 0 && len(r.Server) > 0 && len(r.Id) > 0 && (r.Server == "dell" || r.Server == "hp") { + err := getThermal(r.Host, r.BasicAuthUsername, r.BasicAuthPassword, r.Id) + if err != nil { + return err + } + err = getHostname(r.Host, r.BasicAuthUsername, r.BasicAuthPassword, r.Id) if err != nil { return err } - err = getHostname(r.Host,r.BasicAuthUsername,r.BasicAuthPassword,r.Id) - if err != nil { - return err - } - - err = getPower(r.Host,r.BasicAuthUsername,r.BasicAuthPassword,r.Id,r.Server) - if err != nil { - return err - } + err = getPower(r.Host, r.BasicAuthUsername, r.BasicAuthPassword, r.Id, r.Server) + if err != nil { + return err + } if r.Server == "dell" { - err = getLocation(r.Host,r.BasicAuthUsername,r.BasicAuthPassword,r.Id) - if err != nil { - return err - } + err = getLocation(r.Host, r.BasicAuthUsername, r.BasicAuthPassword, r.Id) + if err != nil { + return err + } } for i := 0; i < len(t.Temperatures); i++ { // Tags -// tags := map[string]string{"Name": t.Temperatures[i].Name} - tags := map[string]string{"OOBIP": r.Host,"Name": t.Temperatures[i].Name,"Hostname": h.Hostname,} + // tags := map[string]string{"Name": t.Temperatures[i].Name} + tags := map[string]string{"OOBIP": r.Host, "Name": t.Temperatures[i].Name, "Hostname": h.Hostname} // Fields fields := make(map[string]interface{}) - fields["Temperature"] = strconv.FormatInt(t.Temperatures[i].Temperature,10) + fields["Temperature"] = strconv.FormatInt(t.Temperatures[i].Temperature, 10) fields["State"] = t.Temperatures[i].Status.State fields["Health"] = t.Temperatures[i].Status.Health - if r.Server == "dell"{ + if r.Server == "dell" { fields["Datacenter"] = l.Location.PostalAddress.DataCenter fields["Room"] = l.Location.PostalAddress.Room fields["Rack"] = l.Location.Placement.Rack fields["Row"] = l.Location.Placement.Row acc.AddFields("cputemperature", fields, tags) } - if r.Server == "hp"{ - acc.AddFields("cputemperature", fields, tags) + if r.Server == "hp" { + acc.AddFields("cputemperature", fields, tags) } } - for i := 0; i < len(f.Fans); i++ { - // Tags - tags := map[string]string{"OOBIP": r.Host,"Name": f.Fans[i].Name,"Hostname": h.Hostname} - // Fields - fields := make(map[string]interface{}) - fields["Fanspeed"] = strconv.FormatInt(f.Fans[i].Speed,10) - fields["State"] = f.Fans[i].Status.State - fields["Health"] = f.Fans[i].Status.Health - if r.Server == "dell" { - fields["Datacenter"] = l.Location.PostalAddress.DataCenter - fields["Room"] = l.Location.PostalAddress.Room - fields["Rack"] = l.Location.Placement.Rack - fields["Row"] = l.Location.Placement.Row - acc.AddFields("fans", fields, tags) - } - if r.Server == "hp" { - acc.AddFields("fans", fields, tags) + for i := 0; i < len(f.Fans); i++ { + // Tags + tags := map[string]string{"OOBIP": r.Host, "Name": f.Fans[i].Name, "Hostname": h.Hostname} + // Fields + fields := make(map[string]interface{}) + fields["Fanspeed"] = strconv.FormatInt(f.Fans[i].Speed, 10) + fields["State"] = f.Fans[i].Status.State + fields["Health"] = f.Fans[i].Status.Health + if r.Server == "dell" { + fields["Datacenter"] = l.Location.PostalAddress.DataCenter + fields["Room"] = l.Location.PostalAddress.Room + fields["Rack"] = l.Location.Placement.Rack + fields["Row"] = l.Location.Placement.Row + acc.AddFields("fans", fields, tags) + } + if r.Server == "hp" { + acc.AddFields("fans", fields, tags) } } if r.Server == "dell" { - for i := 0; i < len(p.PowerSupplies); i++ { - // Tags - tags := map[string]string{"OOBIP": r.Host,"Name": p.PowerSupplies[i].Name,"Hostname": h.Hostname} - // Fields - fields := make(map[string]interface{}) - fields["PowerInputWatts"] = strconv.FormatFloat(p.PowerSupplies[i].PowerInputWatts,'f',-1,64) - fields["PowerCapacityWatts"] = strconv.FormatFloat(p.PowerSupplies[i].PowerCapacityWatts,'f',-1,64) - fields["PowerOutputWatts"] = strconv.FormatFloat(p.PowerSupplies[i].PowerOutputWatts,'f',-1,64) - fields["State"] = p.PowerSupplies[i].Status.State - fields["Health"] = p.PowerSupplies[i].Status.Health - fields["Datacenter"] = l.Location.PostalAddress.DataCenter - fields["Room"] = l.Location.PostalAddress.Room - fields["Rack"] = l.Location.Placement.Rack - fields["Row"] = l.Location.Placement.Row - acc.AddFields("powersupply", fields, tags) + for i := 0; i < len(p.PowerSupplies); i++ { + // Tags + tags := map[string]string{"OOBIP": r.Host, "Name": p.PowerSupplies[i].Name, "Hostname": h.Hostname} + // Fields + fields := make(map[string]interface{}) + fields["PowerInputWatts"] = strconv.FormatFloat(p.PowerSupplies[i].PowerInputWatts, 'f', -1, 64) + fields["PowerCapacityWatts"] = strconv.FormatFloat(p.PowerSupplies[i].PowerCapacityWatts, 'f', -1, 64) + fields["PowerOutputWatts"] = strconv.FormatFloat(p.PowerSupplies[i].PowerOutputWatts, 'f', -1, 64) + fields["State"] = p.PowerSupplies[i].Status.State + fields["Health"] = p.PowerSupplies[i].Status.Health + fields["Datacenter"] = l.Location.PostalAddress.DataCenter + fields["Room"] = l.Location.PostalAddress.Room + fields["Rack"] = l.Location.Placement.Rack + fields["Row"] = l.Location.Placement.Row + acc.AddFields("powersupply", fields, tags) + } + } + if r.Server == "hp" { + for i := 0; i < len(php.PowerSupplieshp); i++ { + // Tags + tags := map[string]string{"OOBIP": r.Host, "Name": php.PowerSupplieshp[i].Name, "MemberId": php.PowerSupplieshp[i].MemberId, "Hostname": h.Hostname} + // Fields + fields := make(map[string]interface{}) + fields["LineInputVoltage"] = strconv.FormatFloat(php.PowerSupplieshp[i].LineInputVoltage, 'f', -1, 64) + fields["PowerCapacityWatts"] = strconv.FormatFloat(php.PowerSupplieshp[i].PowerCapacityWatts, 'f', -1, 64) + fields["LastPowerOutputWatts"] = strconv.FormatFloat(php.PowerSupplieshp[i].LastPowerOutputWatts, 'f', -1, 64) + acc.AddFields("powersupply", fields, tags) } } - if r.Server == "hp" { - for i := 0; i < len(php.PowerSupplieshp); i++ { - // Tags - tags := map[string]string{"OOBIP": r.Host,"Name": php.PowerSupplieshp[i].Name,"MemberId" : php.PowerSupplieshp[i].MemberId,"Hostname": h.Hostname} - // Fields - fields := make(map[string]interface{}) - fields["LineInputVoltage"] = strconv.FormatFloat(php.PowerSupplieshp[i].LineInputVoltage,'f',-1,64) - fields["PowerCapacityWatts"] = strconv.FormatFloat(php.PowerSupplieshp[i].PowerCapacityWatts,'f',-1,64) - fields["LastPowerOutputWatts"] = strconv.FormatFloat(php.PowerSupplieshp[i].LastPowerOutputWatts,'f',-1,64) - acc.AddFields("powersupply", fields, tags) - } - } if r.Server == "dell" { - for i := 0; i < len(v.Voltages); i++ { - // Tags - tags := map[string]string{"OOBIP": r.Host,"Name": v.Voltages[i].Name,"Hostname": h.Hostname} - // Fields - fields := make(map[string]interface{}) - fields["Voltage"] = strconv.FormatInt(v.Voltages[i].ReadingVolts,10) - fields["State"] = v.Voltages[i].Status.State - fields["Health"] = v.Voltages[i].Status.Health - fields["Datacenter"] = l.Location.PostalAddress.DataCenter - fields["Room"] = l.Location.PostalAddress.Room - fields["Rack"] = l.Location.Placement.Rack - fields["Row"] = l.Location.Placement.Row - acc.AddFields("voltages", fields, tags) + for i := 0; i < len(v.Voltages); i++ { + // Tags + tags := map[string]string{"OOBIP": r.Host, "Name": v.Voltages[i].Name, "Hostname": h.Hostname} + // Fields + fields := make(map[string]interface{}) + fields["Voltage"] = strconv.FormatInt(v.Voltages[i].ReadingVolts, 10) + fields["State"] = v.Voltages[i].Status.State + fields["Health"] = v.Voltages[i].Status.Health + fields["Datacenter"] = l.Location.PostalAddress.DataCenter + fields["Room"] = l.Location.PostalAddress.Room + fields["Rack"] = l.Location.Placement.Rack + fields["Row"] = l.Location.Placement.Row + acc.AddFields("voltages", fields, tags) } - } + } return nil - }else { + } else { return fmt.Errorf("Did not provide all the mandatory fields in the configuration") - } + } } func init() { - inputs.Add("redfish", func() telegraf.Input { return &Redfish{} }) + inputs.Add("redfish", func() telegraf.Input { return &Redfish{} }) } diff --git a/plugins/inputs/redfish/redfish_test.go b/plugins/inputs/redfish/redfish_test.go index 3d5c6042087e1..281e601e0221d 100644 --- a/plugins/inputs/redfish/redfish_test.go +++ b/plugins/inputs/redfish/redfish_test.go @@ -13,555 +13,552 @@ import ( func TestApis(t *testing.T) { - ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - - if !checkAuth(r, "test", "test") { - http.Error(w, "Unauthorized.", 401) - return - } - - - switch r.URL.Path { - case "/redfish/v1/Chassis/System.Embedded.1/Thermal": - http.ServeFile(w, r, "testdata/dell_thermal.json") - case "/redfish/v1/Chassis/System.Embedded.1/Power": - http.ServeFile(w, r, "testdata/dell_power.json") - case "/redfish/v1/Chassis/System.Embedded.1/": - http.ServeFile(w, r, "testdata/dell_location.json") - case "/redfish/v1/Systems/System.Embedded.1": - http.ServeFile(w, r, "testdata/dell_hostname.json") + ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + + if !checkAuth(r, "test", "test") { + http.Error(w, "Unauthorized.", 401) + return + } + + switch r.URL.Path { + case "/redfish/v1/Chassis/System.Embedded.1/Thermal": + http.ServeFile(w, r, "testdata/dell_thermal.json") + case "/redfish/v1/Chassis/System.Embedded.1/Power": + http.ServeFile(w, r, "testdata/dell_power.json") + case "/redfish/v1/Chassis/System.Embedded.1/": + http.ServeFile(w, r, "testdata/dell_location.json") + case "/redfish/v1/Systems/System.Embedded.1": + http.ServeFile(w, r, "testdata/dell_hostname.json") case "/redfish/v1/Chassis/System.Embedded.2/Thermal": - http.ServeFile(w, r, "testdata/hp_thermal.json") - case "/redfish/v1/Chassis/System.Embedded.2/Power": - http.ServeFile(w, r, "testdata/hp_power.json") - case "/redfish/v1/Systems/System.Embedded.2": - http.ServeFile(w, r, "testdata/hp_hostname.json") - default: - panic("Cannot handle request") - } - })) - - defer ts.Close() + http.ServeFile(w, r, "testdata/hp_thermal.json") + case "/redfish/v1/Chassis/System.Embedded.2/Power": + http.ServeFile(w, r, "testdata/hp_power.json") + case "/redfish/v1/Systems/System.Embedded.2": + http.ServeFile(w, r, "testdata/hp_hostname.json") + default: + panic("Cannot handle request") + } + })) + + defer ts.Close() expected_metrics_hp := []telegraf.Metric{ - testutil.MustMetric( - "cputemperature", - map[string]string{ - "Name": "01-Inlet Ambient", - "Hostname": "tpa-hostname", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Health": "OK", - "State": "Enabled", - "Temperature": "19", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "cputemperature", - map[string]string{ - "Name": "44-P/S 2 Zone", - "Hostname": "tpa-hostname", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Health": "OK", - "State": "Enabled", - "Temperature": "34", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "fans", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "Fan 1", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Fanspeed": "23", - "Health": "OK", - "State": "Enabled", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "fans", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "Fan 2", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Fanspeed": "23", - "Health": "OK", - "State": "Enabled", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "fans", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "Fan 3", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Fanspeed": "23", - "Health": "OK", - "State": "Enabled", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "powersupply", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "HpeServerPowerSupply", - "MemberId": "0", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "PowerCapacityWatts" :"800", - "LineInputVoltage": "205", - "LastPowerOutputWatts": "0", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "powersupply", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "HpeServerPowerSupply", - "MemberId": "1", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "PowerCapacityWatts" :"800", - "LineInputVoltage": "205", - "LastPowerOutputWatts": "90", - }, - time.Unix(0, 0), - ), - } + testutil.MustMetric( + "cputemperature", + map[string]string{ + "Name": "01-Inlet Ambient", + "Hostname": "tpa-hostname", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Health": "OK", + "State": "Enabled", + "Temperature": "19", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "cputemperature", + map[string]string{ + "Name": "44-P/S 2 Zone", + "Hostname": "tpa-hostname", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Health": "OK", + "State": "Enabled", + "Temperature": "34", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "Fan 1", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Fanspeed": "23", + "Health": "OK", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "Fan 2", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Fanspeed": "23", + "Health": "OK", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "Fan 3", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Fanspeed": "23", + "Health": "OK", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "powersupply", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "HpeServerPowerSupply", + "MemberId": "0", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "PowerCapacityWatts": "800", + "LineInputVoltage": "205", + "LastPowerOutputWatts": "0", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "powersupply", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "HpeServerPowerSupply", + "MemberId": "1", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "PowerCapacityWatts": "800", + "LineInputVoltage": "205", + "LastPowerOutputWatts": "90", + }, + time.Unix(0, 0), + ), + } expected_metrics := []telegraf.Metric{ - testutil.MustMetric( - "cputemperature", - map[string]string{ - "Name": "CPU1 Temp", - "Hostname": "tpa-hostname", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - "Temperature": "40", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "fans", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan1A", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "17760", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "fans", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan1B", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "15360", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "fans", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan2A", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "17880", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "fans", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan2B", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "15120", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "fans", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan3A", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "18000", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "fans", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan3B", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "15600", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "fans", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan4A", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "17280", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "fans", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan4B", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "15360", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "fans", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan5A", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "17640", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "fans", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan5B", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "15600", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "fans", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan6A", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "17760", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "fans", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan6B", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "15600", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "fans", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan7A", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "17400", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "fans", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan7B", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "15720", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "fans", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan8A", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "18000", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "fans", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan8B", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "15840", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "powersupply", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "PS1 Status", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - "PowerCapacityWatts" :"750", - "PowerInputWatts": "900", - "PowerOutputWatts": "203", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "voltages", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board DIMM PG", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - "Voltage" :"1", - }, - time.Unix(0, 0), - ), - testutil.MustMetric( - "voltages", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board NDC PG", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - "Voltage" :"1", - }, - time.Unix(0, 0), - ), - - testutil.MustMetric( - "voltages", - map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board PS1 PG FAIL", - "OOBIP": ts.URL, - }, - map[string]interface{}{ - "Datacenter": "", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - "Voltage" :"1", - }, - time.Unix(0, 0), - ), - } + testutil.MustMetric( + "cputemperature", + map[string]string{ + "Name": "CPU1 Temp", + "Hostname": "tpa-hostname", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + "Temperature": "40", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan1A", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "17760", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan1B", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "15360", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan2A", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "17880", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan2B", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "15120", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan3A", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "18000", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan3B", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "15600", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan4A", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "17280", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan4B", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "15360", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan5A", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "17640", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan5B", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "15600", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan6A", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "17760", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan6B", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "15600", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan7A", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "17400", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan7B", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "15720", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan8A", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "18000", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "fans", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board Fan8B", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Fanspeed": "15840", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "powersupply", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "PS1 Status", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + "PowerCapacityWatts": "750", + "PowerInputWatts": "900", + "PowerOutputWatts": "203", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "voltages", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board DIMM PG", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + "Voltage": "1", + }, + time.Unix(0, 0), + ), + testutil.MustMetric( + "voltages", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board NDC PG", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + "Voltage": "1", + }, + time.Unix(0, 0), + ), + + testutil.MustMetric( + "voltages", + map[string]string{ + "Hostname": "tpa-hostname", + "Name": "System Board PS1 PG FAIL", + "OOBIP": ts.URL, + }, + map[string]interface{}{ + "Datacenter": "", + "Health": "OK", + "Rack": "", + "Room": "", + "Row": "", + "State": "Enabled", + "Voltage": "1", + }, + time.Unix(0, 0), + ), + } plugin := &Redfish{ - Host: ts.URL, + Host: ts.URL, BasicAuthUsername: "test", - BasicAuthPassword: "test", - Id: "System.Embedded.1", - Server: "dell", + BasicAuthPassword: "test", + Id: "System.Embedded.1", + Server: "dell", } - plugin.Init() - var acc testutil.Accumulator + plugin.Init() + var acc testutil.Accumulator - _ = plugin.Gather(&acc) + _ = plugin.Gather(&acc) assert.True(t, acc.HasMeasurement("cputemperature")) testutil.RequireMetricsEqual(t, expected_metrics, acc.GetTelegrafMetrics(), - testutil.IgnoreTime()) - + testutil.IgnoreTime()) hp_plugin := &Redfish{ - Host: ts.URL, + Host: ts.URL, BasicAuthUsername: "test", - BasicAuthPassword: "test", - Id: "System.Embedded.2", - Server: "hp", + BasicAuthPassword: "test", + Id: "System.Embedded.2", + Server: "hp", } - hp_plugin.Init() - var hp_acc testutil.Accumulator + hp_plugin.Init() + var hp_acc testutil.Accumulator - _ = hp_plugin.Gather(&hp_acc) + _ = hp_plugin.Gather(&hp_acc) assert.True(t, hp_acc.HasMeasurement("cputemperature")) testutil.RequireMetricsEqual(t, expected_metrics_hp, hp_acc.GetTelegrafMetrics(), - testutil.IgnoreTime()) + testutil.IgnoreTime()) } - func checkAuth(r *http.Request, username, password string) bool { user, pass, ok := r.BasicAuth() if !ok { @@ -572,13 +569,12 @@ func checkAuth(r *http.Request, username, password string) bool { func TestConnection(t *testing.T) { - r := &Redfish{ - Host: "https://127.0.0.1", - BasicAuthUsername: "test", - BasicAuthPassword: "test", - Id: "System.Embedded.1", - Server: "dell", - + r := &Redfish{ + Host: "https://127.0.0.1", + BasicAuthUsername: "test", + BasicAuthPassword: "test", + Id: "System.Embedded.1", + Server: "dell", } var acc testutil.Accumulator @@ -592,7 +588,6 @@ func TestConnection(t *testing.T) { } } - func TestInvalidUsernameorPassword(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -613,12 +608,11 @@ func TestInvalidUsernameorPassword(t *testing.T) { defer ts.Close() r := &Redfish{ - Host: ts.URL, - BasicAuthUsername: "test", - BasicAuthPassword: "test", - Id: "System.Embedded.1", - Server: "dell", - + Host: ts.URL, + BasicAuthUsername: "test", + BasicAuthPassword: "test", + Id: "System.Embedded.1", + Server: "dell", } var acc testutil.Accumulator @@ -628,222 +622,213 @@ func TestInvalidUsernameorPassword(t *testing.T) { } func TestNoUsernameorPasswordConfiguration(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - - if !checkAuth(r, "testing", "testing") { - http.Error(w, "Unauthorized.", 401) - return - } + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - switch r.URL.Path { - case "/redfish/v1/Chassis/System.Embedded.1/Thermal": - http.ServeFile(w, r, "testdata/dell_thermal.json") - default: - panic("Cannot handle request") - } - })) + if !checkAuth(r, "testing", "testing") { + http.Error(w, "Unauthorized.", 401) + return + } - defer ts.Close() + switch r.URL.Path { + case "/redfish/v1/Chassis/System.Embedded.1/Thermal": + http.ServeFile(w, r, "testdata/dell_thermal.json") + default: + panic("Cannot handle request") + } + })) - r := &Redfish{ - Host: ts.URL, - Id: "System.Embedded.1", - Server: "dell", + defer ts.Close() - } + r := &Redfish{ + Host: ts.URL, + Id: "System.Embedded.1", + Server: "dell", + } - var acc testutil.Accumulator - r.Init() - err := r.Gather(&acc) - assert.EqualError(t, err, "Did not provide all the mandatory fields in the configuration") + var acc testutil.Accumulator + r.Init() + err := r.Gather(&acc) + assert.EqualError(t, err, "Did not provide all the mandatory fields in the configuration") } func TestInvalidServerVarConfiguration(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - - if !checkAuth(r, "test", "test") { - http.Error(w, "Unauthorized.", 401) - return - } + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - switch r.URL.Path { - case "/redfish/v1/Chassis/System.Embedded.1/Thermal": - http.ServeFile(w, r, "testdata/dell_thermal.json") - default: - panic("Cannot handle request") - } - })) + if !checkAuth(r, "test", "test") { + http.Error(w, "Unauthorized.", 401) + return + } - defer ts.Close() + switch r.URL.Path { + case "/redfish/v1/Chassis/System.Embedded.1/Thermal": + http.ServeFile(w, r, "testdata/dell_thermal.json") + default: + panic("Cannot handle request") + } + })) - r := &Redfish{ - Host: ts.URL, - BasicAuthUsername: "test", - BasicAuthPassword: "test", - Id: "System.Embedded.1", - Server: "wtu", + defer ts.Close() - } + r := &Redfish{ + Host: ts.URL, + BasicAuthUsername: "test", + BasicAuthPassword: "test", + Id: "System.Embedded.1", + Server: "wtu", + } - var acc testutil.Accumulator - r.Init() - err := r.Gather(&acc) - assert.EqualError(t, err, "Did not provide all the mandatory fields in the configuration") + var acc testutil.Accumulator + r.Init() + err := r.Gather(&acc) + assert.EqualError(t, err, "Did not provide all the mandatory fields in the configuration") } - func TestInvalidDellJSON(t *testing.T) { - tests := []struct { - name string - thermalfilename string - powerfilename string + tests := []struct { + name string + thermalfilename string + powerfilename string locationfilename string hostnamefilename string }{ { - name: "check Thermal", - thermalfilename: "testdata/dell_thermalinvalid.json", - powerfilename: "testdata/dell_power.json", + name: "check Thermal", + thermalfilename: "testdata/dell_thermalinvalid.json", + powerfilename: "testdata/dell_power.json", locationfilename: "testdata/dell_location.json", hostnamefilename: "testdata/dell_hostname.json", }, { - name: "check Power", - thermalfilename: "testdata/dell_thermal.json", - powerfilename: "testdata/dell_powerinvalid.json", + name: "check Power", + thermalfilename: "testdata/dell_thermal.json", + powerfilename: "testdata/dell_powerinvalid.json", locationfilename: "testdata/dell_location.json", hostnamefilename: "testdata/dell_hostname.json", }, { - name: "check Location", - thermalfilename: "testdata/dell_thermal.json", - powerfilename: "testdata/dell_power.json", + name: "check Location", + thermalfilename: "testdata/dell_thermal.json", + powerfilename: "testdata/dell_power.json", locationfilename: "testdata/dell_locationinvalid.json", hostnamefilename: "testdata/dell_hostname.json", }, { - name: "check Hostname", - thermalfilename: "testdata/dell_thermal.json", - powerfilename: "testdata/dell_power.json", + name: "check Hostname", + thermalfilename: "testdata/dell_thermal.json", + powerfilename: "testdata/dell_power.json", locationfilename: "testdata/dell_location.json", hostnamefilename: "testdata/dell_hostnameinvalid.json", }, } for _, tt := range tests { - ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - - - if !checkAuth(r, "test", "test") { - http.Error(w, "Unauthorized.", 401) - return - } - + ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if !checkAuth(r, "test", "test") { + http.Error(w, "Unauthorized.", 401) + return + } - switch r.URL.Path { - case "/redfish/v1/Chassis/System.Embedded.1/Thermal": - http.ServeFile(w, r, tt.thermalfilename) - case "/redfish/v1/Chassis/System.Embedded.1/Power": - http.ServeFile(w, r, tt.powerfilename) - case "/redfish/v1/Chassis/System.Embedded.1/": - http.ServeFile(w, r, tt.locationfilename) - case "/redfish/v1/Systems/System.Embedded.1": - http.ServeFile(w, r, tt.hostnamefilename) - default: - panic("Cannot handle request") - } - })) + switch r.URL.Path { + case "/redfish/v1/Chassis/System.Embedded.1/Thermal": + http.ServeFile(w, r, tt.thermalfilename) + case "/redfish/v1/Chassis/System.Embedded.1/Power": + http.ServeFile(w, r, tt.powerfilename) + case "/redfish/v1/Chassis/System.Embedded.1/": + http.ServeFile(w, r, tt.locationfilename) + case "/redfish/v1/Systems/System.Embedded.1": + http.ServeFile(w, r, tt.hostnamefilename) + default: + panic("Cannot handle request") + } + })) - defer ts.Close() + defer ts.Close() - plugin := &Redfish{ - Host: ts.URL, + plugin := &Redfish{ + Host: ts.URL, BasicAuthUsername: "test", - BasicAuthPassword: "test", - Id: "System.Embedded.1", - Server: "dell", - } + BasicAuthPassword: "test", + Id: "System.Embedded.1", + Server: "dell", + } - plugin.Init() + plugin.Init() - var acc testutil.Accumulator - err := plugin.Gather(&acc) + var acc testutil.Accumulator + err := plugin.Gather(&acc) - if assert.Error(t, err) { - assert.Contains(t, err.Error(), "error parsing input:") - } + if assert.Error(t, err) { + assert.Contains(t, err.Error(), "error parsing input:") + } } } - func TestInvalidHPJSON(t *testing.T) { - tests := []struct { - name string - thermalfilename string - powerfilename string + tests := []struct { + name string + thermalfilename string + powerfilename string hostnamefilename string }{ { - name: "check Thermal", - thermalfilename: "testdata/hp_thermalinvalid.json", - powerfilename: "testdata/hp_power.json", + name: "check Thermal", + thermalfilename: "testdata/hp_thermalinvalid.json", + powerfilename: "testdata/hp_power.json", hostnamefilename: "testdata/hp_hostname.json", }, { - name: "check Power", - thermalfilename: "testdata/hp_thermal.json", - powerfilename: "testdata/hp_powerinvalid.json", + name: "check Power", + thermalfilename: "testdata/hp_thermal.json", + powerfilename: "testdata/hp_powerinvalid.json", hostnamefilename: "testdata/hp_hostname.json", }, { - name: "check Hostname", - thermalfilename: "testdata/hp_thermal.json", - powerfilename: "testdata/hp_power.json", + name: "check Hostname", + thermalfilename: "testdata/hp_thermal.json", + powerfilename: "testdata/hp_power.json", hostnamefilename: "testdata/hp_hostnameinvalid.json", }, } for _, tt := range tests { - ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if !checkAuth(r, "test", "test") { + http.Error(w, "Unauthorized.", 401) + return + } - if !checkAuth(r, "test", "test" ) { - http.Error(w, "Unauthorized.", 401) - return - } + switch r.URL.Path { + case "/redfish/v1/Chassis/System.Embedded.2/Thermal": + http.ServeFile(w, r, tt.thermalfilename) + case "/redfish/v1/Chassis/System.Embedded.2/Power": + http.ServeFile(w, r, tt.powerfilename) + case "/redfish/v1/Systems/System.Embedded.2": + http.ServeFile(w, r, tt.hostnamefilename) + default: + panic("Cannot handle request") + } + })) + defer ts.Close() - switch r.URL.Path { - case "/redfish/v1/Chassis/System.Embedded.2/Thermal": - http.ServeFile(w, r, tt.thermalfilename) - case "/redfish/v1/Chassis/System.Embedded.2/Power": - http.ServeFile(w, r, tt.powerfilename) - case "/redfish/v1/Systems/System.Embedded.2": - http.ServeFile(w, r, tt.hostnamefilename) - default: - panic("Cannot handle request") - } - })) - - defer ts.Close() - - plugin := &Redfish{ - Host: ts.URL, + plugin := &Redfish{ + Host: ts.URL, BasicAuthUsername: "test", - BasicAuthPassword: "test", - Id: "System.Embedded.2", - Server: "hp", - } + BasicAuthPassword: "test", + Id: "System.Embedded.2", + Server: "hp", + } - plugin.Init() + plugin.Init() - var acc testutil.Accumulator - err := plugin.Gather(&acc) + var acc testutil.Accumulator + err := plugin.Gather(&acc) - if assert.Error(t, err) { - assert.Contains(t, err.Error(), "error parsing input:") - } + if assert.Error(t, err) { + assert.Contains(t, err.Error(), "error parsing input:") + } } } From 8a2178f0743c6223fde079ac13f135d3e73743cb Mon Sep 17 00:00:00 2001 From: sarvanikonda Date: Fri, 28 Feb 2020 09:20:37 +0000 Subject: [PATCH 04/12] added license --- plugins/inputs/redfish/redfish.go | 3 +++ plugins/inputs/redfish/redfish_test.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/plugins/inputs/redfish/redfish.go b/plugins/inputs/redfish/redfish.go index 520251b93a914..863190345e0a7 100644 --- a/plugins/inputs/redfish/redfish.go +++ b/plugins/inputs/redfish/redfish.go @@ -1,3 +1,6 @@ +// Copyright 2020, Verizon +//Licensed under the terms of the MIT License. SEE LICENSE file in project root for terms. + package redfish import ( diff --git a/plugins/inputs/redfish/redfish_test.go b/plugins/inputs/redfish/redfish_test.go index 281e601e0221d..9d7dc92567c2b 100644 --- a/plugins/inputs/redfish/redfish_test.go +++ b/plugins/inputs/redfish/redfish_test.go @@ -1,3 +1,6 @@ +// Copyright 2020, Verizon +//Licensed under the terms of the MIT License. SEE LICENSE file in project root for terms. + package redfish import ( From 3cbf86dec29ee6a525ee81e49a7b64be99ee2d56 Mon Sep 17 00:00:00 2001 From: sarvanikonda Date: Mon, 11 May 2020 19:42:30 +0530 Subject: [PATCH 05/12] optimised redfish plugin code --- plugins/inputs/redfish/redfish.go | 405 +++++------- plugins/inputs/redfish/redfish_test.go | 534 ++++++++-------- .../redfish/testdata/.dell_power.json.swp | Bin 24576 -> 0 bytes telegraf.conf | 591 ++++++++++++++++++ 4 files changed, 1030 insertions(+), 500 deletions(-) delete mode 100644 plugins/inputs/redfish/testdata/.dell_power.json.swp create mode 100644 telegraf.conf diff --git a/plugins/inputs/redfish/redfish.go b/plugins/inputs/redfish/redfish.go index 863190345e0a7..ee566734de392 100644 --- a/plugins/inputs/redfish/redfish.go +++ b/plugins/inputs/redfish/redfish.go @@ -4,28 +4,17 @@ package redfish import ( - "crypto/tls" - "encoding/base64" "encoding/json" "fmt" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/internal" + "github.com/influxdata/telegraf/internal/tls" "github.com/influxdata/telegraf/plugins/inputs" - "github.com/influxdata/telegraf/plugins/parsers" "io/ioutil" "net/http" "strconv" ) -type Redfish struct { - Host string `toml:"host"` - BasicAuthUsername string `toml:"basicauthusername"` - BasicAuthPassword string `toml:"basicauthpassword"` - Id string `toml:"id"` - Server string `toml:"server"` - parser parsers.Parser `toml:"parser"` - Timeout internal.Duration `toml:"timeout"` -} type Hostname struct { Hostname string `json:"HostName"` } @@ -68,7 +57,7 @@ type watt struct { } type watthp struct { Name string `json:"Name"` - MemberId string `json:"MemberId"` + MemberID string `json:"MemberId"` PowerCapacityWatts float64 `json:"PowerCapacityWatts"` LastPowerOutputWatts float64 `json:"LastPowerOutputWatts"` LineInputVoltage float64 `json:"LineInputVoltage"` @@ -104,138 +93,87 @@ type Placement struct { Rack string `json:"Rack"` Row string `json:"Row"` } - -var h Hostname -var t Temperatures -var f Fans -var p PowerSupplies -var v Voltages -var php PowerSupplieshp -var l Location - -func basicAuth(username, password string) string { - auth := username + ":" + password - return base64.StdEncoding.EncodeToString([]byte(auth)) +type Redfish struct { + Host string `toml:"host"` + BasicAuthUsername string `toml:"basicauthusername"` + BasicAuthPassword string `toml:"basicauthpassword"` + Id string `toml:"id"` + Server string `toml:"server"` + client http.Client + tls.ClientConfig + Timeout internal.Duration `toml:"timeout"` + hostname Hostname + temperature Temperatures + fan Fans + powerdell PowerSupplies + voltage Voltages + powerhp PowerSupplieshp + location Location } -func getThermal(host, username, password, id string) error { - r := fmt.Sprint(host, "/redfish/v1/Chassis/", id, "/Thermal") - client := &http.Client{} - http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} - req, err := http.NewRequest("GET", r, nil) - req.Header.Add("Authorization", "Basic "+basicAuth(username, password)) - req.Header.Set("Accept", "application/json") - req.Header.Set("Content-Type", "application/json") - resp, err := client.Do(req) - if err != nil { - return err +func (r *Redfish) getMetrics() error { + url := make(map[string]map[string]interface{}) + url["Thermal"] = make(map[string]interface{}) + url["Power"] = make(map[string]interface{}) + url["Hostname"] = make(map[string]interface{}) + url["Thermal"]["endpoint"] = fmt.Sprint(r.Host, "/redfish/v1/Chassis/", r.Id, "/Thermal") + url["Thermal"]["pointer"] = &r.temperature + url["Thermal"]["fanpointer"] = &r.fan + url["Power"]["endpoint"] = fmt.Sprint(r.Host, "/redfish/v1/Chassis/", r.Id, "/Power") + if r.Server == "dell" { + url["Power"]["pointer"] = &r.powerdell + url["Power"]["voltpointer"] = &r.voltage + } else if r.Server == "hp" { + url["Power"]["pointer"] = &r.powerhp } - if resp.StatusCode == 200 { - body, _ := ioutil.ReadAll(resp.Body) - jsonErr := json.Unmarshal(body, &t) - if jsonErr != nil { - return fmt.Errorf("error parsing input: %v", jsonErr) - } - jsonErr = json.Unmarshal(body, &f) - if jsonErr != nil { - return fmt.Errorf("error parsing input: %v", jsonErr) - } - } else { - return fmt.Errorf("received status code %d (%s), expected 200", - resp.StatusCode, - http.StatusText(resp.StatusCode)) + url["Hostname"]["endpoint"] = fmt.Sprint(r.Host, "/redfish/v1/Systems/", r.Id) + url["Hostname"]["pointer"] = &r.hostname + if r.Server == "dell" { + url["Location"] = make(map[string]interface{}) + url["Location"]["endpoint"] = fmt.Sprint(r.Host, "/redfish/v1/Chassis/", r.Id, "/") + url["Location"]["pointer"] = &r.location } - return nil -} -func getPower(host, username, password, id, server string) error { - r := fmt.Sprint(host, "/redfish/v1/Chassis/", id, "/Power") - client := &http.Client{} - http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} - req, err := http.NewRequest("GET", r, nil) - req.Header.Add("Authorization", "Basic "+basicAuth(username, password)) - req.Header.Set("Accept", "application/json") - req.Header.Set("Content-Type", "application/json") - resp, err := client.Do(req) - if err != nil { - return err - } - if resp.StatusCode == 200 { - body, _ := ioutil.ReadAll(resp.Body) - if server == "dell" { - jsonErr := json.Unmarshal(body, &p) - if jsonErr != nil { - return fmt.Errorf("error parsing input: %v", jsonErr) - } - jsonErr = json.Unmarshal(body, &v) - if jsonErr != nil { - return fmt.Errorf("error parsing input: %v", jsonErr) - } + for key, value := range url { + req, err := http.NewRequest("GET", value["endpoint"].(string), nil) + if err != nil { + return err + } + req.SetBasicAuth(r.BasicAuthUsername, r.BasicAuthPassword) + req.Header.Set("Accept", "application/json") + req.Header.Set("Content-Type", "application/json") + resp, err := r.client.Do(req) + if err != nil { + return err } - if server == "hp" { - jsonErr := json.Unmarshal(body, &php) + if resp.StatusCode == 200 { + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return err + } + jsonErr := json.Unmarshal(body, value["pointer"]) if jsonErr != nil { return fmt.Errorf("error parsing input: %v", jsonErr) } - } - return nil - } else { - return fmt.Errorf("received status code %d (%s), expected 200", - resp.StatusCode, - http.StatusText(resp.StatusCode)) - } -} + if r.Server == "dell" && key == "Power" { + jsonErr = json.Unmarshal(body, value["voltpointer"]) + if jsonErr != nil { + return fmt.Errorf("error parsing input: %v", jsonErr) + } -func getHostname(host, username, password, id string) error { - url := fmt.Sprint(host, "/redfish/v1/Systems/", id) - client := &http.Client{} - http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} - req, err := http.NewRequest("GET", url, nil) - req.Header.Add("Authorization", "Basic "+basicAuth(username, password)) - req.Header.Set("Accept", "*/*") - req.Header.Set("Content-Type", "application/json") - resp, err := client.Do(req) - if err != nil { - return err - } - if resp.StatusCode == 200 { - body, _ := ioutil.ReadAll(resp.Body) - jsonErr := json.Unmarshal(body, &h) - if jsonErr != nil { - return fmt.Errorf("error parsing input: %v", jsonErr) - } - } else { - return fmt.Errorf("received status code %d (%s), expected 200", - resp.StatusCode, - http.StatusText(resp.StatusCode)) - } - return nil -} + } else if key == "Thermal" { + jsonErr = json.Unmarshal(body, value["fanpointer"]) + if jsonErr != nil { + return fmt.Errorf("error parsing input: %v", jsonErr) + } + } -func getLocation(host, Username, password, id string) error { - r := fmt.Sprint(host, "/redfish/v1/Chassis/", id, "/") - client := &http.Client{} - http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true} - req, err := http.NewRequest("GET", r, nil) - req.Header.Add("Authorization", "Basic "+basicAuth(Username, password)) - req.Header.Set("Accept", "application/json") - req.Header.Set("Content-Type", "application/json") - resp, err := client.Do(req) - if err != nil { - return err - } - if resp.StatusCode == 200 { - body, _ := ioutil.ReadAll(resp.Body) - jsonErr := json.Unmarshal(body, &l) - if jsonErr != nil { - return fmt.Errorf("error parsing input: %v", jsonErr) + } else { + return fmt.Errorf("received status code %d (%s), expected 200", + resp.StatusCode, + http.StatusText(resp.StatusCode)) } - } else { - return fmt.Errorf("received status code %d (%s), expected 200", - resp.StatusCode, - http.StatusText(resp.StatusCode)) } - return nil } @@ -254,6 +192,12 @@ basicauthpassword = "test" server= "dell" ## Resource Id for redfish APIs id="System.Embedded.1" +## Optional TLS Config +# tls_ca = "/etc/telegraf/ca.pem" +# tls_cert = "/etc/telegraf/cert.pem" +# tls_key = "/etc/telegraf/key.pem" +## Use TLS but skip chain & host verification +# insecure_skip_verify = false ## Amount of time allowed to complete the HTTP request # timeout = "5s" @@ -263,130 +207,123 @@ func (r *Redfish) SampleConfig() string { return redfishConfig } -func (r *Redfish) SetParser(parser parsers.Parser) { - r.parser = parser -} - func (r *Redfish) Init() error { + tlsCfg, err := r.ClientConfig.TLSConfig() + if err != nil { + return err + } + + r.client = http.Client{ + Transport: &http.Transport{ + TLSClientConfig: tlsCfg, + Proxy: http.ProxyFromEnvironment, + }, + Timeout: r.Timeout.Duration, + } return nil } func (r *Redfish) Gather(acc telegraf.Accumulator) error { - if len(r.Host) > 0 && len(r.BasicAuthUsername) > 0 && len(r.BasicAuthPassword) > 0 && len(r.Server) > 0 && len(r.Id) > 0 && (r.Server == "dell" || r.Server == "hp") { - err := getThermal(r.Host, r.BasicAuthUsername, r.BasicAuthPassword, r.Id) - if err != nil { - return err - } - err = getHostname(r.Host, r.BasicAuthUsername, r.BasicAuthPassword, r.Id) - if err != nil { - return err - } + if len(r.Host) == 0 || len(r.BasicAuthUsername) == 0 || len(r.BasicAuthPassword) == 0 { + return fmt.Errorf("Did not provide IP or username and password") + } + if len(r.Server) == 0 || len(r.Id) == 0 { + return fmt.Errorf("Did not provide all the mandatory fields in the configuration") + } + if !(r.Server == "dell" || r.Server == "hp") { + return fmt.Errorf("Did not provide correct server information, supported server details are dell or hp") + } + err := r.getMetrics() + if err != nil { + return err + } - err = getPower(r.Host, r.BasicAuthUsername, r.BasicAuthPassword, r.Id, r.Server) - if err != nil { - return err + for i := 0; i < len(r.temperature.Temperatures); i++ { + // Tags + tags := map[string]string{"oob_ip": r.Host, "name": r.temperature.Temperatures[i].Name, "hostname": r.hostname.Hostname} + // Fields + fields := make(map[string]interface{}) + fields["temperature"] = strconv.FormatInt(r.temperature.Temperatures[i].Temperature, 10) + fields["state"] = r.temperature.Temperatures[i].Status.State + fields["health"] = r.temperature.Temperatures[i].Status.Health + if r.Server == "dell" { + fields["datacenter"] = r.location.Location.PostalAddress.DataCenter + fields["room"] = r.location.Location.PostalAddress.Room + fields["rack"] = r.location.Location.Placement.Rack + fields["row"] = r.location.Location.Placement.Row + acc.AddFields("cpu_temperature", fields, tags) } - + if r.Server == "hp" { + acc.AddFields("cpu_temperature", fields, tags) + } + } + for i := 0; i < len(r.fan.Fans); i++ { + // Tags + tags := map[string]string{"oob_ip": r.Host, "name": r.fan.Fans[i].Name, "hostname": r.hostname.Hostname} + // Fields + fields := make(map[string]interface{}) + fields["fanspeed"] = strconv.FormatInt(r.fan.Fans[i].Speed, 10) + fields["state"] = r.fan.Fans[i].Status.State + fields["health"] = r.fan.Fans[i].Status.Health if r.Server == "dell" { - err = getLocation(r.Host, r.BasicAuthUsername, r.BasicAuthPassword, r.Id) - if err != nil { - return err - } - + fields["datacenter"] = r.location.Location.PostalAddress.DataCenter + fields["room"] = r.location.Location.PostalAddress.Room + fields["rack"] = r.location.Location.Placement.Rack + fields["row"] = r.location.Location.Placement.Row + acc.AddFields("fans", fields, tags) } - - for i := 0; i < len(t.Temperatures); i++ { + if r.Server == "hp" { + acc.AddFields("fans", fields, tags) + } + } + if r.Server == "dell" { + for i := 0; i < len(r.powerdell.PowerSupplies); i++ { // Tags - // tags := map[string]string{"Name": t.Temperatures[i].Name} - tags := map[string]string{"OOBIP": r.Host, "Name": t.Temperatures[i].Name, "Hostname": h.Hostname} + tags := map[string]string{"oob_ip": r.Host, "name": r.powerdell.PowerSupplies[i].Name, "hostname": r.hostname.Hostname} // Fields fields := make(map[string]interface{}) - fields["Temperature"] = strconv.FormatInt(t.Temperatures[i].Temperature, 10) - fields["State"] = t.Temperatures[i].Status.State - fields["Health"] = t.Temperatures[i].Status.Health - if r.Server == "dell" { - fields["Datacenter"] = l.Location.PostalAddress.DataCenter - fields["Room"] = l.Location.PostalAddress.Room - fields["Rack"] = l.Location.Placement.Rack - fields["Row"] = l.Location.Placement.Row - acc.AddFields("cputemperature", fields, tags) - } - if r.Server == "hp" { - acc.AddFields("cputemperature", fields, tags) - } + fields["power_input_watts"] = strconv.FormatFloat(r.powerdell.PowerSupplies[i].PowerInputWatts, 'f', -1, 64) + fields["power_capacity_watts"] = strconv.FormatFloat(r.powerdell.PowerSupplies[i].PowerCapacityWatts, 'f', -1, 64) + fields["power_output_watts"] = strconv.FormatFloat(r.powerdell.PowerSupplies[i].PowerOutputWatts, 'f', -1, 64) + fields["state"] = r.powerdell.PowerSupplies[i].Status.State + fields["health"] = r.powerdell.PowerSupplies[i].Status.Health + fields["datacenter"] = r.location.Location.PostalAddress.DataCenter + fields["room"] = r.location.Location.PostalAddress.Room + fields["rack"] = r.location.Location.Placement.Rack + fields["row"] = r.location.Location.Placement.Row + acc.AddFields("powersupply", fields, tags) } - for i := 0; i < len(f.Fans); i++ { + for i := 0; i < len(r.voltage.Voltages); i++ { // Tags - tags := map[string]string{"OOBIP": r.Host, "Name": f.Fans[i].Name, "Hostname": h.Hostname} + tags := map[string]string{"oob_ip": r.Host, "name": r.voltage.Voltages[i].Name, "hostname": r.hostname.Hostname} // Fields fields := make(map[string]interface{}) - fields["Fanspeed"] = strconv.FormatInt(f.Fans[i].Speed, 10) - fields["State"] = f.Fans[i].Status.State - fields["Health"] = f.Fans[i].Status.Health - if r.Server == "dell" { - fields["Datacenter"] = l.Location.PostalAddress.DataCenter - fields["Room"] = l.Location.PostalAddress.Room - fields["Rack"] = l.Location.Placement.Rack - fields["Row"] = l.Location.Placement.Row - acc.AddFields("fans", fields, tags) - } - if r.Server == "hp" { - acc.AddFields("fans", fields, tags) - } - } - if r.Server == "dell" { - for i := 0; i < len(p.PowerSupplies); i++ { - // Tags - tags := map[string]string{"OOBIP": r.Host, "Name": p.PowerSupplies[i].Name, "Hostname": h.Hostname} - // Fields - fields := make(map[string]interface{}) - fields["PowerInputWatts"] = strconv.FormatFloat(p.PowerSupplies[i].PowerInputWatts, 'f', -1, 64) - fields["PowerCapacityWatts"] = strconv.FormatFloat(p.PowerSupplies[i].PowerCapacityWatts, 'f', -1, 64) - fields["PowerOutputWatts"] = strconv.FormatFloat(p.PowerSupplies[i].PowerOutputWatts, 'f', -1, 64) - fields["State"] = p.PowerSupplies[i].Status.State - fields["Health"] = p.PowerSupplies[i].Status.Health - fields["Datacenter"] = l.Location.PostalAddress.DataCenter - fields["Room"] = l.Location.PostalAddress.Room - fields["Rack"] = l.Location.Placement.Rack - fields["Row"] = l.Location.Placement.Row - acc.AddFields("powersupply", fields, tags) - } - } - if r.Server == "hp" { - for i := 0; i < len(php.PowerSupplieshp); i++ { - // Tags - tags := map[string]string{"OOBIP": r.Host, "Name": php.PowerSupplieshp[i].Name, "MemberId": php.PowerSupplieshp[i].MemberId, "Hostname": h.Hostname} - // Fields - fields := make(map[string]interface{}) - fields["LineInputVoltage"] = strconv.FormatFloat(php.PowerSupplieshp[i].LineInputVoltage, 'f', -1, 64) - fields["PowerCapacityWatts"] = strconv.FormatFloat(php.PowerSupplieshp[i].PowerCapacityWatts, 'f', -1, 64) - fields["LastPowerOutputWatts"] = strconv.FormatFloat(php.PowerSupplieshp[i].LastPowerOutputWatts, 'f', -1, 64) - acc.AddFields("powersupply", fields, tags) - } + fields["voltage"] = strconv.FormatInt(r.voltage.Voltages[i].ReadingVolts, 10) + fields["state"] = r.voltage.Voltages[i].Status.State + fields["health"] = r.voltage.Voltages[i].Status.Health + fields["datacenter"] = r.location.Location.PostalAddress.DataCenter + fields["room"] = r.location.Location.PostalAddress.Room + fields["rack"] = r.location.Location.Placement.Rack + fields["row"] = r.location.Location.Placement.Row + acc.AddFields("voltages", fields, tags) } - if r.Server == "dell" { - for i := 0; i < len(v.Voltages); i++ { - // Tags - tags := map[string]string{"OOBIP": r.Host, "Name": v.Voltages[i].Name, "Hostname": h.Hostname} - // Fields - fields := make(map[string]interface{}) - fields["Voltage"] = strconv.FormatInt(v.Voltages[i].ReadingVolts, 10) - fields["State"] = v.Voltages[i].Status.State - fields["Health"] = v.Voltages[i].Status.Health - fields["Datacenter"] = l.Location.PostalAddress.DataCenter - fields["Room"] = l.Location.PostalAddress.Room - fields["Rack"] = l.Location.Placement.Rack - fields["Row"] = l.Location.Placement.Row - acc.AddFields("voltages", fields, tags) - } + } + if r.Server == "hp" { + for i := 0; i < len(r.powerhp.PowerSupplieshp); i++ { + // Tags + tags := map[string]string{"oob_ip": r.Host, "name": r.powerhp.PowerSupplieshp[i].Name, "member_id": r.powerhp.PowerSupplieshp[i].MemberID, "hostname": r.hostname.Hostname} + // Fields + fields := make(map[string]interface{}) + fields["line_input_voltage"] = strconv.FormatFloat(r.powerhp.PowerSupplieshp[i].LineInputVoltage, 'f', -1, 64) + fields["power_capacity_watts"] = strconv.FormatFloat(r.powerhp.PowerSupplieshp[i].PowerCapacityWatts, 'f', -1, 64) + fields["last_power_output_watts"] = strconv.FormatFloat(r.powerhp.PowerSupplieshp[i].LastPowerOutputWatts, 'f', -1, 64) + acc.AddFields("powersupply", fields, tags) } - return nil - } else { - return fmt.Errorf("Did not provide all the mandatory fields in the configuration") } + return nil } func init() { diff --git a/plugins/inputs/redfish/redfish_test.go b/plugins/inputs/redfish/redfish_test.go index 9d7dc92567c2b..c78b91ab4c5de 100644 --- a/plugins/inputs/redfish/redfish_test.go +++ b/plugins/inputs/redfish/redfish_test.go @@ -16,7 +16,7 @@ import ( func TestApis(t *testing.T) { - ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if !checkAuth(r, "test", "test") { http.Error(w, "Unauthorized.", 401) @@ -47,102 +47,102 @@ func TestApis(t *testing.T) { expected_metrics_hp := []telegraf.Metric{ testutil.MustMetric( - "cputemperature", + "cpu_temperature", map[string]string{ - "Name": "01-Inlet Ambient", - "Hostname": "tpa-hostname", - "OOBIP": ts.URL, + "name": "01-Inlet Ambient", + "hostname": "tpa-hostname", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Health": "OK", - "State": "Enabled", - "Temperature": "19", + "health": "OK", + "state": "Enabled", + "temperature": "19", }, time.Unix(0, 0), ), testutil.MustMetric( - "cputemperature", + "cpu_temperature", map[string]string{ - "Name": "44-P/S 2 Zone", - "Hostname": "tpa-hostname", - "OOBIP": ts.URL, + "name": "44-P/S 2 Zone", + "hostname": "tpa-hostname", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Health": "OK", - "State": "Enabled", - "Temperature": "34", + "health": "OK", + "state": "Enabled", + "temperature": "34", }, time.Unix(0, 0), ), testutil.MustMetric( "fans", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "Fan 1", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "Fan 1", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Fanspeed": "23", - "Health": "OK", - "State": "Enabled", + "fanspeed": "23", + "health": "OK", + "state": "Enabled", }, time.Unix(0, 0), ), testutil.MustMetric( "fans", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "Fan 2", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "Fan 2", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Fanspeed": "23", - "Health": "OK", - "State": "Enabled", + "fanspeed": "23", + "health": "OK", + "state": "Enabled", }, time.Unix(0, 0), ), testutil.MustMetric( "fans", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "Fan 3", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "Fan 3", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Fanspeed": "23", - "Health": "OK", - "State": "Enabled", + "fanspeed": "23", + "health": "OK", + "state": "Enabled", }, time.Unix(0, 0), ), testutil.MustMetric( "powersupply", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "HpeServerPowerSupply", - "MemberId": "0", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "HpeServerPowerSupply", + "member_id": "0", + "oob_ip": ts.URL, }, map[string]interface{}{ - "PowerCapacityWatts": "800", - "LineInputVoltage": "205", - "LastPowerOutputWatts": "0", + "power_capacity_watts": "800", + "line_input_voltage": "205", + "last_power_output_watts": "0", }, time.Unix(0, 0), ), testutil.MustMetric( "powersupply", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "HpeServerPowerSupply", - "MemberId": "1", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "HpeServerPowerSupply", + "member_id": "1", + "oob_ip": ts.URL, }, map[string]interface{}{ - "PowerCapacityWatts": "800", - "LineInputVoltage": "205", - "LastPowerOutputWatts": "90", + "power_capacity_watts": "800", + "line_input_voltage": "205", + "last_power_output_watts": "90", }, time.Unix(0, 0), ), @@ -150,364 +150,364 @@ func TestApis(t *testing.T) { expected_metrics := []telegraf.Metric{ testutil.MustMetric( - "cputemperature", + "cpu_temperature", map[string]string{ - "Name": "CPU1 Temp", - "Hostname": "tpa-hostname", - "OOBIP": ts.URL, + "name": "CPU1 Temp", + "hostname": "tpa-hostname", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - "Temperature": "40", + "datacenter": "", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", + "temperature": "40", }, time.Unix(0, 0), ), testutil.MustMetric( "fans", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan1A", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "System Board Fan1A", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "17760", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", + "datacenter": "", + "fanspeed": "17760", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", }, time.Unix(0, 0), ), testutil.MustMetric( "fans", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan1B", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "System Board Fan1B", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "15360", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", + "datacenter": "", + "fanspeed": "15360", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", }, time.Unix(0, 0), ), testutil.MustMetric( "fans", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan2A", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "System Board Fan2A", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "17880", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", + "datacenter": "", + "fanspeed": "17880", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", }, time.Unix(0, 0), ), testutil.MustMetric( "fans", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan2B", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "System Board Fan2B", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "15120", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", + "datacenter": "", + "fanspeed": "15120", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", }, time.Unix(0, 0), ), testutil.MustMetric( "fans", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan3A", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "System Board Fan3A", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "18000", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", + "datacenter": "", + "fanspeed": "18000", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", }, time.Unix(0, 0), ), testutil.MustMetric( "fans", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan3B", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "System Board Fan3B", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "15600", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", + "datacenter": "", + "fanspeed": "15600", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", }, time.Unix(0, 0), ), testutil.MustMetric( "fans", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan4A", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "System Board Fan4A", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "17280", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", + "datacenter": "", + "fanspeed": "17280", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", }, time.Unix(0, 0), ), testutil.MustMetric( "fans", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan4B", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "System Board Fan4B", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "15360", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", + "datacenter": "", + "fanspeed": "15360", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", }, time.Unix(0, 0), ), testutil.MustMetric( "fans", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan5A", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "System Board Fan5A", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "17640", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", + "datacenter": "", + "fanspeed": "17640", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", }, time.Unix(0, 0), ), testutil.MustMetric( "fans", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan5B", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "System Board Fan5B", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "15600", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", + "datacenter": "", + "fanspeed": "15600", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", }, time.Unix(0, 0), ), testutil.MustMetric( "fans", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan6A", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "System Board Fan6A", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "17760", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", + "datacenter": "", + "fanspeed": "17760", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", }, time.Unix(0, 0), ), testutil.MustMetric( "fans", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan6B", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "System Board Fan6B", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "15600", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", + "datacenter": "", + "fanspeed": "15600", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", }, time.Unix(0, 0), ), testutil.MustMetric( "fans", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan7A", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "System Board Fan7A", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "17400", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", + "datacenter": "", + "fanspeed": "17400", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", }, time.Unix(0, 0), ), testutil.MustMetric( "fans", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan7B", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "System Board Fan7B", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "15720", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", + "datacenter": "", + "fanspeed": "15720", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", }, time.Unix(0, 0), ), testutil.MustMetric( "fans", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan8A", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "System Board Fan8A", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "18000", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", + "datacenter": "", + "fanspeed": "18000", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", }, time.Unix(0, 0), ), testutil.MustMetric( "fans", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board Fan8B", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "System Board Fan8B", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Fanspeed": "15840", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", + "datacenter": "", + "fanspeed": "15840", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", }, time.Unix(0, 0), ), testutil.MustMetric( "powersupply", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "PS1 Status", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "PS1 Status", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - "PowerCapacityWatts": "750", - "PowerInputWatts": "900", - "PowerOutputWatts": "203", + "datacenter": "", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", + "power_capacity_watts": "750", + "power_input_watts": "900", + "power_output_watts": "203", }, time.Unix(0, 0), ), testutil.MustMetric( "voltages", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board DIMM PG", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "System Board DIMM PG", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - "Voltage": "1", + "datacenter": "", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", + "voltage": "1", }, time.Unix(0, 0), ), testutil.MustMetric( "voltages", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board NDC PG", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "System Board NDC PG", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - "Voltage": "1", + "datacenter": "", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", + "voltage": "1", }, time.Unix(0, 0), ), @@ -515,18 +515,18 @@ func TestApis(t *testing.T) { testutil.MustMetric( "voltages", map[string]string{ - "Hostname": "tpa-hostname", - "Name": "System Board PS1 PG FAIL", - "OOBIP": ts.URL, + "hostname": "tpa-hostname", + "name": "System Board PS1 PG FAIL", + "oob_ip": ts.URL, }, map[string]interface{}{ - "Datacenter": "", - "Health": "OK", - "Rack": "", - "Room": "", - "Row": "", - "State": "Enabled", - "Voltage": "1", + "datacenter": "", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", + "voltage": "1", }, time.Unix(0, 0), ), @@ -537,12 +537,13 @@ func TestApis(t *testing.T) { BasicAuthPassword: "test", Id: "System.Embedded.1", Server: "dell", + // insecure_skip_verify : "true", } plugin.Init() var acc testutil.Accumulator _ = plugin.Gather(&acc) - assert.True(t, acc.HasMeasurement("cputemperature")) + assert.True(t, acc.HasMeasurement("cpu_temperature")) testutil.RequireMetricsEqual(t, expected_metrics, acc.GetTelegrafMetrics(), testutil.IgnoreTime()) @@ -557,7 +558,7 @@ func TestApis(t *testing.T) { var hp_acc testutil.Accumulator _ = hp_plugin.Gather(&hp_acc) - assert.True(t, hp_acc.HasMeasurement("cputemperature")) + assert.True(t, hp_acc.HasMeasurement("cpu_temperature")) testutil.RequireMetricsEqual(t, expected_metrics_hp, hp_acc.GetTelegrafMetrics(), testutil.IgnoreTime()) } @@ -578,6 +579,7 @@ func TestConnection(t *testing.T) { BasicAuthPassword: "test", Id: "System.Embedded.1", Server: "dell", + //insecure_skip_verify : "true", } var acc testutil.Accumulator @@ -651,7 +653,7 @@ func TestNoUsernameorPasswordConfiguration(t *testing.T) { var acc testutil.Accumulator r.Init() err := r.Gather(&acc) - assert.EqualError(t, err, "Did not provide all the mandatory fields in the configuration") + assert.EqualError(t, err, "Did not provide IP or username and password") } func TestInvalidServerVarConfiguration(t *testing.T) { @@ -684,7 +686,7 @@ func TestInvalidServerVarConfiguration(t *testing.T) { var acc testutil.Accumulator r.Init() err := r.Gather(&acc) - assert.EqualError(t, err, "Did not provide all the mandatory fields in the configuration") + assert.EqualError(t, err, "Did not provide correct server information, supported server details are dell or hp") } func TestInvalidDellJSON(t *testing.T) { @@ -726,7 +728,7 @@ func TestInvalidDellJSON(t *testing.T) { }, } for _, tt := range tests { - ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if !checkAuth(r, "test", "test") { http.Error(w, "Unauthorized.", 401) @@ -796,7 +798,7 @@ func TestInvalidHPJSON(t *testing.T) { }, } for _, tt := range tests { - ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if !checkAuth(r, "test", "test") { http.Error(w, "Unauthorized.", 401) diff --git a/plugins/inputs/redfish/testdata/.dell_power.json.swp b/plugins/inputs/redfish/testdata/.dell_power.json.swp deleted file mode 100644 index 39e0df1656f6c06c5f43d3c90122fc642ed761d1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 24576 zcmeI4dyHIF8NhFOLn#`>7*TY%TM$UudF*!Em8dMc+wN+2JMQ!msHM4`xx0JI-I-

gzmEty|JZaYFO53+(n@jKY6sD&t=~}gzo-(ZI`u6T(WhU*$)hsP->83ta z)h5%kW_`*i*9e=fTeWmmFHIV?X~Jt(NeGs7(?z8P zT%Y9rHr($ek?&L8->Un)BNBd!`+LCs{&gh$WcRoCeWx42OUJvv(v^#bzjf64yj#QF zVkcjT1riG+7Dz0RSRk=LVu8d0i3Ji1Bo;_4kXYb^SU@W|bN|Q0M4UZ;Z~p(E_bJK~ za0_gMVd#YmVHunbPoJYGyI}+_1_cf-Qeuo{-b>t`y;OYnWT33M2TA@~HG z48K1E{csoD2z4-F1eU|8aPV|Rc@*|T875#5vT!aucpA2Wqb!j87Jd$2g}rc;HIBn@ z5T1j_U_V?5PqN@K2W#MbI0sIFw^@jJ6@ChL!WUsH41)?wVF}pvWqU+Qe$*=~;#@?x zQBpsdQssGxo!Ru@v{tJbwRB;=X6ZBC!!z6UQb{j$XH~_Ez1zJ~Cv;P@^wKDTsM+G* zF4fB=tz4XUQz=&JWebVSibfF;ajU$a7e_P-_1Rf-e#88%E;2VTsD^{r*DVftY}PER zMtCmM6Am5~M?k#L{*0fdt$R?L)ry8S?+L7084%E_)_9!)S4Fy+{Ab68#s@N4nfx9v zp;T&*TaXl=;B_jcPH5#RJv*k&*%`4D^%5gDfq2Lc>6T`gdZ}PxN0Dg0s@L>#QBM(~ z7qP8OT%<${*P@ndoUS1bwgil}$oU{)-=$G2Uu9K}l6(&vP4gq(2s42BU7+O&L4QVOZZtPMsX19acJ6F-^S4sFW$b*F4?4uQSTmiS`rLqmI@Jy9}#1ZIq{+ zW{8MYt?SLJFU}2PTrgBizB9+zFSaM@#QhfE^`h-5RG6sCg$!#42JWcq?f%lUygIJU zIE}xMO^KeMUX!}ju}VodiL2%}PoxU@byu&T$J)GNVrYEBih+p@!-cEI?b`S1M;+5e z2R3T=>rI-UI;NHDlUmWLSDkK7v=u)&yh6A8txXlv(x!C36VCN!HpR=4!(66MW@4RI zv+O=1+*g$jY$;8t!-P38D(RpKI0aF@P66H z2gBD?_3P_&w(}!5Ak(|bOVyFl=E6F1eZ9>D!bG*?Qx)1!|Tj>?-4M!*PFeO zB>40c5zmo^_{8~ttYKn@9Is}4&x?$KUiCEg#j(}is54lkpf}s*nh>pxXUdZIG_)!s zTU5~hXuTM*#^5L=dvhxl+aUa*1Dk6I?~z>(0;AMvb*E;ImQh7EWOqW?z)rnNpV6Qo zClxr=IHp?+&B5_8n8kI*jA4zIy@K@guJ*HMhYima^;vh^RY$aH$+p1y$w}$lJG*JjUl~OtQyiiZ0(L{tVv`S8IoJD9YV1eSnS=3nEyY( zT>c=4`9D)o`|~!x-*E50%=ZuB%b>#-U;r+K55YUk`(J_Q;Yqj!_P`{J!9^g}2L8bO z|33H%Ou`_Db%DPz-xuou18@cO!rAZ_=Jk)m&tN~?0%9Ft3#@`}SPsuH-+vtLgResk zHbFm}34dj-|2RAb$tSTuVu8d0i3Ji1Bo;_4@Gh``n0u=3x=3`@rDqj^-W;{1V9UUu z7I#+EQvTQjNhvmROn`seznaopTEZ=Zx^Z?^uWp!TeSW%Pmc}dP!Kz^yMNKTuiFGYU z&Q~k1Sr=?)az$Q)9HFe8qEdxEB9SKplv2rm1{%!v% zzC8)=5pv=a@*=b3N0(RfqD8BSmuU=Xyz@WbLR)%MuVN1jV*YAwk8SPvJ&8So7A`}^T$*a~8=|8nSpL+s_h z3NOF`xC8dV4puM?f?_k!e#Ie?DaAnfZL!1eeeW({a{>Z-nv+xky1ACzk*TD)uByqu(PmuRfT0!d%;TN zP%f;AKrhRkCEB61E7nG*kZL2MPP9p}vy@m%kF|G94mwucCWBiPM?j60iwTI{?!Z>@ zg%rxXf^rqr9kbV9i+Ry}na0?Scbvm4arZgoB7@|G;#~RZgbu>EVvV_JkZL0$E5b|I z{%#kkg#-DPjmbKimqE3E?VnyH{tBT zGR1kJRDNx0&A{k7-&pK{x~bV`EwE*_$G1=Lv`F*>QdeLgMsvgZg9!KNM+))nJX-UfE#eqs;%iQZWdne4)AH|;oCE$ywJG&{1@+GNrN<+D!k ztZ)mw1$)>&9w1kWuTcx%#}1zG5GOB z5E)YG*~R>SGjr;b?|-~#v_bN?Z@5YB_s;0Sa5L!d(e zR9Fg!nCssKm%t0m>wg4y!`Gk=L$Dl9gV&kQKMLai8SH{GlwcSxf+g@K^ZJKiKYRoB z!glx+i1z|cg-4m|-wX5bG58(x{ny|XZ{F|LoBXmXT>c5p2xMyr9AguLG0#l6&57v1 zovbZTHIc$Gj!8?y6QR^1FXSr_9T+Q|Bl`^u@7)ObJQ~TiClr&Of7`$E-pL4LsAZry z8!D4;k;TPR5}SyhguId$Z4Di(wUgp?o{W%;ORB9FTOclWupRZLn)Oqnvu=+Od#f59Kq3jDN*fEuZNWqGWPd}*L zzm`|>BCf+dPJ!c$9@}lT)f?-6eoX(W$sigUCu96mC=j(E70HV@Yj!g7N*PamyWE9c zAubPb_c>4C1v%f|FaLedc<)lYD4jRkHtnk2BIt=(O&b~=8*4K?_s`9Dx{fB4ww|5) zI>XCejcYt|F(@qfE?Pp1T1z_JF|D7;BP~2;ZNW=vrmfyn4g`w`c6)c;u<%}amDzD- zM>$a;Znxn1zV}UPi?Pf-%WGfxHg732bFUhjDHp@l{K&vWK9gD1zc!QU?e~|P7CKe? EFF3`)=>Px# diff --git a/telegraf.conf b/telegraf.conf new file mode 100644 index 0000000000000..769d8d03bd33a --- /dev/null +++ b/telegraf.conf @@ -0,0 +1,591 @@ +# Telegraf Configuration +# +# Telegraf is entirely plugin driven. All metrics are gathered from the +# declared inputs, and sent to the declared outputs. +# +# Plugins must be declared in here to be active. +# To deactivate a plugin, comment out the name and any variables. +# +# Use 'telegraf -config telegraf.conf -test' to see what metrics a config +# file would generate. +# +# Environment variables can be used anywhere in this config file, simply surround +# them with ${}. For strings the variable must be within quotes (ie, "${STR_VAR}"), +# for numbers and booleans they should be plain (ie, ${INT_VAR}, ${BOOL_VAR}) + + +# Global tags can be specified here in key="value" format. +[global_tags] + # dc = "us-east-1" # will tag all metrics with dc=us-east-1 + # rack = "1a" + ## Environment variables can be used as tags, and throughout the config file + # user = "$USER" + + +# Configuration for telegraf agent +[agent] + ## Default data collection interval for all inputs + interval = "10s" + ## Rounds collection interval to 'interval' + ## ie, if interval="10s" then always collect on :00, :10, :20, etc. + round_interval = true + + ## Telegraf will send metrics to outputs in batches of at most + ## metric_batch_size metrics. + ## This controls the size of writes that Telegraf sends to output plugins. + metric_batch_size = 1000 + + ## Maximum number of unwritten metrics per output. Increasing this value + ## allows for longer periods of output downtime without dropping metrics at the + ## cost of higher maximum memory usage. + metric_buffer_limit = 10000 + + ## Collection jitter is used to jitter the collection by a random amount. + ## Each plugin will sleep for a random time within jitter before collecting. + ## This can be used to avoid many plugins querying things like sysfs at the + ## same time, which can have a measurable effect on the system. + collection_jitter = "0s" + + ## Default flushing interval for all outputs. Maximum flush_interval will be + ## flush_interval + flush_jitter + flush_interval = "10s" + ## Jitter the flush interval by a random amount. This is primarily to avoid + ## large write spikes for users running a large number of telegraf instances. + ## ie, a jitter of 5s and interval 10s means flushes will happen every 10-15s + flush_jitter = "0s" + + ## By default or when set to "0s", precision will be set to the same + ## timestamp order as the collection interval, with the maximum being 1s. + ## ie, when interval = "10s", precision will be "1s" + ## when interval = "250ms", precision will be "1ms" + ## Precision will NOT be used for service inputs. It is up to each individual + ## service input to set the timestamp at the appropriate precision. + ## Valid time units are "ns", "us" (or "µs"), "ms", "s". + precision = "" + + ## Log at debug level. + # debug = false + ## Log only error level messages. + # quiet = false + + ## Log target controls the destination for logs and can be one of "file", + ## "stderr" or, on Windows, "eventlog". When set to "file", the output file + ## is determined by the "logfile" setting. + # logtarget = "file" + + ## Name of the file to be logged to when using the "file" logtarget. If set to + ## the empty string then logs are written to stderr. + # logfile = "" + + ## The logfile will be rotated after the time interval specified. When set + ## to 0 no time based rotation is performed. Logs are rotated only when + ## written to, if there is no log activity rotation may be delayed. + # logfile_rotation_interval = "0d" + + ## The logfile will be rotated when it becomes larger than the specified + ## size. When set to 0 no size based rotation is performed. + # logfile_rotation_max_size = "0MB" + + ## Maximum number of rotated archives to keep, any older logs are deleted. + ## If set to -1, no archives are removed. + # logfile_rotation_max_archives = 5 + + ## Override default hostname, if empty use os.Hostname() + hostname = "" + ## If set to true, do no set the "host" tag in the telegraf agent. + omit_hostname = false + + +############################################################################### +# OUTPUT PLUGINS # +############################################################################### + + +# Configuration for sending metrics to InfluxDB +[[outputs.influxdb]] + ## The full HTTP or UDP URL for your InfluxDB instance. + ## + ## Multiple URLs can be specified for a single cluster, only ONE of the + ## urls will be written to each interval. + # urls = ["unix:///var/run/influxdb.sock"] + # urls = ["udp://127.0.0.1:8089"] + urls = ["http://10.75.15.73:8086"] + + ## The target database for metrics; will be created as needed. + ## For UDP url endpoint database needs to be configured on server side. + database = "redfishtest" + + ## The value of this tag will be used to determine the database. If this + ## tag is not set the 'database' option is used as the default. + # database_tag = "" + + ## If true, the database tag will not be added to the metric. + # exclude_database_tag = false + + ## If true, no CREATE DATABASE queries will be sent. Set to true when using + ## Telegraf with a user without permissions to create databases or when the + ## database already exists. + # skip_database_creation = false + + ## Name of existing retention policy to write to. Empty string writes to + ## the default retention policy. Only takes effect when using HTTP. + # retention_policy = "" + + ## Write consistency (clusters only), can be: "any", "one", "quorum", "all". + ## Only takes effect when using HTTP. + # write_consistency = "any" + + ## Timeout for HTTP messages. + # timeout = "5s" + + ## HTTP Basic Auth + # username = "telegraf" + # password = "metricsmetricsmetricsmetrics" + + ## HTTP User-Agent + # user_agent = "telegraf" + + ## UDP payload size is the maximum packet size to send. + # udp_payload = "512B" + + ## Optional TLS Config for use on HTTP connections. + # tls_ca = "/etc/telegraf/ca.pem" + # tls_cert = "/etc/telegraf/cert.pem" + # tls_key = "/etc/telegraf/key.pem" + ## Use TLS but skip chain & host verification + # insecure_skip_verify = false + + ## HTTP Proxy override, if unset values the standard proxy environment + ## variables are consulted to determine which proxy, if any, should be used. + # http_proxy = "http://corporate.proxy:3128" + + ## Additional HTTP headers + # http_headers = {"X-Special-Header" = "Special-Value"} + + ## HTTP Content-Encoding for write request body, can be set to "gzip" to + ## compress body or "identity" to apply no encoding. + # content_encoding = "identity" + + ## When true, Telegraf will output unsigned integers as unsigned values, + ## i.e.: "42u". You will need a version of InfluxDB supporting unsigned + ## integer values. Enabling this option will result in field type errors if + ## existing data has been written. + # influx_uint_support = false + + +############################################################################### +# PROCESSOR PLUGINS # +############################################################################### + + +# # Clone metrics and apply modifications. +# [[processors.clone]] +# ## All modifications on inputs and aggregators can be overridden: +# # name_override = "new_name" +# # name_prefix = "new_name_prefix" +# # name_suffix = "new_name_suffix" +# +# ## Tags to be added (all values must be strings) +# # [processors.clone.tags] +# # additional_tag = "tag_value" + + +# # Convert values to another metric value type +# [[processors.converter]] +# ## Tags to convert +# ## +# ## The table key determines the target type, and the array of key-values +# ## select the keys to convert. The array may contain globs. +# ## = [...] +# [processors.converter.tags] +# string = [] +# integer = [] +# unsigned = [] +# boolean = [] +# float = [] +# +# ## Fields to convert +# ## +# ## The table key determines the target type, and the array of key-values +# ## select the keys to convert. The array may contain globs. +# ## = [...] +# [processors.converter.fields] +# tag = [] +# string = [] +# integer = [] +# unsigned = [] +# boolean = [] +# float = [] + + +# # Dates measurements, tags, and fields that pass through this filter. +# [[processors.date]] +# ## New tag to create +# tag_key = "month" +# +# ## Date format string, must be a representation of the Go "reference time" +# ## which is "Mon Jan 2 15:04:05 -0700 MST 2006". +# date_format = "Jan" +# +# ## Offset duration added to the date string when writing the new tag. +# # date_offset = "0s" +# +# ## Timezone to use when creating the tag. This can be set to one of +# ## "UTC", "Local", or to a location name in the IANA Time Zone database. +# ## example: timezone = "America/Los_Angeles" +# # timezone = "UTC" + + +# # Map enum values according to given table. +# [[processors.enum]] +# [[processors.enum.mapping]] +# ## Name of the field to map +# field = "status" +# +# ## Name of the tag to map +# # tag = "status" +# +# ## Destination tag or field to be used for the mapped value. By default the +# ## source tag or field is used, overwriting the original value. +# dest = "status_code" +# +# ## Default value to be used for all values not contained in the mapping +# ## table. When unset, the unmodified value for the field will be used if no +# ## match is found. +# # default = 0 +# +# ## Table of mappings +# [processors.enum.mapping.value_mappings] +# green = 1 +# amber = 2 +# red = 3 + + +# # Apply metric modifications using override semantics. +# [[processors.override]] +# ## All modifications on inputs and aggregators can be overridden: +# # name_override = "new_name" +# # name_prefix = "new_name_prefix" +# # name_suffix = "new_name_suffix" +# +# ## Tags to be added (all values must be strings) +# # [processors.override.tags] +# # additional_tag = "tag_value" + + +# # Parse a value in a specified field/tag(s) and add the result in a new metric +# [[processors.parser]] +# ## The name of the fields whose value will be parsed. +# parse_fields = [] +# +# ## If true, incoming metrics are not emitted. +# drop_original = false +# +# ## If set to override, emitted metrics will be merged by overriding the +# ## original metric using the newly parsed metrics. +# merge = "override" +# +# ## The dataformat to be read from files +# ## Each data format has its own unique set of configuration options, read +# ## more about them here: +# ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md +# data_format = "influx" + + +# # Rotate a single valued metric into a multi field metric +# [[processors.pivot]] +# ## Tag to use for naming the new field. +# tag_key = "name" +# ## Field to use as the value of the new field. +# value_key = "value" + + +# # Print all metrics that pass through this filter. +# [[processors.printer]] + + +# # Transforms tag and field values with regex pattern +# [[processors.regex]] +# ## Tag and field conversions defined in a separate sub-tables +# # [[processors.regex.tags]] +# # ## Tag to change +# # key = "resp_code" +# # ## Regular expression to match on a tag value +# # pattern = "^(\\d)\\d\\d$" +# # ## Matches of the pattern will be replaced with this string. Use ${1} +# # ## notation to use the text of the first submatch. +# # replacement = "${1}xx" +# +# # [[processors.regex.fields]] +# # ## Field to change +# # key = "request" +# # ## All the power of the Go regular expressions available here +# # ## For example, named subgroups +# # pattern = "^/api(?P/[\\w/]+)\\S*" +# # replacement = "${method}" +# # ## If result_key is present, a new field will be created +# # ## instead of changing existing field +# # result_key = "method" +# +# ## Multiple conversions may be applied for one field sequentially +# ## Let's extract one more value +# # [[processors.regex.fields]] +# # key = "request" +# # pattern = ".*category=(\\w+).*" +# # replacement = "${1}" +# # result_key = "search_category" + + +# # Rename measurements, tags, and fields that pass through this filter. +# [[processors.rename]] + + +# # Perform string processing on tags, fields, and measurements +# [[processors.strings]] +# ## Convert a tag value to uppercase +# # [[processors.strings.uppercase]] +# # tag = "method" +# +# ## Convert a field value to lowercase and store in a new field +# # [[processors.strings.lowercase]] +# # field = "uri_stem" +# # dest = "uri_stem_normalised" +# +# ## Convert a field value to titlecase +# # [[processors.strings.titlecase]] +# # field = "status" +# +# ## Trim leading and trailing whitespace using the default cutset +# # [[processors.strings.trim]] +# # field = "message" +# +# ## Trim leading characters in cutset +# # [[processors.strings.trim_left]] +# # field = "message" +# # cutset = "\t" +# +# ## Trim trailing characters in cutset +# # [[processors.strings.trim_right]] +# # field = "message" +# # cutset = "\r\n" +# +# ## Trim the given prefix from the field +# # [[processors.strings.trim_prefix]] +# # field = "my_value" +# # prefix = "my_" +# +# ## Trim the given suffix from the field +# # [[processors.strings.trim_suffix]] +# # field = "read_count" +# # suffix = "_count" +# +# ## Replace all non-overlapping instances of old with new +# # [[processors.strings.replace]] +# # measurement = "*" +# # old = ":" +# # new = "_" +# +# ## Trims strings based on width +# # [[processors.strings.left]] +# # field = "message" +# # width = 10 +# +# ## Decode a base64 encoded utf-8 string +# # [[processors.strings.base64decode]] +# # field = "message" + + +# # Restricts the number of tags that can pass through this filter and chooses which tags to preserve when over the limit. +# [[processors.tag_limit]] +# ## Maximum number of tags to preserve +# limit = 10 +# +# ## List of tags to preferentially preserve +# keep = ["foo", "bar", "baz"] + + +# # Uses a Go template to create a new tag +# [[processors.template]] +# ## Tag to set with the output of the template. +# tag = "topic" +# +# ## Go template used to create the tag value. In order to ease TOML +# ## escaping requirements, you may wish to use single quotes around the +# ## template string. +# template = '{{ .Tag "hostname" }}.{{ .Tag "level" }}' + + +# # Print all metrics that pass through this filter. +# [[processors.topk]] +# ## How many seconds between aggregations +# # period = 10 +# +# ## How many top metrics to return +# # k = 10 +# +# ## Over which tags should the aggregation be done. Globs can be specified, in +# ## which case any tag matching the glob will aggregated over. If set to an +# ## empty list is no aggregation over tags is done +# # group_by = ['*'] +# +# ## Over which fields are the top k are calculated +# # fields = ["value"] +# +# ## What aggregation to use. Options: sum, mean, min, max +# # aggregation = "mean" +# +# ## Instead of the top k largest metrics, return the bottom k lowest metrics +# # bottomk = false +# +# ## The plugin assigns each metric a GroupBy tag generated from its name and +# ## tags. If this setting is different than "" the plugin will add a +# ## tag (which name will be the value of this setting) to each metric with +# ## the value of the calculated GroupBy tag. Useful for debugging +# # add_groupby_tag = "" +# +# ## These settings provide a way to know the position of each metric in +# ## the top k. The 'add_rank_field' setting allows to specify for which +# ## fields the position is required. If the list is non empty, then a field +# ## will be added to each and every metric for each string present in this +# ## setting. This field will contain the ranking of the group that +# ## the metric belonged to when aggregated over that field. +# ## The name of the field will be set to the name of the aggregation field, +# ## suffixed with the string '_topk_rank' +# # add_rank_fields = [] +# +# ## These settings provide a way to know what values the plugin is generating +# ## when aggregating metrics. The 'add_agregate_field' setting allows to +# ## specify for which fields the final aggregation value is required. If the +# ## list is non empty, then a field will be added to each every metric for +# ## each field present in this setting. This field will contain +# ## the computed aggregation for the group that the metric belonged to when +# ## aggregated over that field. +# ## The name of the field will be set to the name of the aggregation field, +# ## suffixed with the string '_topk_aggregate' +# # add_aggregate_fields = [] + + +# # Rotate multi field metric into several single field metrics +# [[processors.unpivot]] +# ## Tag to use for the name. +# tag_key = "name" +# ## Field to use for the name of the value. +# value_key = "value" + + +############################################################################### +# AGGREGATOR PLUGINS # +############################################################################### + + +# # Keep the aggregate basicstats of each metric passing through. +# [[aggregators.basicstats]] +# ## The period on which to flush & clear the aggregator. +# period = "30s" +# +# ## If true, the original metric will be dropped by the +# ## aggregator and will not get sent to the output plugins. +# drop_original = false +# +# ## Configures which basic stats to push as fields +# # stats = ["count", "min", "max", "mean", "stdev", "s2", "sum"] + + +# # Report the final metric of a series +# [[aggregators.final]] +# ## The period on which to flush & clear the aggregator. +# period = "30s" +# ## If true, the original metric will be dropped by the +# ## aggregator and will not get sent to the output plugins. +# drop_original = false +# +# ## The time that a series is not updated until considering it final. +# series_timeout = "5m" + + +# # Create aggregate histograms. +# [[aggregators.histogram]] +# ## The period in which to flush the aggregator. +# period = "30s" +# +# ## If true, the original metric will be dropped by the +# ## aggregator and will not get sent to the output plugins. +# drop_original = false +# +# ## If true, the histogram will be reset on flush instead +# ## of accumulating the results. +# reset = false +# +# ## Example config that aggregates all fields of the metric. +# # [[aggregators.histogram.config]] +# # ## The set of buckets. +# # buckets = [0.0, 15.6, 34.5, 49.1, 71.5, 80.5, 94.5, 100.0] +# # ## The name of metric. +# # measurement_name = "cpu" +# +# ## Example config that aggregates only specific fields of the metric. +# # [[aggregators.histogram.config]] +# # ## The set of buckets. +# # buckets = [0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0] +# # ## The name of metric. +# # measurement_name = "diskio" +# # ## The concrete fields of metric +# # fields = ["io_time", "read_time", "write_time"] + + +# # Merge metrics into multifield metrics by series key +# [[aggregators.merge]] +# ## If true, the original metric will be dropped by the +# ## aggregator and will not get sent to the output plugins. +# drop_original = true + + +# # Keep the aggregate min/max of each metric passing through. +# [[aggregators.minmax]] +# ## General Aggregator Arguments: +# ## The period on which to flush & clear the aggregator. +# period = "30s" +# ## If true, the original metric will be dropped by the +# ## aggregator and will not get sent to the output plugins. +# drop_original = false + + +# # Count the occurrence of values in fields. +# [[aggregators.valuecounter]] +# ## General Aggregator Arguments: +# ## The period on which to flush & clear the aggregator. +# period = "30s" +# ## If true, the original metric will be dropped by the +# ## aggregator and will not get sent to the output plugins. +# drop_original = false +# ## The fields for which the values will be counted +# fields = [] + + +############################################################################### +# INPUT PLUGINS # +############################################################################### + + +# Read CPU, Fans, Powersupply and Voltage metrics of Dell/HP hardware server through redfish APIs +[[inputs.redfish]] +## Server OOB-IP +host = "https://10.75.112.108" + +## Username,Password for hardware server +basicauthusername = "corona" +basicauthpassword = "Babylon1" +## Server Vendor(dell or hp) +server= "dell" +## Resource Id for redfish APIs +id="System.Embedded.1" +## Optional TLS Config +# tls_ca = "/etc/telegraf/ca.pem" +# tls_cert = "/etc/telegraf/cert.pem" +# tls_key = "/etc/telegraf/key.pem" +## Use TLS but skip chain & host verification +insecure_skip_verify = true + +## Amount of time allowed to complete the HTTP request + timeout = "5s" + From 06a33dc83e9a989d9137322446265b93433caa97 Mon Sep 17 00:00:00 2001 From: sarvanikonda Date: Mon, 11 May 2020 19:57:44 +0530 Subject: [PATCH 06/12] optimised redfish plugin code --- plugins/inputs/redfish/README.md | 188 +++++----- telegraf.conf | 591 ------------------------------- 2 files changed, 97 insertions(+), 682 deletions(-) delete mode 100644 telegraf.conf diff --git a/plugins/inputs/redfish/README.md b/plugins/inputs/redfish/README.md index 4f6ce54546494..10a76c8a82c4d 100644 --- a/plugins/inputs/redfish/README.md +++ b/plugins/inputs/redfish/README.md @@ -1,7 +1,7 @@ # Redfish Input Plugin -The `redfish` plugin gathers metrics and status information about CPU temperature, Fanspeed, Powersupply, voltage, Hostname and Location details(datacenter,placement,rack and room) of Dell hardware servers for which redfish is enabled. -And also metrics like CPU temperature,Fanspeed, Powersupply and Hostname metrics for HP Hardware server(redfish should be enabled). +The `redfish` plugin gathers metrics and status information about CPU temperature, fanspeed, Powersupply, voltage, hostname and Location details(datacenter,placement,rack and room) of Dell hardware servers for which redfish is enabled. +And also metrics like CPU temperature,fanspeed, Powersupply and hostname metrics for HP Hardware server(redfish should be enabled). Note: Currently this plugin only supports DELL and HP servers. @@ -12,7 +12,7 @@ Note: Currently this plugin only supports DELL and HP servers. ```toml [[inputs.redfish]] ## Server OOB-IP -host = "https://192.0.0.1" +host = "http://192.0.0.1" ## Username,Password for hardware server basicauthusername = "test" @@ -21,6 +21,12 @@ basicauthpassword = "test" server= "dell" ## Resource Id for redfish APIs id="System.Embedded.1" +## Optional TLS Config +# tls_ca = "/etc/telegraf/ca.pem" +# tls_cert = "/etc/telegraf/cert.pem" +# tls_key = "/etc/telegraf/key.pem" +## Use TLS but skip chain & host verification +# insecure_skip_verify = false ## Amount of time allowed to complete the HTTP request # timeout = "5s" @@ -28,132 +34,132 @@ id="System.Embedded.1" ### Metrics for Dell Servers -- cputemperatures +- cpu_temperatures - tags: - - Hostname - - Name - - OOBIP + - hostname + - name + - oob_ip - host - Fields: - - Datacenter - - Temperature - - Health - - Rack - - Room - - Row - - State + - datacenter + - temperature + - health + - rack + - room + - row + - state - fans - tags: - - Hostname - - Name - - OOBIP + - hostname + - name + - oob_ip - host - Fields: - - Datacenter - - Fanspeed - - Health - - Rack - - Room - - Row - - State - -- Voltages + - datacenter + - fanspeed + - health + - rack + - room + - row + - state + +- voltages - tags: - - Hostname - - Name - - OOBIP + - hostname + - name + - oob_ip - host - Fields: - - Datacenter - - Voltage - - Health - - Rack - - Room - - Row - - State + - datacenter + - voltage + - health + - rack + - room + - row + - state - Powersupply - tags: - - Hostname - - Name - - OOBIP + - hostname + - name + - oobip - host - Fields: - - Datacenter - - Health - - PowerCapacityWatts - - PowerInputWatts - - PowerOutputWatts - - Rack - - Room - - Row - - State + - datacenter + - health + - power_capacity_watts + - power_input_watts + - power_output_watts + - rack + - room + - row + - state ### Metrics for HP Servers -- cputemperatures +- cpu_temperature - tags: - - Hostname - - Name - - OOBIP + - hostname + - name + - oob_ip - host - Fields: - - Temperature - - Health - - State + - temperature + - health + - state - fans - tags: - - Hostname - - Name - - OOBIP + - hostname + - name + - oob_ip - host - Fields: - - Fanspeed - - Health - - State + - fanspeed + - health + - state - Powersupply - tags: - - Hostname - - Name - - OOBIP + - hostname + - name + - oob_ip - host - - MemberId + - member_id - Fields: - - PowerCapacityWatts - - LastPowerOutputWatts - - LineInputVoltage + - power_capacity_watts + - last_powerOutput_watts + - line_input_voltage ### Example Output For HP ``` -cputemperature,Hostname=tpa_hostname,Name=01-Inlet\ Ambient,OOBIP=https://127.0.0.1,host=tpa_po Health="OK",State="Enabled",Temperature="19" 1582612210000000000 -cputemperature,Hostname=tpa_hostname,Name=02-CPU\ 1,OOBIP=https://127.0.0.1,host=tpa_po Health="OK",State="Enabled",Temperature="40" 1582612210000000000 -fans,Hostname=tpa_hostname,Name=Fan\ 4,OOBIP=https://127.0.0.1,host=tpa_po Fanspeed="23",Health="OK",State="Enabled" 1582612210000000000 -fans,Hostname=tpa_hostname,Name=Fan\ 5,OOBIP=https://127.0.0.1,host=tpa_po Fanspeed="23",Health="OK",State="Enabled" 1582612210000000000 -fans,Hostname=tpa_hostname,Name=Fan\ 6,OOBIP=https://127.0.0.1,host=tpa_po Fanspeed="23",Health="OK",State="Enabled" 1582612210000000000 -fans,Hostname=tpa_hostname,Name=Fan\ 7,OOBIP=https://127.0.0.1,host=tpa_po Fanspeed="23",Health="OK",State="Enabled" 1582612210000000000 -powersupply,Hostname=tpa_hostname,MemberId=0,Name=HpeServerPowerSupply,OOBIP=https://127.0.0.1,host=tpa_po LastPowerOutputWatts="109",LineInputVoltage="206",PowerCapacityWatts="800" 1582612210000000000 -powersupply,Hostname=tpa_hostname,MemberId=1,Name=HpeServerPowerSupply,OOBIP=https://127.0.0.1,host=tpa_po LastPowerOutputWatts="98",LineInputVoltage="204",PowerCapacityWatts="800" 1582612210000000000 +cpu_temperature,hostname=tpa_hostname,name=01-Inlet\ Ambient,oob_ip=http://127.0.0.1,host=tpa_po health="OK",state="Enabled",temperature="19" 1582612210000000000 +cpu_temperature,hostname=tpa_hostname,name=02-CPU\ 1,oob_ip=http://127.0.0.1,host=tpa_po health="OK",state="Enabled",temperature="40" 1582612210000000000 +fans,hostname=tpa_hostname,name=Fan\ 4,oob_ip=http://127.0.0.1,host=tpa_po fanspeed="23",health="OK",state="Enabled" 1582612210000000000 +fans,hostname=tpa_hostname,name=Fan\ 5,oob_ip=http://127.0.0.1,host=tpa_po fanspeed="23",health="OK",state="Enabled" 1582612210000000000 +fans,hostname=tpa_hostname,name=Fan\ 6,oob_ip=http://127.0.0.1,host=tpa_po fanspeed="23",health="OK",state="Enabled" 1582612210000000000 +fans,hostname=tpa_hostname,name=Fan\ 7,oob_ip=http://127.0.0.1,host=tpa_po fanspeed="23",health="OK",state="Enabled" 1582612210000000000 +powersupply,hostname=tpa_hostname,member_id=0,name=HpeServerPowerSupply,oob_ip=http://127.0.0.1,host=tpa_po last_power_output_watts="109",line_input_voltage="206",power_capacity_watts="800" 1582612210000000000 +powersupply,hostname=tpa_hostname,member_id=1,name=HpeServerPowerSupply,oob_ip=http://127.0.0.1,host=tpa_po last_power_output_watts="98",line_input_voltage="204",power_capacity_watts="800" 1582612210000000000 ``` ### Example Output For Dell ``` -cputemperature,Hostname=test-hostname,Name=CPU1\ Temp,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled",Temperature="41" 1582114112000000000 -cputemperature,Hostname=test-hostname,Name=CPU2\ Temp,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled",Temperature="51" 1582114112000000000 -cputemperature,Hostname=test-hostname,Name=System\ Board\ Inlet\ Temp,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled",Temperature="23" 1582114112000000000 -cputemperature,Hostname=test-hostname,Name=System\ Board\ Exhaust\ Temp,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled",Temperature="33" 1582114112000000000 -fans,Hostname=test-hostname,Name=System\ Board\ Fan1A,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Fanspeed="17760",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled" 1582114112000000000 -fans,Hostname=test-hostname,Name=System\ Board\ Fan1B,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Fanspeed="15360",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled" 1582114112000000000 -fans,Hostname=test-hostname,Name=System\ Board\ Fan2A,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Fanspeed="17880",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled" 1582114112000000000 -powersupply,Hostname=test-hostname,Name=PS1\ Status,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",PowerCapacityWatts="750",PowerInputWatts="900",PowerOutputWatts="208",Rack="12",Room="tbc",Row="3",State="Enabled" 1582114112000000000 -powersupply,Hostname=test-hostname,Name=PS2\ Status,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",PowerCapacityWatts="750",PowerInputWatts="900",PowerOutputWatts="194",Rack="12",Room="tbc",Row="3",State="Enabled" 1582114112000000000 -voltages,Hostname=test-hostname,Name=CPU1\ MEM345\ VDDQ\ PG,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled",Voltage="1" 1582114112000000000 -voltages,Hostname=test-hostname,Name=CPU1\ MEM345\ VPP\ PG,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled",Voltage="1" 1582114112000000000 -voltages,Hostname=test-hostname,Name=CPU1\ MEM345\ VTT\ PG,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled",Voltage="1" 1582114112000000000 -voltages,Hostname=test-hostname,Name=PS1\ Voltage\ 1,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled",Voltage="208" 1582114112000000000 -voltages,Hostname=test-hostname,Name=PS2\ Voltage\ 2,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled",Voltage="208" 1582114112000000000 -voltages,Hostname=test-hostname,Name=System\ Board\ 3.3V\ A\ PG,OOBIP=https://190.0.0.1,host=test-telegraf Datacenter="Tampa",Health="OK",Rack="12",Room="tbc",Row="3",State="Enabled",Voltage="1" 1582114112000000000 +cpu_temperature,hostname=test-hostname,name=CPU1\ Temp,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",temperature="41" 1582114112000000000 +cpu_temperature,hostname=test-hostname,name=CPU2\ Temp,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",temperature="51" 1582114112000000000 +cpu_temperature,hostname=test-hostname,name=System\ Board\ Inlet\ Temp,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",temperature="23" 1582114112000000000 +cpu_temperature,hostname=test-hostname,name=System\ Board\ Exhaust\ Temp,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",temperature="33" 1582114112000000000 +fans,hostname=test-hostname,name=System\ Board\ Fan1A,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",fanspeed="17760",health="OK",rack="12",room="tbc",row="3",state="Enabled" 1582114112000000000 +fans,hostname=test-hostname,name=System\ Board\ Fan1B,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",fanspeed="15360",health="OK",rack="12",room="tbc",row="3",state="Enabled" 1582114112000000000 +fans,hostname=test-hostname,name=System\ Board\ Fan2A,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",fanspeed="17880",health="OK",rack="12",room="tbc",row="3",state="Enabled" 1582114112000000000 +powersupply,hostname=test-hostname,name=PS1\ Status,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",power_capacity_watts="750",power_input_watts="900",power_output_watts="208",rack="12",room="tbc",row="3",state="Enabled" 1582114112000000000 +powersupply,hostname=test-hostname,name=PS2\ Status,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",power_capacity_watts="750",power_input_watts="900",power_output_watts="194",rack="12",room="tbc",row="3",state="Enabled" 1582114112000000000 +voltages,hostname=test-hostname,name=CPU1\ MEM345\ VDDQ\ PG,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",voltage="1" 1582114112000000000 +voltages,hostname=test-hostname,name=CPU1\ MEM345\ VPP\ PG,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",voltage="1" 1582114112000000000 +voltages,hostname=test-hostname,name=CPU1\ MEM345\ VTT\ PG,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",voltage="1" 1582114112000000000 +voltages,hostname=test-hostname,name=PS1\ voltage\ 1,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",Voltage="208" 1582114112000000000 +voltages,hostname=test-hostname,name=PS2\ voltage\ 2,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",Voltage="208" 1582114112000000000 +voltages,hostname=test-hostname,name=System\ Board\ 3.3V\ A\ PG,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",voltage="1" 1582114112000000000 ``` diff --git a/telegraf.conf b/telegraf.conf deleted file mode 100644 index 769d8d03bd33a..0000000000000 --- a/telegraf.conf +++ /dev/null @@ -1,591 +0,0 @@ -# Telegraf Configuration -# -# Telegraf is entirely plugin driven. All metrics are gathered from the -# declared inputs, and sent to the declared outputs. -# -# Plugins must be declared in here to be active. -# To deactivate a plugin, comment out the name and any variables. -# -# Use 'telegraf -config telegraf.conf -test' to see what metrics a config -# file would generate. -# -# Environment variables can be used anywhere in this config file, simply surround -# them with ${}. For strings the variable must be within quotes (ie, "${STR_VAR}"), -# for numbers and booleans they should be plain (ie, ${INT_VAR}, ${BOOL_VAR}) - - -# Global tags can be specified here in key="value" format. -[global_tags] - # dc = "us-east-1" # will tag all metrics with dc=us-east-1 - # rack = "1a" - ## Environment variables can be used as tags, and throughout the config file - # user = "$USER" - - -# Configuration for telegraf agent -[agent] - ## Default data collection interval for all inputs - interval = "10s" - ## Rounds collection interval to 'interval' - ## ie, if interval="10s" then always collect on :00, :10, :20, etc. - round_interval = true - - ## Telegraf will send metrics to outputs in batches of at most - ## metric_batch_size metrics. - ## This controls the size of writes that Telegraf sends to output plugins. - metric_batch_size = 1000 - - ## Maximum number of unwritten metrics per output. Increasing this value - ## allows for longer periods of output downtime without dropping metrics at the - ## cost of higher maximum memory usage. - metric_buffer_limit = 10000 - - ## Collection jitter is used to jitter the collection by a random amount. - ## Each plugin will sleep for a random time within jitter before collecting. - ## This can be used to avoid many plugins querying things like sysfs at the - ## same time, which can have a measurable effect on the system. - collection_jitter = "0s" - - ## Default flushing interval for all outputs. Maximum flush_interval will be - ## flush_interval + flush_jitter - flush_interval = "10s" - ## Jitter the flush interval by a random amount. This is primarily to avoid - ## large write spikes for users running a large number of telegraf instances. - ## ie, a jitter of 5s and interval 10s means flushes will happen every 10-15s - flush_jitter = "0s" - - ## By default or when set to "0s", precision will be set to the same - ## timestamp order as the collection interval, with the maximum being 1s. - ## ie, when interval = "10s", precision will be "1s" - ## when interval = "250ms", precision will be "1ms" - ## Precision will NOT be used for service inputs. It is up to each individual - ## service input to set the timestamp at the appropriate precision. - ## Valid time units are "ns", "us" (or "µs"), "ms", "s". - precision = "" - - ## Log at debug level. - # debug = false - ## Log only error level messages. - # quiet = false - - ## Log target controls the destination for logs and can be one of "file", - ## "stderr" or, on Windows, "eventlog". When set to "file", the output file - ## is determined by the "logfile" setting. - # logtarget = "file" - - ## Name of the file to be logged to when using the "file" logtarget. If set to - ## the empty string then logs are written to stderr. - # logfile = "" - - ## The logfile will be rotated after the time interval specified. When set - ## to 0 no time based rotation is performed. Logs are rotated only when - ## written to, if there is no log activity rotation may be delayed. - # logfile_rotation_interval = "0d" - - ## The logfile will be rotated when it becomes larger than the specified - ## size. When set to 0 no size based rotation is performed. - # logfile_rotation_max_size = "0MB" - - ## Maximum number of rotated archives to keep, any older logs are deleted. - ## If set to -1, no archives are removed. - # logfile_rotation_max_archives = 5 - - ## Override default hostname, if empty use os.Hostname() - hostname = "" - ## If set to true, do no set the "host" tag in the telegraf agent. - omit_hostname = false - - -############################################################################### -# OUTPUT PLUGINS # -############################################################################### - - -# Configuration for sending metrics to InfluxDB -[[outputs.influxdb]] - ## The full HTTP or UDP URL for your InfluxDB instance. - ## - ## Multiple URLs can be specified for a single cluster, only ONE of the - ## urls will be written to each interval. - # urls = ["unix:///var/run/influxdb.sock"] - # urls = ["udp://127.0.0.1:8089"] - urls = ["http://10.75.15.73:8086"] - - ## The target database for metrics; will be created as needed. - ## For UDP url endpoint database needs to be configured on server side. - database = "redfishtest" - - ## The value of this tag will be used to determine the database. If this - ## tag is not set the 'database' option is used as the default. - # database_tag = "" - - ## If true, the database tag will not be added to the metric. - # exclude_database_tag = false - - ## If true, no CREATE DATABASE queries will be sent. Set to true when using - ## Telegraf with a user without permissions to create databases or when the - ## database already exists. - # skip_database_creation = false - - ## Name of existing retention policy to write to. Empty string writes to - ## the default retention policy. Only takes effect when using HTTP. - # retention_policy = "" - - ## Write consistency (clusters only), can be: "any", "one", "quorum", "all". - ## Only takes effect when using HTTP. - # write_consistency = "any" - - ## Timeout for HTTP messages. - # timeout = "5s" - - ## HTTP Basic Auth - # username = "telegraf" - # password = "metricsmetricsmetricsmetrics" - - ## HTTP User-Agent - # user_agent = "telegraf" - - ## UDP payload size is the maximum packet size to send. - # udp_payload = "512B" - - ## Optional TLS Config for use on HTTP connections. - # tls_ca = "/etc/telegraf/ca.pem" - # tls_cert = "/etc/telegraf/cert.pem" - # tls_key = "/etc/telegraf/key.pem" - ## Use TLS but skip chain & host verification - # insecure_skip_verify = false - - ## HTTP Proxy override, if unset values the standard proxy environment - ## variables are consulted to determine which proxy, if any, should be used. - # http_proxy = "http://corporate.proxy:3128" - - ## Additional HTTP headers - # http_headers = {"X-Special-Header" = "Special-Value"} - - ## HTTP Content-Encoding for write request body, can be set to "gzip" to - ## compress body or "identity" to apply no encoding. - # content_encoding = "identity" - - ## When true, Telegraf will output unsigned integers as unsigned values, - ## i.e.: "42u". You will need a version of InfluxDB supporting unsigned - ## integer values. Enabling this option will result in field type errors if - ## existing data has been written. - # influx_uint_support = false - - -############################################################################### -# PROCESSOR PLUGINS # -############################################################################### - - -# # Clone metrics and apply modifications. -# [[processors.clone]] -# ## All modifications on inputs and aggregators can be overridden: -# # name_override = "new_name" -# # name_prefix = "new_name_prefix" -# # name_suffix = "new_name_suffix" -# -# ## Tags to be added (all values must be strings) -# # [processors.clone.tags] -# # additional_tag = "tag_value" - - -# # Convert values to another metric value type -# [[processors.converter]] -# ## Tags to convert -# ## -# ## The table key determines the target type, and the array of key-values -# ## select the keys to convert. The array may contain globs. -# ## = [...] -# [processors.converter.tags] -# string = [] -# integer = [] -# unsigned = [] -# boolean = [] -# float = [] -# -# ## Fields to convert -# ## -# ## The table key determines the target type, and the array of key-values -# ## select the keys to convert. The array may contain globs. -# ## = [...] -# [processors.converter.fields] -# tag = [] -# string = [] -# integer = [] -# unsigned = [] -# boolean = [] -# float = [] - - -# # Dates measurements, tags, and fields that pass through this filter. -# [[processors.date]] -# ## New tag to create -# tag_key = "month" -# -# ## Date format string, must be a representation of the Go "reference time" -# ## which is "Mon Jan 2 15:04:05 -0700 MST 2006". -# date_format = "Jan" -# -# ## Offset duration added to the date string when writing the new tag. -# # date_offset = "0s" -# -# ## Timezone to use when creating the tag. This can be set to one of -# ## "UTC", "Local", or to a location name in the IANA Time Zone database. -# ## example: timezone = "America/Los_Angeles" -# # timezone = "UTC" - - -# # Map enum values according to given table. -# [[processors.enum]] -# [[processors.enum.mapping]] -# ## Name of the field to map -# field = "status" -# -# ## Name of the tag to map -# # tag = "status" -# -# ## Destination tag or field to be used for the mapped value. By default the -# ## source tag or field is used, overwriting the original value. -# dest = "status_code" -# -# ## Default value to be used for all values not contained in the mapping -# ## table. When unset, the unmodified value for the field will be used if no -# ## match is found. -# # default = 0 -# -# ## Table of mappings -# [processors.enum.mapping.value_mappings] -# green = 1 -# amber = 2 -# red = 3 - - -# # Apply metric modifications using override semantics. -# [[processors.override]] -# ## All modifications on inputs and aggregators can be overridden: -# # name_override = "new_name" -# # name_prefix = "new_name_prefix" -# # name_suffix = "new_name_suffix" -# -# ## Tags to be added (all values must be strings) -# # [processors.override.tags] -# # additional_tag = "tag_value" - - -# # Parse a value in a specified field/tag(s) and add the result in a new metric -# [[processors.parser]] -# ## The name of the fields whose value will be parsed. -# parse_fields = [] -# -# ## If true, incoming metrics are not emitted. -# drop_original = false -# -# ## If set to override, emitted metrics will be merged by overriding the -# ## original metric using the newly parsed metrics. -# merge = "override" -# -# ## The dataformat to be read from files -# ## Each data format has its own unique set of configuration options, read -# ## more about them here: -# ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md -# data_format = "influx" - - -# # Rotate a single valued metric into a multi field metric -# [[processors.pivot]] -# ## Tag to use for naming the new field. -# tag_key = "name" -# ## Field to use as the value of the new field. -# value_key = "value" - - -# # Print all metrics that pass through this filter. -# [[processors.printer]] - - -# # Transforms tag and field values with regex pattern -# [[processors.regex]] -# ## Tag and field conversions defined in a separate sub-tables -# # [[processors.regex.tags]] -# # ## Tag to change -# # key = "resp_code" -# # ## Regular expression to match on a tag value -# # pattern = "^(\\d)\\d\\d$" -# # ## Matches of the pattern will be replaced with this string. Use ${1} -# # ## notation to use the text of the first submatch. -# # replacement = "${1}xx" -# -# # [[processors.regex.fields]] -# # ## Field to change -# # key = "request" -# # ## All the power of the Go regular expressions available here -# # ## For example, named subgroups -# # pattern = "^/api(?P/[\\w/]+)\\S*" -# # replacement = "${method}" -# # ## If result_key is present, a new field will be created -# # ## instead of changing existing field -# # result_key = "method" -# -# ## Multiple conversions may be applied for one field sequentially -# ## Let's extract one more value -# # [[processors.regex.fields]] -# # key = "request" -# # pattern = ".*category=(\\w+).*" -# # replacement = "${1}" -# # result_key = "search_category" - - -# # Rename measurements, tags, and fields that pass through this filter. -# [[processors.rename]] - - -# # Perform string processing on tags, fields, and measurements -# [[processors.strings]] -# ## Convert a tag value to uppercase -# # [[processors.strings.uppercase]] -# # tag = "method" -# -# ## Convert a field value to lowercase and store in a new field -# # [[processors.strings.lowercase]] -# # field = "uri_stem" -# # dest = "uri_stem_normalised" -# -# ## Convert a field value to titlecase -# # [[processors.strings.titlecase]] -# # field = "status" -# -# ## Trim leading and trailing whitespace using the default cutset -# # [[processors.strings.trim]] -# # field = "message" -# -# ## Trim leading characters in cutset -# # [[processors.strings.trim_left]] -# # field = "message" -# # cutset = "\t" -# -# ## Trim trailing characters in cutset -# # [[processors.strings.trim_right]] -# # field = "message" -# # cutset = "\r\n" -# -# ## Trim the given prefix from the field -# # [[processors.strings.trim_prefix]] -# # field = "my_value" -# # prefix = "my_" -# -# ## Trim the given suffix from the field -# # [[processors.strings.trim_suffix]] -# # field = "read_count" -# # suffix = "_count" -# -# ## Replace all non-overlapping instances of old with new -# # [[processors.strings.replace]] -# # measurement = "*" -# # old = ":" -# # new = "_" -# -# ## Trims strings based on width -# # [[processors.strings.left]] -# # field = "message" -# # width = 10 -# -# ## Decode a base64 encoded utf-8 string -# # [[processors.strings.base64decode]] -# # field = "message" - - -# # Restricts the number of tags that can pass through this filter and chooses which tags to preserve when over the limit. -# [[processors.tag_limit]] -# ## Maximum number of tags to preserve -# limit = 10 -# -# ## List of tags to preferentially preserve -# keep = ["foo", "bar", "baz"] - - -# # Uses a Go template to create a new tag -# [[processors.template]] -# ## Tag to set with the output of the template. -# tag = "topic" -# -# ## Go template used to create the tag value. In order to ease TOML -# ## escaping requirements, you may wish to use single quotes around the -# ## template string. -# template = '{{ .Tag "hostname" }}.{{ .Tag "level" }}' - - -# # Print all metrics that pass through this filter. -# [[processors.topk]] -# ## How many seconds between aggregations -# # period = 10 -# -# ## How many top metrics to return -# # k = 10 -# -# ## Over which tags should the aggregation be done. Globs can be specified, in -# ## which case any tag matching the glob will aggregated over. If set to an -# ## empty list is no aggregation over tags is done -# # group_by = ['*'] -# -# ## Over which fields are the top k are calculated -# # fields = ["value"] -# -# ## What aggregation to use. Options: sum, mean, min, max -# # aggregation = "mean" -# -# ## Instead of the top k largest metrics, return the bottom k lowest metrics -# # bottomk = false -# -# ## The plugin assigns each metric a GroupBy tag generated from its name and -# ## tags. If this setting is different than "" the plugin will add a -# ## tag (which name will be the value of this setting) to each metric with -# ## the value of the calculated GroupBy tag. Useful for debugging -# # add_groupby_tag = "" -# -# ## These settings provide a way to know the position of each metric in -# ## the top k. The 'add_rank_field' setting allows to specify for which -# ## fields the position is required. If the list is non empty, then a field -# ## will be added to each and every metric for each string present in this -# ## setting. This field will contain the ranking of the group that -# ## the metric belonged to when aggregated over that field. -# ## The name of the field will be set to the name of the aggregation field, -# ## suffixed with the string '_topk_rank' -# # add_rank_fields = [] -# -# ## These settings provide a way to know what values the plugin is generating -# ## when aggregating metrics. The 'add_agregate_field' setting allows to -# ## specify for which fields the final aggregation value is required. If the -# ## list is non empty, then a field will be added to each every metric for -# ## each field present in this setting. This field will contain -# ## the computed aggregation for the group that the metric belonged to when -# ## aggregated over that field. -# ## The name of the field will be set to the name of the aggregation field, -# ## suffixed with the string '_topk_aggregate' -# # add_aggregate_fields = [] - - -# # Rotate multi field metric into several single field metrics -# [[processors.unpivot]] -# ## Tag to use for the name. -# tag_key = "name" -# ## Field to use for the name of the value. -# value_key = "value" - - -############################################################################### -# AGGREGATOR PLUGINS # -############################################################################### - - -# # Keep the aggregate basicstats of each metric passing through. -# [[aggregators.basicstats]] -# ## The period on which to flush & clear the aggregator. -# period = "30s" -# -# ## If true, the original metric will be dropped by the -# ## aggregator and will not get sent to the output plugins. -# drop_original = false -# -# ## Configures which basic stats to push as fields -# # stats = ["count", "min", "max", "mean", "stdev", "s2", "sum"] - - -# # Report the final metric of a series -# [[aggregators.final]] -# ## The period on which to flush & clear the aggregator. -# period = "30s" -# ## If true, the original metric will be dropped by the -# ## aggregator and will not get sent to the output plugins. -# drop_original = false -# -# ## The time that a series is not updated until considering it final. -# series_timeout = "5m" - - -# # Create aggregate histograms. -# [[aggregators.histogram]] -# ## The period in which to flush the aggregator. -# period = "30s" -# -# ## If true, the original metric will be dropped by the -# ## aggregator and will not get sent to the output plugins. -# drop_original = false -# -# ## If true, the histogram will be reset on flush instead -# ## of accumulating the results. -# reset = false -# -# ## Example config that aggregates all fields of the metric. -# # [[aggregators.histogram.config]] -# # ## The set of buckets. -# # buckets = [0.0, 15.6, 34.5, 49.1, 71.5, 80.5, 94.5, 100.0] -# # ## The name of metric. -# # measurement_name = "cpu" -# -# ## Example config that aggregates only specific fields of the metric. -# # [[aggregators.histogram.config]] -# # ## The set of buckets. -# # buckets = [0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0] -# # ## The name of metric. -# # measurement_name = "diskio" -# # ## The concrete fields of metric -# # fields = ["io_time", "read_time", "write_time"] - - -# # Merge metrics into multifield metrics by series key -# [[aggregators.merge]] -# ## If true, the original metric will be dropped by the -# ## aggregator and will not get sent to the output plugins. -# drop_original = true - - -# # Keep the aggregate min/max of each metric passing through. -# [[aggregators.minmax]] -# ## General Aggregator Arguments: -# ## The period on which to flush & clear the aggregator. -# period = "30s" -# ## If true, the original metric will be dropped by the -# ## aggregator and will not get sent to the output plugins. -# drop_original = false - - -# # Count the occurrence of values in fields. -# [[aggregators.valuecounter]] -# ## General Aggregator Arguments: -# ## The period on which to flush & clear the aggregator. -# period = "30s" -# ## If true, the original metric will be dropped by the -# ## aggregator and will not get sent to the output plugins. -# drop_original = false -# ## The fields for which the values will be counted -# fields = [] - - -############################################################################### -# INPUT PLUGINS # -############################################################################### - - -# Read CPU, Fans, Powersupply and Voltage metrics of Dell/HP hardware server through redfish APIs -[[inputs.redfish]] -## Server OOB-IP -host = "https://10.75.112.108" - -## Username,Password for hardware server -basicauthusername = "corona" -basicauthpassword = "Babylon1" -## Server Vendor(dell or hp) -server= "dell" -## Resource Id for redfish APIs -id="System.Embedded.1" -## Optional TLS Config -# tls_ca = "/etc/telegraf/ca.pem" -# tls_cert = "/etc/telegraf/cert.pem" -# tls_key = "/etc/telegraf/key.pem" -## Use TLS but skip chain & host verification -insecure_skip_verify = true - -## Amount of time allowed to complete the HTTP request - timeout = "5s" - From 06e6e4aeb5a6c68090265cc4cd3dec72f3f1822a Mon Sep 17 00:00:00 2001 From: sarvanikonda Date: Mon, 18 May 2020 19:55:49 +0530 Subject: [PATCH 07/12] changes made as requested --- plugins/inputs/redfish/README.md | 284 ++++++------- plugins/inputs/redfish/redfish.go | 439 ++++++++++--------- plugins/inputs/redfish/redfish_test.go | 562 ++++++++++++------------- 3 files changed, 625 insertions(+), 660 deletions(-) diff --git a/plugins/inputs/redfish/README.md b/plugins/inputs/redfish/README.md index 10a76c8a82c4d..514475e13afe0 100644 --- a/plugins/inputs/redfish/README.md +++ b/plugins/inputs/redfish/README.md @@ -1,165 +1,157 @@ # Redfish Input Plugin -The `redfish` plugin gathers metrics and status information about CPU temperature, fanspeed, Powersupply, voltage, hostname and Location details(datacenter,placement,rack and room) of Dell hardware servers for which redfish is enabled. -And also metrics like CPU temperature,fanspeed, Powersupply and hostname metrics for HP Hardware server(redfish should be enabled). - -Note: Currently this plugin only supports DELL and HP servers. - +The `redfish` plugin gathers metrics and status information about CPU temperature, fanspeed, Powersupply, voltage, hostname and Location details(datacenter,placement,rack and room) of hardware servers for which redfish is enabled. ### Configuration ```toml [[inputs.redfish]] -## Server OOB-IP -host = "http://192.0.0.1" - -## Username,Password for hardware server -basicauthusername = "test" -basicauthpassword = "test" -## Server Vendor(dell or hp) -server= "dell" -## Resource Id for redfish APIs -id="System.Embedded.1" -## Optional TLS Config -# tls_ca = "/etc/telegraf/ca.pem" -# tls_cert = "/etc/telegraf/cert.pem" -# tls_key = "/etc/telegraf/key.pem" -## Use TLS but skip chain & host verification -# insecure_skip_verify = false - -## Amount of time allowed to complete the HTTP request -# timeout = "5s" + ## Server OOB-IP + host = "192.0.0.1" + + ## Username,Password for hardware server + username = "test" + password = "test" + + ## Resource Id for redfish APIs + id="System.Embedded.1" + + ## Optional TLS Config, if not provided insecure skip verifies defaults to true + # tls_ca = "/etc/telegraf/ca.pem" + # tls_cert = "/etc/telegraf/cert.pem" + # tls_key = "/etc/telegraf/key.pem" + + ## Amount of time allowed to complete the HTTP request + # timeout = "5s" ``` ### Metrics for Dell Servers -- cpu_temperatures - - tags: - - hostname - - name - - oob_ip - - host - - Fields: - - datacenter - - temperature - - health - - rack - - room - - row - - state - -- fans - - tags: - - hostname - - name - - oob_ip - - host - - Fields: - - datacenter - - fanspeed - - health - - rack - - room - - row - - state - -- voltages - - tags: - - hostname - - name - - oob_ip - - host - - Fields: - - datacenter - - voltage - - health - - rack - - room - - row - - state - -- Powersupply - - tags: - - hostname - - name - - oobip - - host - - Fields: - - datacenter - - health - - power_capacity_watts - - power_input_watts - - power_output_watts - - rack - - room - - row - - state - -### Metrics for HP Servers - -- cpu_temperature - - tags: - - hostname - - name - - oob_ip - - host - - Fields: - - temperature - - health - - state - -- fans - - tags: - - hostname - - name - - oob_ip - - host - - Fields: - - fanspeed - - health - - state -- Powersupply - - tags: - - hostname - - name - - oob_ip - - host - - member_id - - Fields: - - power_capacity_watts - - last_powerOutput_watts - - line_input_voltage - -### Example Output For HP +- redfish_power_powersupplies + - tags: + - source_ip + - name + - datacenter + - rack + - room + - row + - state + - health + - Fields: + - last_power_output_watts + - line_input_voltage + - power_capacity_watts + - power_input_watts + - power_output_watts + +- redfish_power_voltages + - tags: + - source_ip + - name + - datacenter + - rack + - room + - row + - state + - health + - Fields: + - voltage + +- redfish_thermal_fans + - tags: + - source_ip + - name + - datacenter + - rack + - room + - row + - state + - health + - Fields: + - fanspeed + +- redfish_thermal_temperatures + - tags: + - source_ip + - name + - datacenter + - rack + - room + - row + - state + - health + - Fields: + - temperature + + +### Metrics if location details, voltage and power input/output data are not available in server APIs + +- redfish_power_powersupplies + - tags: + - health + - host + - name + - source_ip + - state + - Fields: + - last_power_output_watts + - line_input_voltage + - power_capacity_watts + +- redfish_thermal_fans + - tags: + - health + - host + - name + - source_ip + - state + - Fields: + - fanspeed + +- redfish_thermal_temperatures + - tags: + - health + - host + - name + - source_ip + - state + - Fields: + - temperature + + + + +### Example Output For Dell ``` -cpu_temperature,hostname=tpa_hostname,name=01-Inlet\ Ambient,oob_ip=http://127.0.0.1,host=tpa_po health="OK",state="Enabled",temperature="19" 1582612210000000000 -cpu_temperature,hostname=tpa_hostname,name=02-CPU\ 1,oob_ip=http://127.0.0.1,host=tpa_po health="OK",state="Enabled",temperature="40" 1582612210000000000 -fans,hostname=tpa_hostname,name=Fan\ 4,oob_ip=http://127.0.0.1,host=tpa_po fanspeed="23",health="OK",state="Enabled" 1582612210000000000 -fans,hostname=tpa_hostname,name=Fan\ 5,oob_ip=http://127.0.0.1,host=tpa_po fanspeed="23",health="OK",state="Enabled" 1582612210000000000 -fans,hostname=tpa_hostname,name=Fan\ 6,oob_ip=http://127.0.0.1,host=tpa_po fanspeed="23",health="OK",state="Enabled" 1582612210000000000 -fans,hostname=tpa_hostname,name=Fan\ 7,oob_ip=http://127.0.0.1,host=tpa_po fanspeed="23",health="OK",state="Enabled" 1582612210000000000 -powersupply,hostname=tpa_hostname,member_id=0,name=HpeServerPowerSupply,oob_ip=http://127.0.0.1,host=tpa_po last_power_output_watts="109",line_input_voltage="206",power_capacity_watts="800" 1582612210000000000 -powersupply,hostname=tpa_hostname,member_id=1,name=HpeServerPowerSupply,oob_ip=http://127.0.0.1,host=tpa_po last_power_output_watts="98",line_input_voltage="204",power_capacity_watts="800" 1582612210000000000 +redfish_thermal_temperatures,source=test-hostname,name=CPU1\ Temp,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" temperature="41" 1582114112000000000 +redfish_thermal_temperatures,source=test-hostname,name=CPU2\ Temp,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" temperature="51" 1582114112000000000 +redfish_thermal_temperatures,source=test-hostname,name=System\ Board\ Inlet\ Temp,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" temperature="23" 1582114112000000000 +redfish_thermal_temperatures,source=test-hostname,name=System\ Board\ Exhaust\ Temp,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" temperature="33" 1582114112000000000 +redfish_thermal_fans,source=test-hostname,name=System\ Board\ Fan1A,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" 1582114112000000000 +redfish_thermal_fans,source=test-hostname,name=System\ Board\ Fan1B,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" fanspeed="17760" 1582114112000000000 +redfish_thermal_fans,source=test-hostname,name=System\ Board\ Fan2A,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" fanspeed="17880" 1582114112000000000 +redfish_power_powersupplies,source=test-hostname,name=PS1\ Status,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" power_capacity_watts="750",power_input_watts="900",power_output_watts="208",last_power_output_watts="98",line_input_voltage="204" 1582114112000000000 +redfish_power_powersupplies,source=test-hostname,name=PS2\ Status,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" power_capacity_watts="750",power_input_watts="900",power_output_watts="194",last_power_output_watts="98",line_input_voltage="204" 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=CPU1\ MEM345\ VDDQ\ PG,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" voltage="1" 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=CPU1\ MEM345\ VPP\ PG,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" voltage="1" 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=CPU1\ MEM345\ VTT\ PG,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" voltage="1" 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=PS1\ voltage\ 1,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" voltage="208" 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=PS2\ voltage\ 2,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" voltage="208" 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=System\ Board\ 3.3V\ A\ PG,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" voltage="1" 1582114112000000000 + ``` -### Example Output For Dell + +### Example output if location details, voltage and power input/output data are not available in server APIs + ``` -cpu_temperature,hostname=test-hostname,name=CPU1\ Temp,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",temperature="41" 1582114112000000000 -cpu_temperature,hostname=test-hostname,name=CPU2\ Temp,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",temperature="51" 1582114112000000000 -cpu_temperature,hostname=test-hostname,name=System\ Board\ Inlet\ Temp,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",temperature="23" 1582114112000000000 -cpu_temperature,hostname=test-hostname,name=System\ Board\ Exhaust\ Temp,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",temperature="33" 1582114112000000000 -fans,hostname=test-hostname,name=System\ Board\ Fan1A,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",fanspeed="17760",health="OK",rack="12",room="tbc",row="3",state="Enabled" 1582114112000000000 -fans,hostname=test-hostname,name=System\ Board\ Fan1B,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",fanspeed="15360",health="OK",rack="12",room="tbc",row="3",state="Enabled" 1582114112000000000 -fans,hostname=test-hostname,name=System\ Board\ Fan2A,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",fanspeed="17880",health="OK",rack="12",room="tbc",row="3",state="Enabled" 1582114112000000000 -powersupply,hostname=test-hostname,name=PS1\ Status,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",power_capacity_watts="750",power_input_watts="900",power_output_watts="208",rack="12",room="tbc",row="3",state="Enabled" 1582114112000000000 -powersupply,hostname=test-hostname,name=PS2\ Status,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",power_capacity_watts="750",power_input_watts="900",power_output_watts="194",rack="12",room="tbc",row="3",state="Enabled" 1582114112000000000 -voltages,hostname=test-hostname,name=CPU1\ MEM345\ VDDQ\ PG,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",voltage="1" 1582114112000000000 -voltages,hostname=test-hostname,name=CPU1\ MEM345\ VPP\ PG,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",voltage="1" 1582114112000000000 -voltages,hostname=test-hostname,name=CPU1\ MEM345\ VTT\ PG,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",voltage="1" 1582114112000000000 -voltages,hostname=test-hostname,name=PS1\ voltage\ 1,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",Voltage="208" 1582114112000000000 -voltages,hostname=test-hostname,name=PS2\ voltage\ 2,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",Voltage="208" 1582114112000000000 -voltages,hostname=test-hostname,name=System\ Board\ 3.3V\ A\ PG,oob_ip=http://190.0.0.1,host=test-telegraf datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",voltage="1" 1582114112000000000 +redfish_thermal_temperatures,source=tpa_hostname,name=01-Inlet\ Ambient,source_ip=http://127.0.0.1,host=tpa_po,health="OK",state="Enabled" temperature="19" 1582612210000000000 +redfish_thermal_temperatures,source=tpa_hostname,name=02-CPU\ 1,source_ip=http://127.0.0.1,host=tpa_po,health="OK",state="Enabled" temperature="40" 1582612210000000000 +redfish_thermal_fans,source=tpa_hostname,name=Fan\ 4,source_ip=http://127.0.0.1,health="OK",state="Enabled",host=tpa_po fanspeed="23"1582612210000000000 +redfish_thermal_fans,source=tpa_hostname,name=Fan\ 5,source_ip=http://127.0.0.1,health="OK",state="Enabled",host=tpa_po fanspeed="28" 1582612210000000000 +redfish_power_powersupplies,source=tpa_hostname,name=HpeServerPowerSupply,source_ip=http://127.0.0.1,health="OK",state="Enabled",host=tpa_po last_power_output_watts="109",line_input_voltage="206",power_capacity_watts="800" 1582612210000000000 +redfish_power_powersupplies,source=tpa_hostname,name=HpeServerPowerSupply,source_ip=http://127.0.0.1,health="OK",state="Enabled",host=tpa_po last_power_output_watts="98",line_input_voltage="204",power_capacity_watts="800" 1582612210000000000 ``` diff --git a/plugins/inputs/redfish/redfish.go b/plugins/inputs/redfish/redfish.go index ee566734de392..496bf548bee19 100644 --- a/plugins/inputs/redfish/redfish.go +++ b/plugins/inputs/redfish/redfish.go @@ -1,6 +1,3 @@ -// Copyright 2020, Verizon -//Licensed under the terms of the MIT License. SEE LICENSE file in project root for terms. - package redfish import ( @@ -12,169 +9,77 @@ import ( "github.com/influxdata/telegraf/plugins/inputs" "io/ioutil" "net/http" - "strconv" + //"strconv" ) -type Hostname struct { - Hostname string `json:"HostName"` -} type Cpu struct { - Name string `json:"Name"` - Temperature int64 `json:"ReadingCelsius"` - Status CpuStatus `json:"Status"` + Name string `json:"Name"` + ReadingCelsius int64 `json:"ReadingCelsius"` + Status CpuStatus `json:"Status"` } -type Temperatures struct { - Temperatures []Cpu `json:"Temperatures"` +type Payload struct { + Temperatures []*Cpu `json:",omitempty"` + Fans []*speed `json:",omitempty"` + PowerSupplies []*Watt `json:",omitempty"` + Hostname string `json:",omitempty"` + Voltages []*volt `json:",omitempty"` + Location *Address `json:",omitempty"` } type CpuStatus struct { - State string `json:"State"` - Health string `json:"Health"` -} -type Fans struct { - Fans []speed `json:"Fans"` + State string + Health string } type speed struct { - Name string `json:"Name"` - Speed int64 `json:"Reading"` - Status FansStatus `json:"Status"` + Name string + Reading int64 + Status FansStatus } type FansStatus struct { State string `json:"State"` Health string `json:"Health"` } -type PowerSupplies struct { - PowerSupplies []watt `json:"PowerSupplies"` -} -type PowerSupplieshp struct { - PowerSupplieshp []watthp `json:"PowerSupplies"` -} -type watt struct { - Name string `json:"Name"` - PowerInputWatts float64 `json:"PowerInputWatts"` - PowerCapacityWatts float64 `json:"PowerCapacityWatts"` - PowerOutputWatts float64 `json:"PowerOutputWatts"` - Status PowerStatus `json:"Status"` -} -type watthp struct { - Name string `json:"Name"` - MemberID string `json:"MemberId"` - PowerCapacityWatts float64 `json:"PowerCapacityWatts"` - LastPowerOutputWatts float64 `json:"LastPowerOutputWatts"` - LineInputVoltage float64 `json:"LineInputVoltage"` +type Watt struct { + Name string `json:",omitempty"` + PowerInputWatts float64 `json:",omitempty"` + PowerCapacityWatts float64 `json:",omitempty"` + PowerOutputWatts float64 `json:",omitempty"` + LastPowerOutputWatts float64 `json:",omitempty"` + Status *PowerStatus `json:",omitempty"` + LineInputVoltage float64 `json:",omitempty"` } type PowerStatus struct { - State string `json:"State"` - Health string `json:"Health"` -} -type Voltages struct { - Voltages []volt `json:"Voltages"` + State string + Health string } type volt struct { - Name string `json:"Name"` - ReadingVolts int64 `json:"ReadingVolts"` - Status VoltStatus `json:"Status"` + Name string + ReadingVolts int64 + Status VoltStatus } type VoltStatus struct { - State string `json:"State"` - Health string `json:"Health"` -} -type Location struct { - Location Address `json:"Location"` + State string + Health string } type Address struct { - PostalAddress PostalAddress `json:"PostalAddress"` - Placement Placement `json:"Placement"` + PostalAddress PostalAddress + Placement Placement } type PostalAddress struct { - DataCenter string `json:"Building"` - Room string `json:"Room"` + DataCenter string + Room string } type Placement struct { - Rack string `json:"Rack"` - Row string `json:"Row"` + Rack string + Row string } type Redfish struct { Host string `toml:"host"` - BasicAuthUsername string `toml:"basicauthusername"` - BasicAuthPassword string `toml:"basicauthpassword"` + BasicAuthUsername string `toml:"username"` + BasicAuthPassword string `toml:"password"` Id string `toml:"id"` - Server string `toml:"server"` client http.Client tls.ClientConfig - Timeout internal.Duration `toml:"timeout"` - hostname Hostname - temperature Temperatures - fan Fans - powerdell PowerSupplies - voltage Voltages - powerhp PowerSupplieshp - location Location -} - -func (r *Redfish) getMetrics() error { - url := make(map[string]map[string]interface{}) - url["Thermal"] = make(map[string]interface{}) - url["Power"] = make(map[string]interface{}) - url["Hostname"] = make(map[string]interface{}) - url["Thermal"]["endpoint"] = fmt.Sprint(r.Host, "/redfish/v1/Chassis/", r.Id, "/Thermal") - url["Thermal"]["pointer"] = &r.temperature - url["Thermal"]["fanpointer"] = &r.fan - url["Power"]["endpoint"] = fmt.Sprint(r.Host, "/redfish/v1/Chassis/", r.Id, "/Power") - if r.Server == "dell" { - url["Power"]["pointer"] = &r.powerdell - url["Power"]["voltpointer"] = &r.voltage - } else if r.Server == "hp" { - url["Power"]["pointer"] = &r.powerhp - } - url["Hostname"]["endpoint"] = fmt.Sprint(r.Host, "/redfish/v1/Systems/", r.Id) - url["Hostname"]["pointer"] = &r.hostname - if r.Server == "dell" { - url["Location"] = make(map[string]interface{}) - url["Location"]["endpoint"] = fmt.Sprint(r.Host, "/redfish/v1/Chassis/", r.Id, "/") - url["Location"]["pointer"] = &r.location - } - - for key, value := range url { - req, err := http.NewRequest("GET", value["endpoint"].(string), nil) - if err != nil { - return err - } - req.SetBasicAuth(r.BasicAuthUsername, r.BasicAuthPassword) - req.Header.Set("Accept", "application/json") - req.Header.Set("Content-Type", "application/json") - resp, err := r.client.Do(req) - if err != nil { - return err - } - if resp.StatusCode == 200 { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return err - } - jsonErr := json.Unmarshal(body, value["pointer"]) - if jsonErr != nil { - return fmt.Errorf("error parsing input: %v", jsonErr) - } - if r.Server == "dell" && key == "Power" { - jsonErr = json.Unmarshal(body, value["voltpointer"]) - if jsonErr != nil { - return fmt.Errorf("error parsing input: %v", jsonErr) - } - - } else if key == "Thermal" { - jsonErr = json.Unmarshal(body, value["fanpointer"]) - if jsonErr != nil { - return fmt.Errorf("error parsing input: %v", jsonErr) - } - } - - } else { - return fmt.Errorf("received status code %d (%s), expected 200", - resp.StatusCode, - http.StatusText(resp.StatusCode)) - } - } - return nil + Timeout internal.Duration `toml:"timeout"` } func (r *Redfish) Description() string { @@ -182,25 +87,24 @@ func (r *Redfish) Description() string { } var redfishConfig = ` -## Server OOB-IP -host = "https://192.0.0.1" + ##Server OOB-IP + host = "192.0.0.1" + + ##Username, Password for hardware server + username = "test" + password = "test" -## Username,Password for hardware server -basicauthusername = "test" -basicauthpassword = "test" -## Server Vendor(dell or hp) -server= "dell" -## Resource Id for redfish APIs -id="System.Embedded.1" -## Optional TLS Config -# tls_ca = "/etc/telegraf/ca.pem" -# tls_cert = "/etc/telegraf/cert.pem" -# tls_key = "/etc/telegraf/key.pem" -## Use TLS but skip chain & host verification -# insecure_skip_verify = false + ##Resource Id for redfish APIs + id="System.Embedded.1" -## Amount of time allowed to complete the HTTP request -# timeout = "5s" + ##Optional TLS Config, if not provided insecure skip verifies defaults to true + #tls_ca = "/etc/telegraf/ca.pem" + #tls_cert = "/etc/telegraf/cert.pem" + #tls_key = "/etc/telegraf/key.pem" + + + ## Amount of time allowed to complete the HTTP request + # timeout = "5s" ` func (r *Redfish) SampleConfig() string { @@ -212,7 +116,14 @@ func (r *Redfish) Init() error { if err != nil { return err } - + if (len(r.ClientConfig.TLSCA) == 0) || (len(r.ClientConfig.TLSCert) == 0 && len(r.ClientConfig.TLSKey) == 0) { + var insecuretls tls.ClientConfig + insecuretls.InsecureSkipVerify = true + tlsCfg, err = insecuretls.TLSConfig() + if err != nil { + return err + } + } r.client = http.Client{ Transport: &http.Transport{ TLSClientConfig: tlsCfg, @@ -224,102 +135,176 @@ func (r *Redfish) Init() error { } func (r *Redfish) Gather(acc telegraf.Accumulator) error { + var url []string + var payload Payload + url = append(url, fmt.Sprint("https://", r.Host, "/redfish/v1/Chassis/", r.Id, "/Thermal"), fmt.Sprint("https://", r.Host, "/redfish/v1/Chassis/", r.Id, "/Power"), fmt.Sprint("https://", r.Host, "/redfish/v1/Systems/", r.Id), fmt.Sprint("https://", r.Host, "/redfish/v1/Chassis/", r.Id, "/")) if len(r.Host) == 0 || len(r.BasicAuthUsername) == 0 || len(r.BasicAuthPassword) == 0 { return fmt.Errorf("Did not provide IP or username and password") } - if len(r.Server) == 0 || len(r.Id) == 0 { - return fmt.Errorf("Did not provide all the mandatory fields in the configuration") - } - if !(r.Server == "dell" || r.Server == "hp") { - return fmt.Errorf("Did not provide correct server information, supported server details are dell or hp") - } - err := r.getMetrics() - if err != nil { - return err + if len(r.Id) == 0 { + return fmt.Errorf("Did not provide all the ID of the resource") } - for i := 0; i < len(r.temperature.Temperatures); i++ { - // Tags - tags := map[string]string{"oob_ip": r.Host, "name": r.temperature.Temperatures[i].Name, "hostname": r.hostname.Hostname} - // Fields - fields := make(map[string]interface{}) - fields["temperature"] = strconv.FormatInt(r.temperature.Temperatures[i].Temperature, 10) - fields["state"] = r.temperature.Temperatures[i].Status.State - fields["health"] = r.temperature.Temperatures[i].Status.Health - if r.Server == "dell" { - fields["datacenter"] = r.location.Location.PostalAddress.DataCenter - fields["room"] = r.location.Location.PostalAddress.Room - fields["rack"] = r.location.Location.Placement.Rack - fields["row"] = r.location.Location.Placement.Row - acc.AddFields("cpu_temperature", fields, tags) + for _, i := range url { + req, err := http.NewRequest("GET", i, nil) + if err != nil { + return err } - if r.Server == "hp" { - acc.AddFields("cpu_temperature", fields, tags) + req.SetBasicAuth(r.BasicAuthUsername, r.BasicAuthPassword) + req.Header.Set("Accept", "application/json") + req.Header.Set("Content-Type", "application/json") + resp, err := r.client.Do(req) + if err != nil { + return err + } + if resp.StatusCode == 200 { + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return fmt.Errorf("%v", err) + } + jsonErr := json.Unmarshal(body, &payload) + if jsonErr != nil { + return fmt.Errorf("error parsing input: %v", jsonErr) + } + + } else { + return fmt.Errorf("received status code %d (%s), expected 200", + resp.StatusCode, + http.StatusText(resp.StatusCode)) } } - for i := 0; i < len(r.fan.Fans); i++ { - // Tags - tags := map[string]string{"oob_ip": r.Host, "name": r.fan.Fans[i].Name, "hostname": r.hostname.Hostname} - // Fields - fields := make(map[string]interface{}) - fields["fanspeed"] = strconv.FormatInt(r.fan.Fans[i].Speed, 10) - fields["state"] = r.fan.Fans[i].Status.State - fields["health"] = r.fan.Fans[i].Status.Health - if r.Server == "dell" { - fields["datacenter"] = r.location.Location.PostalAddress.DataCenter - fields["room"] = r.location.Location.PostalAddress.Room - fields["rack"] = r.location.Location.Placement.Rack - fields["row"] = r.location.Location.Placement.Row - acc.AddFields("fans", fields, tags) + if payload.Location != nil { + for _, j := range payload.Temperatures { + // Tags + tags := map[string]string{} + tags["source_ip"] = r.Host + tags["name"] = j.Name + tags["source"] = payload.Hostname + tags["state"] = j.Status.State + tags["health"] = j.Status.Health + tags["datacenter"] = payload.Location.PostalAddress.DataCenter + tags["room"] = payload.Location.PostalAddress.Room + tags["rack"] = payload.Location.Placement.Rack + tags["row"] = payload.Location.Placement.Row + // Fields + fields := make(map[string]interface{}) + fields["temperature"] = j.ReadingCelsius + acc.AddFields("redfish_thermal_temperatures", fields, tags) } - if r.Server == "hp" { - acc.AddFields("fans", fields, tags) + for _, j := range payload.Fans { + // Tags + tags := map[string]string{} + tags["source_ip"] = r.Host + tags["name"] = j.Name + tags["source"] = payload.Hostname + tags["state"] = j.Status.State + tags["health"] = j.Status.Health + tags["datacenter"] = payload.Location.PostalAddress.DataCenter + tags["room"] = payload.Location.PostalAddress.Room + tags["rack"] = payload.Location.Placement.Rack + tags["row"] = payload.Location.Placement.Row + // Fields + fields := make(map[string]interface{}) + fields["fanspeed"] = j.Reading + acc.AddFields("redfish_thermal_fans", fields, tags) } - } - if r.Server == "dell" { - for i := 0; i < len(r.powerdell.PowerSupplies); i++ { + for _, j := range payload.PowerSupplies { // Tags - tags := map[string]string{"oob_ip": r.Host, "name": r.powerdell.PowerSupplies[i].Name, "hostname": r.hostname.Hostname} + tags := map[string]string{} + tags["source_ip"] = r.Host + tags["name"] = j.Name //j.Name + tags["source"] = payload.Hostname + tags["state"] = j.Status.State + tags["health"] = j.Status.Health + tags["datacenter"] = payload.Location.PostalAddress.DataCenter + tags["room"] = payload.Location.PostalAddress.Room + tags["rack"] = payload.Location.Placement.Rack + tags["row"] = payload.Location.Placement.Row // Fields fields := make(map[string]interface{}) - fields["power_input_watts"] = strconv.FormatFloat(r.powerdell.PowerSupplies[i].PowerInputWatts, 'f', -1, 64) - fields["power_capacity_watts"] = strconv.FormatFloat(r.powerdell.PowerSupplies[i].PowerCapacityWatts, 'f', -1, 64) - fields["power_output_watts"] = strconv.FormatFloat(r.powerdell.PowerSupplies[i].PowerOutputWatts, 'f', -1, 64) - fields["state"] = r.powerdell.PowerSupplies[i].Status.State - fields["health"] = r.powerdell.PowerSupplies[i].Status.Health - fields["datacenter"] = r.location.Location.PostalAddress.DataCenter - fields["room"] = r.location.Location.PostalAddress.Room - fields["rack"] = r.location.Location.Placement.Rack - fields["row"] = r.location.Location.Placement.Row - acc.AddFields("powersupply", fields, tags) + fields["power_input_watts"] = j.PowerInputWatts + fields["power_output_watts"] = j.PowerOutputWatts + fields["line_input_voltage"] = j.LineInputVoltage + fields["last_power_output_watts"] = j.LastPowerOutputWatts + fields["power_capacity_watts"] = j.PowerCapacityWatts + acc.AddFields("redfish_power_powersupplies", fields, tags) } - for i := 0; i < len(r.voltage.Voltages); i++ { + for _, j := range payload.Voltages { // Tags - tags := map[string]string{"oob_ip": r.Host, "name": r.voltage.Voltages[i].Name, "hostname": r.hostname.Hostname} + tags := map[string]string{} + tags["source_ip"] = r.Host + tags["name"] = j.Name + tags["source"] = payload.Hostname + tags["state"] = j.Status.State + tags["health"] = j.Status.Health + tags["datacenter"] = payload.Location.PostalAddress.DataCenter + tags["room"] = payload.Location.PostalAddress.Room + tags["rack"] = payload.Location.Placement.Rack + tags["row"] = payload.Location.Placement.Row // Fields fields := make(map[string]interface{}) - fields["voltage"] = strconv.FormatInt(r.voltage.Voltages[i].ReadingVolts, 10) - fields["state"] = r.voltage.Voltages[i].Status.State - fields["health"] = r.voltage.Voltages[i].Status.Health - fields["datacenter"] = r.location.Location.PostalAddress.DataCenter - fields["room"] = r.location.Location.PostalAddress.Room - fields["rack"] = r.location.Location.Placement.Rack - fields["row"] = r.location.Location.Placement.Row - acc.AddFields("voltages", fields, tags) + fields["voltage"] = j.ReadingVolts + acc.AddFields("redfish_power_voltages", fields, tags) } - - } - if r.Server == "hp" { - for i := 0; i < len(r.powerhp.PowerSupplieshp); i++ { + } else { + for _, j := range payload.Temperatures { + // Tags + tags := map[string]string{} + tags["source_ip"] = r.Host + tags["name"] = j.Name + tags["source"] = payload.Hostname + tags["state"] = j.Status.State + tags["health"] = j.Status.Health + // Fields + fields := make(map[string]interface{}) + fields["temperature"] = j.ReadingCelsius + acc.AddFields("redfish_thermal_temperatures", fields, tags) + } + for _, j := range payload.Fans { + // Tags + tags := map[string]string{} + tags["source_ip"] = r.Host + tags["name"] = j.Name + tags["source"] = payload.Hostname + tags["state"] = j.Status.State + tags["health"] = j.Status.Health + // Fields + fields := make(map[string]interface{}) + fields["fanspeed"] = j.Reading + acc.AddFields("redfish_thermal_fans", fields, tags) + } + for _, j := range payload.PowerSupplies { + // Tags + tags := map[string]string{} + tags["source_ip"] = r.Host + tags["name"] = j.Name //j.Name + tags["source"] = payload.Hostname + tags["state"] = j.Status.State + tags["health"] = j.Status.Health + // Fields + fields := make(map[string]interface{}) + /* if (j.PowerInputWatts != 0){ + fields["power_input_watts"] = j.PowerInputWatts + fields["power_output_watts"] = j.PowerOutputWatts + }*/ + fields["line_input_voltage"] = j.LineInputVoltage + fields["last_power_output_watts"] = j.LastPowerOutputWatts + fields["power_capacity_watts"] = j.PowerCapacityWatts + acc.AddFields("redfish_power_powersupplies", fields, tags) + } + for _, j := range payload.Voltages { // Tags - tags := map[string]string{"oob_ip": r.Host, "name": r.powerhp.PowerSupplieshp[i].Name, "member_id": r.powerhp.PowerSupplieshp[i].MemberID, "hostname": r.hostname.Hostname} + tags := map[string]string{} + tags["source_ip"] = r.Host + tags["name"] = j.Name + tags["source"] = payload.Hostname + tags["state"] = j.Status.State + tags["health"] = j.Status.Health // Fields fields := make(map[string]interface{}) - fields["line_input_voltage"] = strconv.FormatFloat(r.powerhp.PowerSupplieshp[i].LineInputVoltage, 'f', -1, 64) - fields["power_capacity_watts"] = strconv.FormatFloat(r.powerhp.PowerSupplieshp[i].PowerCapacityWatts, 'f', -1, 64) - fields["last_power_output_watts"] = strconv.FormatFloat(r.powerhp.PowerSupplieshp[i].LastPowerOutputWatts, 'f', -1, 64) - acc.AddFields("powersupply", fields, tags) + fields["voltage"] = j.ReadingVolts + acc.AddFields("redfish_power_voltages", fields, tags) } } diff --git a/plugins/inputs/redfish/redfish_test.go b/plugins/inputs/redfish/redfish_test.go index c78b91ab4c5de..32349b4826d62 100644 --- a/plugins/inputs/redfish/redfish_test.go +++ b/plugins/inputs/redfish/redfish_test.go @@ -1,9 +1,7 @@ -// Copyright 2020, Verizon -//Licensed under the terms of the MIT License. SEE LICENSE file in project root for terms. - package redfish import ( + "net" "net/http" "net/http/httptest" "testing" @@ -11,12 +9,13 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/testutil" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + // "github.com/influxdata/telegraf/internal/tls" ) func TestApis(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if !checkAuth(r, "test", "test") { http.Error(w, "Unauthorized.", 401) @@ -38,111 +37,122 @@ func TestApis(t *testing.T) { http.ServeFile(w, r, "testdata/hp_power.json") case "/redfish/v1/Systems/System.Embedded.2": http.ServeFile(w, r, "testdata/hp_hostname.json") + case "/redfish/v1/Chassis/System.Embedded.2/": + http.ServeFile(w, r, "testdata/hp_power.json") default: panic("Cannot handle request") } })) + CUSTOM_URL := "127.0.0.1:3458" + l, _ := net.Listen("tcp", CUSTOM_URL) + ts.Listener = l + ts.StartTLS() defer ts.Close() + //ts.StartTLS() + //defer ts.Close() + expected_metrics_hp := []telegraf.Metric{ testutil.MustMetric( - "cpu_temperature", + "redfish_thermal_temperatures", map[string]string{ - "name": "01-Inlet Ambient", - "hostname": "tpa-hostname", - "oob_ip": ts.URL, + "name": "01-Inlet Ambient", + "source": "tpa-hostname", + "source_ip": CUSTOM_URL, + "health": "OK", + "state": "Enabled", }, map[string]interface{}{ - "health": "OK", - "state": "Enabled", - "temperature": "19", + "temperature": 19, }, time.Unix(0, 0), ), testutil.MustMetric( - "cpu_temperature", + "redfish_thermal_temperatures", map[string]string{ - "name": "44-P/S 2 Zone", - "hostname": "tpa-hostname", - "oob_ip": ts.URL, + "name": "44-P/S 2 Zone", + "source": "tpa-hostname", + "source_ip": CUSTOM_URL, + "health": "OK", + "state": "Enabled", }, map[string]interface{}{ - "health": "OK", - "state": "Enabled", - "temperature": "34", + "temperature": 34, }, time.Unix(0, 0), ), testutil.MustMetric( - "fans", + "redfish_thermal_fans", map[string]string{ - "hostname": "tpa-hostname", - "name": "Fan 1", - "oob_ip": ts.URL, + "source": "tpa-hostname", + "name": "Fan 1", + "source_ip": CUSTOM_URL, + "health": "OK", + "state": "Enabled", }, map[string]interface{}{ - "fanspeed": "23", - "health": "OK", - "state": "Enabled", + "fanspeed": 23, }, time.Unix(0, 0), ), testutil.MustMetric( - "fans", + "redfish_thermal_fans", map[string]string{ - "hostname": "tpa-hostname", - "name": "Fan 2", - "oob_ip": ts.URL, + "source": "tpa-hostname", + "name": "Fan 2", + "source_ip": CUSTOM_URL, + "health": "OK", + "state": "Enabled", }, map[string]interface{}{ - "fanspeed": "23", - "health": "OK", - "state": "Enabled", + "fanspeed": 23, }, time.Unix(0, 0), ), testutil.MustMetric( - "fans", + "redfish_thermal_fans", map[string]string{ - "hostname": "tpa-hostname", - "name": "Fan 3", - "oob_ip": ts.URL, + "source": "tpa-hostname", + "name": "Fan 3", + "source_ip": CUSTOM_URL, + "health": "OK", + "state": "Enabled", }, map[string]interface{}{ - "fanspeed": "23", - "health": "OK", - "state": "Enabled", + "fanspeed": 23, }, time.Unix(0, 0), ), testutil.MustMetric( - "powersupply", + "redfish_power_powersupplies", map[string]string{ - "hostname": "tpa-hostname", + "source": "tpa-hostname", "name": "HpeServerPowerSupply", - "member_id": "0", - "oob_ip": ts.URL, + "source_ip": CUSTOM_URL, + "health": "OK", + "state": "Enabled", }, map[string]interface{}{ - "power_capacity_watts": "800", - "line_input_voltage": "205", - "last_power_output_watts": "0", + "power_capacity_watts": 800.0, + "line_input_voltage": 205.0, + "last_power_output_watts": 0.0, }, time.Unix(0, 0), ), testutil.MustMetric( - "powersupply", + "redfish_power_powersupplies", map[string]string{ - "hostname": "tpa-hostname", + "source": "tpa-hostname", "name": "HpeServerPowerSupply", - "member_id": "1", - "oob_ip": ts.URL, + "source_ip": CUSTOM_URL, + "health": "OK", + "state": "Enabled", }, map[string]interface{}{ - "power_capacity_watts": "800", - "line_input_voltage": "205", - "last_power_output_watts": "90", + "power_capacity_watts": 800.0, + "line_input_voltage": 205.0, + "last_power_output_watts": 90.0, }, time.Unix(0, 0), ), @@ -150,415 +160,416 @@ func TestApis(t *testing.T) { expected_metrics := []telegraf.Metric{ testutil.MustMetric( - "cpu_temperature", + "redfish_thermal_temperatures", map[string]string{ - "name": "CPU1 Temp", - "hostname": "tpa-hostname", - "oob_ip": ts.URL, + "name": "CPU1 Temp", + "source": "tpa-hostname", + "source_ip": CUSTOM_URL, + "datacenter": "", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", }, map[string]interface{}{ - "datacenter": "", - "health": "OK", - "rack": "", - "room": "", - "row": "", - "state": "Enabled", - "temperature": "40", + "temperature": 40, }, time.Unix(0, 0), ), testutil.MustMetric( - "fans", + "redfish_thermal_fans", map[string]string{ - "hostname": "tpa-hostname", - "name": "System Board Fan1A", - "oob_ip": ts.URL, - }, - map[string]interface{}{ + "source": "tpa-hostname", + "name": "System Board Fan1A", + "source_ip": CUSTOM_URL, "datacenter": "", - "fanspeed": "17760", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", }, + map[string]interface{}{ + "fanspeed": 17760, + }, time.Unix(0, 0), ), testutil.MustMetric( - "fans", + "redfish_thermal_fans", map[string]string{ - "hostname": "tpa-hostname", - "name": "System Board Fan1B", - "oob_ip": ts.URL, - }, - map[string]interface{}{ + "source": "tpa-hostname", + "name": "System Board Fan1B", + "source_ip": CUSTOM_URL, "datacenter": "", - "fanspeed": "15360", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", }, + map[string]interface{}{ + "fanspeed": 15360, + }, time.Unix(0, 0), ), testutil.MustMetric( - "fans", + "redfish_thermal_fans", map[string]string{ - "hostname": "tpa-hostname", - "name": "System Board Fan2A", - "oob_ip": ts.URL, - }, - map[string]interface{}{ + "source": "tpa-hostname", + "name": "System Board Fan2A", + "source_ip": CUSTOM_URL, "datacenter": "", - "fanspeed": "17880", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", }, + map[string]interface{}{ + "fanspeed": 17880, + }, time.Unix(0, 0), ), testutil.MustMetric( - "fans", + "redfish_thermal_fans", map[string]string{ - "hostname": "tpa-hostname", - "name": "System Board Fan2B", - "oob_ip": ts.URL, - }, - map[string]interface{}{ + "source": "tpa-hostname", + "name": "System Board Fan2B", + "source_ip": CUSTOM_URL, "datacenter": "", - "fanspeed": "15120", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", }, + map[string]interface{}{ + "fanspeed": 15120, + }, time.Unix(0, 0), ), testutil.MustMetric( - "fans", + "redfish_thermal_fans", map[string]string{ - "hostname": "tpa-hostname", - "name": "System Board Fan3A", - "oob_ip": ts.URL, - }, - map[string]interface{}{ + "source": "tpa-hostname", + "name": "System Board Fan3A", + "source_ip": CUSTOM_URL, "datacenter": "", - "fanspeed": "18000", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", }, + map[string]interface{}{ + "fanspeed": 18000, + }, time.Unix(0, 0), ), testutil.MustMetric( - "fans", + "redfish_thermal_fans", map[string]string{ - "hostname": "tpa-hostname", - "name": "System Board Fan3B", - "oob_ip": ts.URL, - }, - map[string]interface{}{ + "source": "tpa-hostname", + "name": "System Board Fan3B", + "source_ip": CUSTOM_URL, "datacenter": "", - "fanspeed": "15600", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", }, + map[string]interface{}{ + "fanspeed": 15600, + }, time.Unix(0, 0), ), testutil.MustMetric( - "fans", + "redfish_thermal_fans", map[string]string{ - "hostname": "tpa-hostname", - "name": "System Board Fan4A", - "oob_ip": ts.URL, - }, - map[string]interface{}{ + "source": "tpa-hostname", + "name": "System Board Fan4A", + "source_ip": CUSTOM_URL, "datacenter": "", - "fanspeed": "17280", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", }, + map[string]interface{}{ + "fanspeed": 17280, + }, time.Unix(0, 0), ), testutil.MustMetric( - "fans", + "redfish_thermal_fans", map[string]string{ - "hostname": "tpa-hostname", - "name": "System Board Fan4B", - "oob_ip": ts.URL, - }, - map[string]interface{}{ + "source": "tpa-hostname", + "name": "System Board Fan4B", + "source_ip": CUSTOM_URL, "datacenter": "", - "fanspeed": "15360", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", }, + map[string]interface{}{ + "fanspeed": 15360, + }, time.Unix(0, 0), ), testutil.MustMetric( - "fans", + "redfish_thermal_fans", map[string]string{ - "hostname": "tpa-hostname", - "name": "System Board Fan5A", - "oob_ip": ts.URL, - }, - map[string]interface{}{ + "source": "tpa-hostname", + "name": "System Board Fan5A", + "source_ip": CUSTOM_URL, "datacenter": "", - "fanspeed": "17640", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", }, + map[string]interface{}{ + "fanspeed": 17640, + }, time.Unix(0, 0), ), testutil.MustMetric( - "fans", + "redfish_thermal_fans", map[string]string{ - "hostname": "tpa-hostname", - "name": "System Board Fan5B", - "oob_ip": ts.URL, - }, - map[string]interface{}{ + "source": "tpa-hostname", + "name": "System Board Fan5B", + "source_ip": CUSTOM_URL, "datacenter": "", - "fanspeed": "15600", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", }, + map[string]interface{}{ + "fanspeed": 15600, + }, time.Unix(0, 0), ), testutil.MustMetric( - "fans", + "redfish_thermal_fans", map[string]string{ - "hostname": "tpa-hostname", - "name": "System Board Fan6A", - "oob_ip": ts.URL, - }, - map[string]interface{}{ + "source": "tpa-hostname", + "name": "System Board Fan6A", + "source_ip": CUSTOM_URL, "datacenter": "", - "fanspeed": "17760", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", }, + map[string]interface{}{ + "fanspeed": 17760, + }, time.Unix(0, 0), ), testutil.MustMetric( - "fans", + "redfish_thermal_fans", map[string]string{ - "hostname": "tpa-hostname", - "name": "System Board Fan6B", - "oob_ip": ts.URL, - }, - map[string]interface{}{ + "source": "tpa-hostname", + "name": "System Board Fan6B", + "source_ip": CUSTOM_URL, "datacenter": "", - "fanspeed": "15600", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", }, + map[string]interface{}{ + "fanspeed": 15600, + }, time.Unix(0, 0), ), testutil.MustMetric( - "fans", + "redfish_thermal_fans", map[string]string{ - "hostname": "tpa-hostname", - "name": "System Board Fan7A", - "oob_ip": ts.URL, - }, - map[string]interface{}{ + "source": "tpa-hostname", + "name": "System Board Fan7A", + "source_ip": CUSTOM_URL, "datacenter": "", - "fanspeed": "17400", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", }, + map[string]interface{}{ + "fanspeed": 17400, + }, time.Unix(0, 0), ), testutil.MustMetric( - "fans", + "redfish_thermal_fans", map[string]string{ - "hostname": "tpa-hostname", - "name": "System Board Fan7B", - "oob_ip": ts.URL, - }, - map[string]interface{}{ + "source": "tpa-hostname", + "name": "System Board Fan7B", + "source_ip": CUSTOM_URL, "datacenter": "", - "fanspeed": "15720", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", }, + map[string]interface{}{ + "fanspeed": 15720, + }, time.Unix(0, 0), ), testutil.MustMetric( - "fans", + "redfish_thermal_fans", map[string]string{ - "hostname": "tpa-hostname", - "name": "System Board Fan8A", - "oob_ip": ts.URL, - }, - map[string]interface{}{ + "source": "tpa-hostname", + "name": "System Board Fan8A", + "source_ip": CUSTOM_URL, "datacenter": "", - "fanspeed": "18000", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", }, + map[string]interface{}{ + "fanspeed": 18000, + }, time.Unix(0, 0), ), testutil.MustMetric( - "fans", + "redfish_thermal_fans", map[string]string{ - "hostname": "tpa-hostname", - "name": "System Board Fan8B", - "oob_ip": ts.URL, - }, - map[string]interface{}{ + "source": "tpa-hostname", + "name": "System Board Fan8B", + "source_ip": CUSTOM_URL, "datacenter": "", - "fanspeed": "15840", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", }, + map[string]interface{}{ + "fanspeed": 15840, + }, time.Unix(0, 0), ), testutil.MustMetric( - "powersupply", + "redfish_power_powersupplies", map[string]string{ - "hostname": "tpa-hostname", - "name": "PS1 Status", - "oob_ip": ts.URL, + "source": "tpa-hostname", + "name": "PS1 Status", + "source_ip": CUSTOM_URL, + "datacenter": "", + "health": "OK", + "rack": "", + "room": "", + "row": "", + "state": "Enabled", }, map[string]interface{}{ - "datacenter": "", - "health": "OK", - "rack": "", - "room": "", - "row": "", - "state": "Enabled", - "power_capacity_watts": "750", - "power_input_watts": "900", - "power_output_watts": "203", + "power_capacity_watts": 750.0, + "power_input_watts": 900.0, + "power_output_watts": 203.0, + "last_power_output_watts": 0.0, + "line_input_voltage": 206.0, }, time.Unix(0, 0), ), testutil.MustMetric( - "voltages", + "redfish_power_voltages", map[string]string{ - "hostname": "tpa-hostname", - "name": "System Board DIMM PG", - "oob_ip": ts.URL, - }, - map[string]interface{}{ + "source": "tpa-hostname", + "name": "System Board DIMM PG", + "source_ip": CUSTOM_URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "voltage": "1", + }, + map[string]interface{}{ + "voltage": 1, }, time.Unix(0, 0), ), testutil.MustMetric( - "voltages", + "redfish_power_voltages", map[string]string{ - "hostname": "tpa-hostname", - "name": "System Board NDC PG", - "oob_ip": ts.URL, - }, - map[string]interface{}{ + "source": "tpa-hostname", + "name": "System Board NDC PG", + "source_ip": CUSTOM_URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "voltage": "1", + }, + map[string]interface{}{ + "voltage": 1, }, time.Unix(0, 0), ), testutil.MustMetric( - "voltages", + "redfish_power_voltages", map[string]string{ - "hostname": "tpa-hostname", - "name": "System Board PS1 PG FAIL", - "oob_ip": ts.URL, - }, - map[string]interface{}{ + "source": "tpa-hostname", + "name": "System Board PS1 PG FAIL", + "source_ip": CUSTOM_URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "voltage": "1", + }, + map[string]interface{}{ + "voltage": 1, }, time.Unix(0, 0), ), } plugin := &Redfish{ - Host: ts.URL, + Host: "127.0.0.1:3458", BasicAuthUsername: "test", BasicAuthPassword: "test", Id: "System.Embedded.1", - Server: "dell", - // insecure_skip_verify : "true", } plugin.Init() var acc testutil.Accumulator - _ = plugin.Gather(&acc) - assert.True(t, acc.HasMeasurement("cpu_temperature")) + err := plugin.Gather(&acc) + require.NoError(t, err) + require.True(t, acc.HasMeasurement("redfish_thermal_temperatures")) testutil.RequireMetricsEqual(t, expected_metrics, acc.GetTelegrafMetrics(), testutil.IgnoreTime()) hp_plugin := &Redfish{ - Host: ts.URL, + Host: "127.0.0.1:3458", BasicAuthUsername: "test", BasicAuthPassword: "test", Id: "System.Embedded.2", - Server: "hp", } hp_plugin.Init() var hp_acc testutil.Accumulator - _ = hp_plugin.Gather(&hp_acc) - assert.True(t, hp_acc.HasMeasurement("cpu_temperature")) + err = hp_plugin.Gather(&hp_acc) + require.NoError(t, err) + require.True(t, hp_acc.HasMeasurement("redfish_thermal_temperatures")) testutil.RequireMetricsEqual(t, expected_metrics_hp, hp_acc.GetTelegrafMetrics(), testutil.IgnoreTime()) } @@ -574,12 +585,10 @@ func checkAuth(r *http.Request, username, password string) bool { func TestConnection(t *testing.T) { r := &Redfish{ - Host: "https://127.0.0.1", + Host: "127.0.0.1", BasicAuthUsername: "test", BasicAuthPassword: "test", Id: "System.Embedded.1", - Server: "dell", - //insecure_skip_verify : "true", } var acc testutil.Accumulator @@ -587,15 +596,13 @@ func TestConnection(t *testing.T) { r.Init() err := r.Gather(&acc) - - if assert.Error(t, err) { - assert.Contains(t, err.Error(), "connect: connection refused") - } + require.Error(t, err) + require.Contains(t, err.Error(), "connect: connection refused") } func TestInvalidUsernameorPassword(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if !checkAuth(r, "testing", "testing") { http.Error(w, "Unauthorized.", 401) @@ -609,25 +616,28 @@ func TestInvalidUsernameorPassword(t *testing.T) { panic("Cannot handle request") } })) - + CUSTOM_URL := "127.0.0.1:3458" + l, _ := net.Listen("tcp", CUSTOM_URL) + ts.Listener = l + ts.StartTLS() defer ts.Close() r := &Redfish{ - Host: ts.URL, + Host: CUSTOM_URL, BasicAuthUsername: "test", BasicAuthPassword: "test", Id: "System.Embedded.1", - Server: "dell", } var acc testutil.Accumulator r.Init() err := r.Gather(&acc) - assert.EqualError(t, err, "received status code 401 (Unauthorized), expected 200") + require.Error(t, err) + require.EqualError(t, err, "received status code 401 (Unauthorized), expected 200") } func TestNoUsernameorPasswordConfiguration(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if !checkAuth(r, "testing", "testing") { http.Error(w, "Unauthorized.", 401) @@ -641,52 +651,22 @@ func TestNoUsernameorPasswordConfiguration(t *testing.T) { panic("Cannot handle request") } })) - - defer ts.Close() - - r := &Redfish{ - Host: ts.URL, - Id: "System.Embedded.1", - Server: "dell", - } - - var acc testutil.Accumulator - r.Init() - err := r.Gather(&acc) - assert.EqualError(t, err, "Did not provide IP or username and password") -} - -func TestInvalidServerVarConfiguration(t *testing.T) { - - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - - if !checkAuth(r, "test", "test") { - http.Error(w, "Unauthorized.", 401) - return - } - - switch r.URL.Path { - case "/redfish/v1/Chassis/System.Embedded.1/Thermal": - http.ServeFile(w, r, "testdata/dell_thermal.json") - default: - panic("Cannot handle request") - } - })) - + CUSTOM_URL := "127.0.0.1:3458" + l, _ := net.Listen("tcp", CUSTOM_URL) + ts.Listener = l + ts.StartTLS() defer ts.Close() r := &Redfish{ - Host: ts.URL, - BasicAuthUsername: "test", - BasicAuthPassword: "test", - Id: "System.Embedded.1", - Server: "wtu", + Host: CUSTOM_URL, + Id: "System.Embedded.1", } var acc testutil.Accumulator r.Init() err := r.Gather(&acc) - assert.EqualError(t, err, "Did not provide correct server information, supported server details are dell or hp") + require.Error(t, err) + require.EqualError(t, err, "Did not provide IP or username and password") } func TestInvalidDellJSON(t *testing.T) { @@ -697,6 +677,7 @@ func TestInvalidDellJSON(t *testing.T) { powerfilename string locationfilename string hostnamefilename string + CUSTOM_URL string }{ { name: "check Thermal", @@ -704,6 +685,7 @@ func TestInvalidDellJSON(t *testing.T) { powerfilename: "testdata/dell_power.json", locationfilename: "testdata/dell_location.json", hostnamefilename: "testdata/dell_hostname.json", + CUSTOM_URL: "127.0.0.1:3459", }, { name: "check Power", @@ -711,6 +693,7 @@ func TestInvalidDellJSON(t *testing.T) { powerfilename: "testdata/dell_powerinvalid.json", locationfilename: "testdata/dell_location.json", hostnamefilename: "testdata/dell_hostname.json", + CUSTOM_URL: "127.0.0.1:3451", }, { name: "check Location", @@ -718,6 +701,7 @@ func TestInvalidDellJSON(t *testing.T) { powerfilename: "testdata/dell_power.json", locationfilename: "testdata/dell_locationinvalid.json", hostnamefilename: "testdata/dell_hostname.json", + CUSTOM_URL: "127.0.0.1:3452", }, { name: "check Hostname", @@ -725,10 +709,11 @@ func TestInvalidDellJSON(t *testing.T) { powerfilename: "testdata/dell_power.json", locationfilename: "testdata/dell_location.json", hostnamefilename: "testdata/dell_hostnameinvalid.json", + CUSTOM_URL: "127.0.0.1:3453", }, } for _, tt := range tests { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if !checkAuth(r, "test", "test") { http.Error(w, "Unauthorized.", 401) @@ -748,25 +733,25 @@ func TestInvalidDellJSON(t *testing.T) { panic("Cannot handle request") } })) - + //CUSTOM_URL := "127.0.0.1:3459" + l, _ := net.Listen("tcp", tt.CUSTOM_URL) + ts.Listener = l + ts.StartTLS() defer ts.Close() plugin := &Redfish{ - Host: ts.URL, + Host: tt.CUSTOM_URL, BasicAuthUsername: "test", BasicAuthPassword: "test", Id: "System.Embedded.1", - Server: "dell", } plugin.Init() var acc testutil.Accumulator err := plugin.Gather(&acc) - - if assert.Error(t, err) { - assert.Contains(t, err.Error(), "error parsing input:") - } + require.Error(t, err) + require.Contains(t, err.Error(), "error parsing input:") } } @@ -777,28 +762,32 @@ func TestInvalidHPJSON(t *testing.T) { thermalfilename string powerfilename string hostnamefilename string + CUSTOM_URL string }{ { name: "check Thermal", thermalfilename: "testdata/hp_thermalinvalid.json", powerfilename: "testdata/hp_power.json", hostnamefilename: "testdata/hp_hostname.json", + CUSTOM_URL: "127.0.0.1:3278", }, { name: "check Power", thermalfilename: "testdata/hp_thermal.json", powerfilename: "testdata/hp_powerinvalid.json", hostnamefilename: "testdata/hp_hostname.json", + CUSTOM_URL: "127.0.0.1:3289", }, { name: "check Hostname", thermalfilename: "testdata/hp_thermal.json", powerfilename: "testdata/hp_power.json", hostnamefilename: "testdata/hp_hostnameinvalid.json", + CUSTOM_URL: "127.0.0.1:3290", }, } for _, tt := range tests { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if !checkAuth(r, "test", "test") { http.Error(w, "Unauthorized.", 401) @@ -816,24 +805,23 @@ func TestInvalidHPJSON(t *testing.T) { panic("Cannot handle request") } })) - + l, _ := net.Listen("tcp", tt.CUSTOM_URL) + ts.Listener = l + ts.StartTLS() defer ts.Close() plugin := &Redfish{ - Host: ts.URL, + Host: tt.CUSTOM_URL, BasicAuthUsername: "test", BasicAuthPassword: "test", Id: "System.Embedded.2", - Server: "hp", } plugin.Init() var acc testutil.Accumulator err := plugin.Gather(&acc) - - if assert.Error(t, err) { - assert.Contains(t, err.Error(), "error parsing input:") - } + require.Error(t, err) + require.Contains(t, err.Error(), "error parsing input:") } } From 94d64b17b858648e675bcb85774de34860a3a472 Mon Sep 17 00:00:00 2001 From: sarvanikonda Date: Mon, 18 May 2020 20:03:43 +0530 Subject: [PATCH 08/12] removed commented lines in redfish_test.go --- plugins/inputs/redfish/redfish_test.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/plugins/inputs/redfish/redfish_test.go b/plugins/inputs/redfish/redfish_test.go index 32349b4826d62..d7a479f7cd547 100644 --- a/plugins/inputs/redfish/redfish_test.go +++ b/plugins/inputs/redfish/redfish_test.go @@ -10,7 +10,6 @@ import ( "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/testutil" "github.com/stretchr/testify/require" - // "github.com/influxdata/telegraf/internal/tls" ) func TestApis(t *testing.T) { @@ -50,9 +49,6 @@ func TestApis(t *testing.T) { ts.StartTLS() defer ts.Close() - //ts.StartTLS() - //defer ts.Close() - expected_metrics_hp := []telegraf.Metric{ testutil.MustMetric( "redfish_thermal_temperatures", @@ -733,7 +729,6 @@ func TestInvalidDellJSON(t *testing.T) { panic("Cannot handle request") } })) - //CUSTOM_URL := "127.0.0.1:3459" l, _ := net.Listen("tcp", tt.CUSTOM_URL) ts.Listener = l ts.StartTLS() From 93cf584639969f207a78c263e51a1e1a741dc2bb Mon Sep 17 00:00:00 2001 From: sarvanikonda Date: Tue, 19 May 2020 19:25:43 +0530 Subject: [PATCH 09/12] removed comments from redfish.go --- plugins/inputs/redfish/redfish.go | 30 +++++++++++--------------- plugins/inputs/redfish/redfish_test.go | 6 +++--- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/plugins/inputs/redfish/redfish.go b/plugins/inputs/redfish/redfish.go index 496bf548bee19..c8d7470081962 100644 --- a/plugins/inputs/redfish/redfish.go +++ b/plugins/inputs/redfish/redfish.go @@ -8,8 +8,8 @@ import ( "github.com/influxdata/telegraf/internal/tls" "github.com/influxdata/telegraf/plugins/inputs" "io/ioutil" + "math" "net/http" - //"strconv" ) type Cpu struct { @@ -53,7 +53,7 @@ type PowerStatus struct { } type volt struct { Name string - ReadingVolts int64 + ReadingVolts float64 Status VoltStatus } type VoltStatus struct { @@ -213,7 +213,7 @@ func (r *Redfish) Gather(acc telegraf.Accumulator) error { // Tags tags := map[string]string{} tags["source_ip"] = r.Host - tags["name"] = j.Name //j.Name + tags["name"] = j.Name tags["source"] = payload.Hostname tags["state"] = j.Status.State tags["health"] = j.Status.Health @@ -223,11 +223,11 @@ func (r *Redfish) Gather(acc telegraf.Accumulator) error { tags["row"] = payload.Location.Placement.Row // Fields fields := make(map[string]interface{}) - fields["power_input_watts"] = j.PowerInputWatts - fields["power_output_watts"] = j.PowerOutputWatts - fields["line_input_voltage"] = j.LineInputVoltage - fields["last_power_output_watts"] = j.LastPowerOutputWatts - fields["power_capacity_watts"] = j.PowerCapacityWatts + fields["power_input_watts"] = math.Round(j.PowerInputWatts*100) / 100 + fields["power_output_watts"] = math.Round(j.PowerOutputWatts*100) / 100 + fields["line_input_voltage"] = math.Round(j.LineInputVoltage*100) / 100 + fields["last_power_output_watts"] = math.Round(j.LastPowerOutputWatts*100) / 100 + fields["power_capacity_watts"] = math.Round(j.PowerCapacityWatts*100) / 100 acc.AddFields("redfish_power_powersupplies", fields, tags) } for _, j := range payload.Voltages { @@ -244,7 +244,7 @@ func (r *Redfish) Gather(acc telegraf.Accumulator) error { tags["row"] = payload.Location.Placement.Row // Fields fields := make(map[string]interface{}) - fields["voltage"] = j.ReadingVolts + fields["voltage"] = math.Round(j.ReadingVolts*100) / 100 acc.AddFields("redfish_power_voltages", fields, tags) } } else { @@ -284,13 +284,9 @@ func (r *Redfish) Gather(acc telegraf.Accumulator) error { tags["health"] = j.Status.Health // Fields fields := make(map[string]interface{}) - /* if (j.PowerInputWatts != 0){ - fields["power_input_watts"] = j.PowerInputWatts - fields["power_output_watts"] = j.PowerOutputWatts - }*/ - fields["line_input_voltage"] = j.LineInputVoltage - fields["last_power_output_watts"] = j.LastPowerOutputWatts - fields["power_capacity_watts"] = j.PowerCapacityWatts + fields["line_input_voltage"] = math.Round(j.LineInputVoltage*100) / 100 + fields["last_power_output_watts"] = math.Round(j.LastPowerOutputWatts*100) / 100 + fields["power_capacity_watts"] = math.Round(j.PowerCapacityWatts*100) / 100 acc.AddFields("redfish_power_powersupplies", fields, tags) } for _, j := range payload.Voltages { @@ -303,7 +299,7 @@ func (r *Redfish) Gather(acc telegraf.Accumulator) error { tags["health"] = j.Status.Health // Fields fields := make(map[string]interface{}) - fields["voltage"] = j.ReadingVolts + fields["voltage"] = math.Round(j.ReadingVolts*100) / 100 acc.AddFields("redfish_power_voltages", fields, tags) } } diff --git a/plugins/inputs/redfish/redfish_test.go b/plugins/inputs/redfish/redfish_test.go index d7a479f7cd547..bbee60df35f13 100644 --- a/plugins/inputs/redfish/redfish_test.go +++ b/plugins/inputs/redfish/redfish_test.go @@ -497,7 +497,7 @@ func TestApis(t *testing.T) { "state": "Enabled", }, map[string]interface{}{ - "voltage": 1, + "voltage": 1.0, }, time.Unix(0, 0), ), @@ -515,7 +515,7 @@ func TestApis(t *testing.T) { "state": "Enabled", }, map[string]interface{}{ - "voltage": 1, + "voltage": 1.0, }, time.Unix(0, 0), ), @@ -534,7 +534,7 @@ func TestApis(t *testing.T) { "state": "Enabled", }, map[string]interface{}{ - "voltage": 1, + "voltage": 1.0, }, time.Unix(0, 0), ), From 90151896ea7798283a4d2be75da0a9902567221d Mon Sep 17 00:00:00 2001 From: sarvanikonda Date: Tue, 26 May 2020 18:35:37 +0530 Subject: [PATCH 10/12] added threshold data --- plugins/inputs/redfish/README.md | 60 +++++++++----- plugins/inputs/redfish/redfish.go | 98 ++++++++++++++++------ plugins/inputs/redfish/redfish_test.go | 110 ++++++++++++++++++++----- 3 files changed, 199 insertions(+), 69 deletions(-) diff --git a/plugins/inputs/redfish/README.md b/plugins/inputs/redfish/README.md index 514475e13afe0..f33670f8a3cbd 100644 --- a/plugins/inputs/redfish/README.md +++ b/plugins/inputs/redfish/README.md @@ -55,8 +55,12 @@ The `redfish` plugin gathers metrics and status information about CPU temperatu - row - state - health + - severity - Fields: - voltage + - upper_threshold_critical + - upper_threshold_fatal + - redfish_thermal_fans - tags: @@ -68,8 +72,12 @@ The `redfish` plugin gathers metrics and status information about CPU temperatu - row - state - health + - severity - Fields: - fanspeed + - upper_threshold_critical + - upper_threshold_fatal + - redfish_thermal_temperatures - tags: @@ -81,8 +89,12 @@ The `redfish` plugin gathers metrics and status information about CPU temperatu - row - state - health + - severity - Fields: - temperature + - upper_threshold_critical + - upper_threshold_fatal + ### Metrics if location details, voltage and power input/output data are not available in server APIs @@ -106,8 +118,11 @@ The `redfish` plugin gathers metrics and status information about CPU temperatu - name - source_ip - state + - severity - Fields: - fanspeed + - upper_threshold_critical + - upper_threshold_fatal - redfish_thermal_temperatures - tags: @@ -116,29 +131,32 @@ The `redfish` plugin gathers metrics and status information about CPU temperatu - name - source_ip - state + - severity - Fields: - temperature + - upper_threshold_critical + - upper_threshold_fatal ### Example Output For Dell ``` -redfish_thermal_temperatures,source=test-hostname,name=CPU1\ Temp,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" temperature="41" 1582114112000000000 -redfish_thermal_temperatures,source=test-hostname,name=CPU2\ Temp,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" temperature="51" 1582114112000000000 -redfish_thermal_temperatures,source=test-hostname,name=System\ Board\ Inlet\ Temp,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" temperature="23" 1582114112000000000 -redfish_thermal_temperatures,source=test-hostname,name=System\ Board\ Exhaust\ Temp,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" temperature="33" 1582114112000000000 -redfish_thermal_fans,source=test-hostname,name=System\ Board\ Fan1A,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" 1582114112000000000 -redfish_thermal_fans,source=test-hostname,name=System\ Board\ Fan1B,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" fanspeed="17760" 1582114112000000000 -redfish_thermal_fans,source=test-hostname,name=System\ Board\ Fan2A,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" fanspeed="17880" 1582114112000000000 -redfish_power_powersupplies,source=test-hostname,name=PS1\ Status,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" power_capacity_watts="750",power_input_watts="900",power_output_watts="208",last_power_output_watts="98",line_input_voltage="204" 1582114112000000000 -redfish_power_powersupplies,source=test-hostname,name=PS2\ Status,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" power_capacity_watts="750",power_input_watts="900",power_output_watts="194",last_power_output_watts="98",line_input_voltage="204" 1582114112000000000 -redfish_power_voltages,source=test-hostname,name=CPU1\ MEM345\ VDDQ\ PG,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" voltage="1" 1582114112000000000 -redfish_power_voltages,source=test-hostname,name=CPU1\ MEM345\ VPP\ PG,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" voltage="1" 1582114112000000000 -redfish_power_voltages,source=test-hostname,name=CPU1\ MEM345\ VTT\ PG,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" voltage="1" 1582114112000000000 -redfish_power_voltages,source=test-hostname,name=PS1\ voltage\ 1,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" voltage="208" 1582114112000000000 -redfish_power_voltages,source=test-hostname,name=PS2\ voltage\ 2,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" voltage="208" 1582114112000000000 -redfish_power_voltages,source=test-hostname,name=System\ Board\ 3.3V\ A\ PG,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" voltage="1" 1582114112000000000 +redfish_thermal_temperatures,source=test-hostname,name=CPU1\ Temp,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" temperature=41,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_thermal_temperatures,source=test-hostname,name=CPU2\ Temp,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" temperature=51,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_thermal_temperatures,source=test-hostname,name=System\ Board\ Inlet\ Temp,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" temperature=23,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_thermal_temperatures,source=test-hostname,name=System\ Board\ Exhaust\ Temp,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" temperature=33,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_thermal_fans,source=test-hostname,name=System\ Board\ Fan1A,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" fanspeed=17720,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_thermal_fans,source=test-hostname,name=System\ Board\ Fan1B,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" fanspeed=17760,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_thermal_fans,source=test-hostname,name=System\ Board\ Fan2A,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" fanspeed=17880,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_power_powersupplies,source=test-hostname,name=PS1\ Status,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" power_capacity_watts=750,power_input_watts=900,power_output_watts=208,last_power_output_watts=98,line_input_voltage=204 1582114112000000000 +redfish_power_powersupplies,source=test-hostname,name=PS2\ Status,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" power_capacity_watts=750,power_input_watts=900,power_output_watts=194,last_power_output_watts=98,line_input_voltage=204 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=CPU1\ MEM345\ VDDQ\ PG,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" voltage=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=CPU1\ MEM345\ VPP\ PG,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" voltage=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=CPU1\ MEM345\ VTT\ PG,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" voltage=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=PS1\ voltage\ 1,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" voltage=208,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=PS2\ voltage\ 2,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" voltage=208,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=System\ Board\ 3.3V\ A\ PG,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" voltage=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 ``` @@ -147,11 +165,11 @@ redfish_power_voltages,source=test-hostname,name=System\ Board\ 3.3V\ A\ PG,sour ### Example output if location details, voltage and power input/output data are not available in server APIs ``` -redfish_thermal_temperatures,source=tpa_hostname,name=01-Inlet\ Ambient,source_ip=http://127.0.0.1,host=tpa_po,health="OK",state="Enabled" temperature="19" 1582612210000000000 -redfish_thermal_temperatures,source=tpa_hostname,name=02-CPU\ 1,source_ip=http://127.0.0.1,host=tpa_po,health="OK",state="Enabled" temperature="40" 1582612210000000000 -redfish_thermal_fans,source=tpa_hostname,name=Fan\ 4,source_ip=http://127.0.0.1,health="OK",state="Enabled",host=tpa_po fanspeed="23"1582612210000000000 -redfish_thermal_fans,source=tpa_hostname,name=Fan\ 5,source_ip=http://127.0.0.1,health="OK",state="Enabled",host=tpa_po fanspeed="28" 1582612210000000000 -redfish_power_powersupplies,source=tpa_hostname,name=HpeServerPowerSupply,source_ip=http://127.0.0.1,health="OK",state="Enabled",host=tpa_po last_power_output_watts="109",line_input_voltage="206",power_capacity_watts="800" 1582612210000000000 -redfish_power_powersupplies,source=tpa_hostname,name=HpeServerPowerSupply,source_ip=http://127.0.0.1,health="OK",state="Enabled",host=tpa_po last_power_output_watts="98",line_input_voltage="204",power_capacity_watts="800" 1582612210000000000 +redfish_thermal_temperatures,source=tpa_hostname,name=01-Inlet\ Ambient,source_ip=http://127.0.0.1,health="OK",state="Enabled",severity="OK" temperature=19,upper_threshold_critical=59,upper_threshold_fatal=64 1582612210000000000 +redfish_thermal_temperatures,source=tpa_hostname,name=02-CPU\ 1,source_ip=http://127.0.0.1,,health="OK",state="Enabled",severity="OK" temperature=40,upper_threshold_critical=59,upper_threshold_fatal=64 1582612210000000000 +redfish_thermal_fans,source=tpa_hostname,name=Fan\ 4,source_ip=http://127.0.0.1,health="OK",state="Enabled",severity="OK" fanspeed=23,upper_threshold_critical=59,upper_threshold_fatal=64 1582612210000000000 +redfish_thermal_fans,source=tpa_hostname,name=Fan\ 5,source_ip=http://127.0.0.1,health="OK",state="Enabled",severity="OK" fanspeed=28,upper_threshold_critical=59,upper_threshold_fatal=64 1582612210000000000 +redfish_power_powersupplies,source=tpa_hostname,name=HpeServerPowerSupply,source_ip=http://127.0.0.1,health="OK",state="Enabled" last_power_output_watts="109",line_input_voltage="206",power_capacity_watts="800" 1582612210000000000 +redfish_power_powersupplies,source=tpa_hostname,name=HpeServerPowerSupply,source_ip=http://127.0.0.1,health="OK",state="Enabled" last_power_output_watts="98",line_input_voltage="204",power_capacity_watts="800" 1582612210000000000 ``` diff --git a/plugins/inputs/redfish/redfish.go b/plugins/inputs/redfish/redfish.go index c8d7470081962..6348136fda8d5 100644 --- a/plugins/inputs/redfish/redfish.go +++ b/plugins/inputs/redfish/redfish.go @@ -10,51 +10,59 @@ import ( "io/ioutil" "math" "net/http" + "strconv" ) type Cpu struct { - Name string `json:"Name"` - ReadingCelsius int64 `json:"ReadingCelsius"` - Status CpuStatus `json:"Status"` + Name string + ReadingCelsius int + UpperThresholdCritical int + UpperThresholdFatal int + Status CpuStatus } type Payload struct { - Temperatures []*Cpu `json:",omitempty"` - Fans []*speed `json:",omitempty"` - PowerSupplies []*Watt `json:",omitempty"` + Temperatures []Cpu `json:",omitempty"` + Fans []Speed `json:",omitempty"` + PowerSupplies []Watt `json:",omitempty"` Hostname string `json:",omitempty"` - Voltages []*volt `json:",omitempty"` + Voltages []Volt `json:",omitempty"` Location *Address `json:",omitempty"` } type CpuStatus struct { State string Health string } -type speed struct { - Name string - Reading int64 - Status FansStatus +type Speed struct { + Name string + Reading int + ReadingUnits string + UpperThresholdCritical int + UpperThresholdFatal int + Status FansStatus } type FansStatus struct { - State string `json:"State"` - Health string `json:"Health"` + State string + Health string } type Watt struct { - Name string `json:",omitempty"` - PowerInputWatts float64 `json:",omitempty"` - PowerCapacityWatts float64 `json:",omitempty"` - PowerOutputWatts float64 `json:",omitempty"` - LastPowerOutputWatts float64 `json:",omitempty"` - Status *PowerStatus `json:",omitempty"` - LineInputVoltage float64 `json:",omitempty"` + Name string + PowerInputWatts float64 + PowerCapacityWatts float64 + PowerOutputWatts float64 + LastPowerOutputWatts float64 + Status PowerStatus + LineInputVoltage float64 } type PowerStatus struct { State string Health string } -type volt struct { - Name string - ReadingVolts float64 - Status VoltStatus +type Volt struct { + Name string + ReadingVolts float64 + UpperThresholdCritical float64 + UpperThresholdFatal float64 + Status VoltStatus } type VoltStatus struct { State string @@ -134,6 +142,20 @@ func (r *Redfish) Init() error { return nil } +func Severity(critical, fatal, val int) string { + severity := "NA" + if (critical != 0) || (fatal != 0) { + if (val >= fatal) && (fatal != 0) { + severity = "Fatal" + } else if (val >= critical) && (critical != 0) { + severity = "Critical" + } else { + severity = "OK" + } + } + return severity +} + func (r *Redfish) Gather(acc telegraf.Accumulator) error { var url []string var payload Payload @@ -187,14 +209,18 @@ func (r *Redfish) Gather(acc telegraf.Accumulator) error { tags["room"] = payload.Location.PostalAddress.Room tags["rack"] = payload.Location.Placement.Rack tags["row"] = payload.Location.Placement.Row + tags["severity"] = Severity(j.UpperThresholdCritical, j.UpperThresholdFatal, j.ReadingCelsius) // Fields fields := make(map[string]interface{}) fields["temperature"] = j.ReadingCelsius + fields["upper_threshold_critical"] = j.UpperThresholdCritical + fields["upper_threshold_fatal"] = j.UpperThresholdFatal acc.AddFields("redfish_thermal_temperatures", fields, tags) } for _, j := range payload.Fans { // Tags tags := map[string]string{} + fields := make(map[string]interface{}) tags["source_ip"] = r.Host tags["name"] = j.Name tags["source"] = payload.Hostname @@ -204,8 +230,14 @@ func (r *Redfish) Gather(acc telegraf.Accumulator) error { tags["room"] = payload.Location.PostalAddress.Room tags["rack"] = payload.Location.Placement.Rack tags["row"] = payload.Location.Placement.Row + if j.ReadingUnits == "RPM" { + tags["severity"] = Severity(j.UpperThresholdCritical, j.UpperThresholdFatal, j.Reading) + fields["upper_threshold_critical"] = j.UpperThresholdCritical + fields["upper_threshold_fatal"] = j.UpperThresholdFatal + + } + // Fields - fields := make(map[string]interface{}) fields["fanspeed"] = j.Reading acc.AddFields("redfish_thermal_fans", fields, tags) } @@ -242,9 +274,12 @@ func (r *Redfish) Gather(acc telegraf.Accumulator) error { tags["room"] = payload.Location.PostalAddress.Room tags["rack"] = payload.Location.Placement.Rack tags["row"] = payload.Location.Placement.Row + tags["severity"] = Severity(int(math.Round(j.UpperThresholdCritical)), int(math.Round(j.UpperThresholdFatal)), int(math.Round(j.ReadingVolts))) // Fields fields := make(map[string]interface{}) fields["voltage"] = math.Round(j.ReadingVolts*100) / 100 + fields["upper_threshold_critical"] = math.Round(j.UpperThresholdCritical*100) / 100 + fields["upper_threshold_fatal"] = math.Round(j.UpperThresholdFatal*100) / 100 acc.AddFields("redfish_power_voltages", fields, tags) } } else { @@ -256,21 +291,29 @@ func (r *Redfish) Gather(acc telegraf.Accumulator) error { tags["source"] = payload.Hostname tags["state"] = j.Status.State tags["health"] = j.Status.Health + tags["severity"] = Severity(j.UpperThresholdCritical, j.UpperThresholdFatal, j.ReadingCelsius) // Fields fields := make(map[string]interface{}) fields["temperature"] = j.ReadingCelsius + fields["upper_threshold_critical"] = j.UpperThresholdCritical + fields["upper_threshold_fatal"] = j.UpperThresholdFatal acc.AddFields("redfish_thermal_temperatures", fields, tags) } for _, j := range payload.Fans { // Tags tags := map[string]string{} + fields := make(map[string]interface{}) tags["source_ip"] = r.Host tags["name"] = j.Name tags["source"] = payload.Hostname tags["state"] = j.Status.State tags["health"] = j.Status.Health + if j.ReadingUnits == "RPM" { + tags["upper_threshold_critical"] = strconv.Itoa(j.UpperThresholdCritical) + fields["upper_threshold_fatal"] = strconv.Itoa(j.UpperThresholdFatal) + fields["severity"] = Severity(j.UpperThresholdCritical, j.UpperThresholdFatal, j.Reading) + } // Fields - fields := make(map[string]interface{}) fields["fanspeed"] = j.Reading acc.AddFields("redfish_thermal_fans", fields, tags) } @@ -297,9 +340,12 @@ func (r *Redfish) Gather(acc telegraf.Accumulator) error { tags["source"] = payload.Hostname tags["state"] = j.Status.State tags["health"] = j.Status.Health + tags["severity"] = Severity(int(math.Round(j.UpperThresholdCritical)), int(math.Round(j.UpperThresholdFatal)), int(math.Round(j.ReadingVolts))) // Fields fields := make(map[string]interface{}) fields["voltage"] = math.Round(j.ReadingVolts*100) / 100 + fields["upper_threshold_critical"] = math.Round(j.UpperThresholdCritical*100) / 100 + fields["upper_threshold_fatal"] = math.Round(j.UpperThresholdFatal*100) / 100 acc.AddFields("redfish_power_voltages", fields, tags) } } diff --git a/plugins/inputs/redfish/redfish_test.go b/plugins/inputs/redfish/redfish_test.go index bbee60df35f13..2656e330ec8d2 100644 --- a/plugins/inputs/redfish/redfish_test.go +++ b/plugins/inputs/redfish/redfish_test.go @@ -58,9 +58,12 @@ func TestApis(t *testing.T) { "source_ip": CUSTOM_URL, "health": "OK", "state": "Enabled", + "severity": "OK", }, map[string]interface{}{ - "temperature": 19, + "temperature": 19, + "upper_threshold_critical": 42, + "upper_threshold_fatal": 47, }, time.Unix(0, 0), ), @@ -72,9 +75,12 @@ func TestApis(t *testing.T) { "source_ip": CUSTOM_URL, "health": "OK", "state": "Enabled", + "severity": "OK", }, map[string]interface{}{ - "temperature": 34, + "temperature": 34, + "upper_threshold_critical": 75, + "upper_threshold_fatal": 80, }, time.Unix(0, 0), ), @@ -167,9 +173,12 @@ func TestApis(t *testing.T) { "room": "", "row": "", "state": "Enabled", + "severity": "OK", }, map[string]interface{}{ - "temperature": 40, + "temperature": 40, + "upper_threshold_critical": 93, + "upper_threshold_fatal": 93, }, time.Unix(0, 0), ), @@ -185,9 +194,12 @@ func TestApis(t *testing.T) { "room": "", "row": "", "state": "Enabled", + "severity": "NA", }, map[string]interface{}{ - "fanspeed": 17760, + "fanspeed": 17760, + "upper_threshold_critical": 0, + "upper_threshold_fatal": 0, }, time.Unix(0, 0), ), @@ -203,9 +215,12 @@ func TestApis(t *testing.T) { "room": "", "row": "", "state": "Enabled", + "severity": "NA", }, map[string]interface{}{ - "fanspeed": 15360, + "fanspeed": 15360, + "upper_threshold_critical": 0, + "upper_threshold_fatal": 0, }, time.Unix(0, 0), ), @@ -221,9 +236,12 @@ func TestApis(t *testing.T) { "room": "", "row": "", "state": "Enabled", + "severity": "NA", }, map[string]interface{}{ - "fanspeed": 17880, + "fanspeed": 17880, + "upper_threshold_critical": 0, + "upper_threshold_fatal": 0, }, time.Unix(0, 0), ), @@ -239,9 +257,12 @@ func TestApis(t *testing.T) { "room": "", "row": "", "state": "Enabled", + "severity": "NA", }, map[string]interface{}{ - "fanspeed": 15120, + "fanspeed": 15120, + "upper_threshold_critical": 0, + "upper_threshold_fatal": 0, }, time.Unix(0, 0), ), @@ -257,9 +278,12 @@ func TestApis(t *testing.T) { "room": "", "row": "", "state": "Enabled", + "severity": "NA", }, map[string]interface{}{ - "fanspeed": 18000, + "fanspeed": 18000, + "upper_threshold_critical": 0, + "upper_threshold_fatal": 0, }, time.Unix(0, 0), ), @@ -275,9 +299,12 @@ func TestApis(t *testing.T) { "room": "", "row": "", "state": "Enabled", + "severity": "NA", }, map[string]interface{}{ - "fanspeed": 15600, + "fanspeed": 15600, + "upper_threshold_critical": 0, + "upper_threshold_fatal": 0, }, time.Unix(0, 0), ), @@ -293,9 +320,12 @@ func TestApis(t *testing.T) { "room": "", "row": "", "state": "Enabled", + "severity": "NA", }, map[string]interface{}{ - "fanspeed": 17280, + "fanspeed": 17280, + "upper_threshold_critical": 0, + "upper_threshold_fatal": 0, }, time.Unix(0, 0), ), @@ -311,9 +341,12 @@ func TestApis(t *testing.T) { "room": "", "row": "", "state": "Enabled", + "severity": "NA", }, map[string]interface{}{ - "fanspeed": 15360, + "fanspeed": 15360, + "upper_threshold_critical": 0, + "upper_threshold_fatal": 0, }, time.Unix(0, 0), ), @@ -329,9 +362,12 @@ func TestApis(t *testing.T) { "room": "", "row": "", "state": "Enabled", + "severity": "NA", }, map[string]interface{}{ - "fanspeed": 17640, + "fanspeed": 17640, + "upper_threshold_critical": 0, + "upper_threshold_fatal": 0, }, time.Unix(0, 0), ), @@ -347,9 +383,12 @@ func TestApis(t *testing.T) { "room": "", "row": "", "state": "Enabled", + "severity": "NA", }, map[string]interface{}{ - "fanspeed": 15600, + "fanspeed": 15600, + "upper_threshold_critical": 0, + "upper_threshold_fatal": 0, }, time.Unix(0, 0), ), @@ -365,9 +404,12 @@ func TestApis(t *testing.T) { "room": "", "row": "", "state": "Enabled", + "severity": "NA", }, map[string]interface{}{ - "fanspeed": 17760, + "fanspeed": 17760, + "upper_threshold_critical": 0, + "upper_threshold_fatal": 0, }, time.Unix(0, 0), ), @@ -383,9 +425,12 @@ func TestApis(t *testing.T) { "room": "", "row": "", "state": "Enabled", + "severity": "NA", }, map[string]interface{}{ - "fanspeed": 15600, + "fanspeed": 15600, + "upper_threshold_critical": 0, + "upper_threshold_fatal": 0, }, time.Unix(0, 0), ), @@ -401,9 +446,12 @@ func TestApis(t *testing.T) { "room": "", "row": "", "state": "Enabled", + "severity": "NA", }, map[string]interface{}{ - "fanspeed": 17400, + "fanspeed": 17400, + "upper_threshold_critical": 0, + "upper_threshold_fatal": 0, }, time.Unix(0, 0), ), @@ -419,9 +467,12 @@ func TestApis(t *testing.T) { "room": "", "row": "", "state": "Enabled", + "severity": "NA", }, map[string]interface{}{ - "fanspeed": 15720, + "fanspeed": 15720, + "upper_threshold_critical": 0, + "upper_threshold_fatal": 0, }, time.Unix(0, 0), ), @@ -437,9 +488,12 @@ func TestApis(t *testing.T) { "room": "", "row": "", "state": "Enabled", + "severity": "NA", }, map[string]interface{}{ - "fanspeed": 18000, + "fanspeed": 18000, + "upper_threshold_critical": 0, + "upper_threshold_fatal": 0, }, time.Unix(0, 0), ), @@ -455,9 +509,12 @@ func TestApis(t *testing.T) { "room": "", "row": "", "state": "Enabled", + "severity": "NA", }, map[string]interface{}{ - "fanspeed": 15840, + "fanspeed": 15840, + "upper_threshold_critical": 0, + "upper_threshold_fatal": 0, }, time.Unix(0, 0), ), @@ -495,9 +552,12 @@ func TestApis(t *testing.T) { "room": "", "row": "", "state": "Enabled", + "severity": "NA", }, map[string]interface{}{ - "voltage": 1.0, + "voltage": 1.0, + "upper_threshold_critical": 0.0, + "upper_threshold_fatal": 0.0, }, time.Unix(0, 0), ), @@ -513,9 +573,12 @@ func TestApis(t *testing.T) { "room": "", "row": "", "state": "Enabled", + "severity": "NA", }, map[string]interface{}{ - "voltage": 1.0, + "voltage": 1.0, + "upper_threshold_critical": 0.0, + "upper_threshold_fatal": 0.0, }, time.Unix(0, 0), ), @@ -532,9 +595,12 @@ func TestApis(t *testing.T) { "room": "", "row": "", "state": "Enabled", + "severity": "NA", }, map[string]interface{}{ - "voltage": 1.0, + "voltage": 1.0, + "upper_threshold_critical": 0.0, + "upper_threshold_fatal": 0.0, }, time.Unix(0, 0), ), From 36a041ed1a7bad9904b078ebdda4fe0beaba5c83 Mon Sep 17 00:00:00 2001 From: sarvanikonda Date: Tue, 9 Jun 2020 19:10:10 +0530 Subject: [PATCH 11/12] made changes as required --- plugins/inputs/redfish/README.md | 146 +++------ plugins/inputs/redfish/redfish.go | 246 +++++++-------- plugins/inputs/redfish/redfish_test.go | 296 +++++++----------- .../{dell_location.json => dell_chassis.json} | 0 ...ninvalid.json => dell_chassisinvalid.json} | 0 .../{dell_hostname.json => dell_systems.json} | 0 ...einvalid.json => dell_systemsinvalid.json} | 0 .../{hp_hostname.json => hp_systems.json} | 0 ...ameinvalid.json => hp_systemsinvalid.json} | 0 9 files changed, 279 insertions(+), 409 deletions(-) rename plugins/inputs/redfish/testdata/{dell_location.json => dell_chassis.json} (100%) rename plugins/inputs/redfish/testdata/{dell_locationinvalid.json => dell_chassisinvalid.json} (100%) rename plugins/inputs/redfish/testdata/{dell_hostname.json => dell_systems.json} (100%) rename plugins/inputs/redfish/testdata/{dell_hostnameinvalid.json => dell_systemsinvalid.json} (100%) rename plugins/inputs/redfish/testdata/{hp_hostname.json => hp_systems.json} (100%) rename plugins/inputs/redfish/testdata/{hp_hostnameinvalid.json => hp_systemsinvalid.json} (100%) diff --git a/plugins/inputs/redfish/README.md b/plugins/inputs/redfish/README.md index f33670f8a3cbd..7593761a997c1 100644 --- a/plugins/inputs/redfish/README.md +++ b/plugins/inputs/redfish/README.md @@ -8,7 +8,7 @@ The `redfish` plugin gathers metrics and status information about CPU temperatu ```toml [[inputs.redfish]] ## Server OOB-IP - host = "192.0.0.1" + address = "http://192.0.0.1" ## Username,Password for hardware server username = "test" @@ -17,25 +17,26 @@ The `redfish` plugin gathers metrics and status information about CPU temperatu ## Resource Id for redfish APIs id="System.Embedded.1" - ## Optional TLS Config, if not provided insecure skip verifies defaults to true + ## Optional TLS Config # tls_ca = "/etc/telegraf/ca.pem" # tls_cert = "/etc/telegraf/cert.pem" # tls_key = "/etc/telegraf/key.pem" + # insecure_skip_verify = false ## Amount of time allowed to complete the HTTP request # timeout = "5s" ``` -### Metrics for Dell Servers +### Metrics - redfish_power_powersupplies - tags: - - source_ip + - address - name - - datacenter - - rack - - room - - row + - datacenter (available only if location data is found) + - rack (available only if location data is found) + - room (available only if location data is found) + - row (available only if location data is found) - state - health - Fields: @@ -45,131 +46,72 @@ The `redfish` plugin gathers metrics and status information about CPU temperatu - power_input_watts - power_output_watts -- redfish_power_voltages +- redfish_power_voltages (available only if voltage data is found) - tags: - - source_ip + - address - name - - datacenter - - rack - - room - - row + - datacenter (available only if location data is found) + - rack (available only if location data is found) + - room (available only if location data is found) + - row (available only if location data is found) - state - health - - severity - Fields: - - voltage + - reading_volts - upper_threshold_critical - upper_threshold_fatal - redfish_thermal_fans - tags: - - source_ip + - address - name - - datacenter - - rack - - room - - row + - datacenter (available only if location data is found) + - rack (available only if location data is found) + - room (available only if location data is found) + - row (available only if location data is found) - state - health - - severity - Fields: - - fanspeed + - reading_rpm (or) reading_percent - upper_threshold_critical - upper_threshold_fatal - redfish_thermal_temperatures - tags: - - source_ip + - address - name - - datacenter - - rack - - room - - row + - datacenter (available only if location data is found) + - rack (available only if location data is found) + - room (available only if location data is found) + - row (available only if location data is found) - state - health - - severity - Fields: - - temperature + - reading_celsius - upper_threshold_critical - upper_threshold_fatal -### Metrics if location details, voltage and power input/output data are not available in server APIs - -- redfish_power_powersupplies - - tags: - - health - - host - - name - - source_ip - - state - - Fields: - - last_power_output_watts - - line_input_voltage - - power_capacity_watts - -- redfish_thermal_fans - - tags: - - health - - host - - name - - source_ip - - state - - severity - - Fields: - - fanspeed - - upper_threshold_critical - - upper_threshold_fatal - -- redfish_thermal_temperatures - - tags: - - health - - host - - name - - source_ip - - state - - severity - - Fields: - - temperature - - upper_threshold_critical - - upper_threshold_fatal - - - - -### Example Output For Dell -``` -redfish_thermal_temperatures,source=test-hostname,name=CPU1\ Temp,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" temperature=41,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_thermal_temperatures,source=test-hostname,name=CPU2\ Temp,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" temperature=51,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_thermal_temperatures,source=test-hostname,name=System\ Board\ Inlet\ Temp,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" temperature=23,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_thermal_temperatures,source=test-hostname,name=System\ Board\ Exhaust\ Temp,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" temperature=33,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_thermal_fans,source=test-hostname,name=System\ Board\ Fan1A,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" fanspeed=17720,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_thermal_fans,source=test-hostname,name=System\ Board\ Fan1B,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" fanspeed=17760,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_thermal_fans,source=test-hostname,name=System\ Board\ Fan2A,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" fanspeed=17880,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_power_powersupplies,source=test-hostname,name=PS1\ Status,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" power_capacity_watts=750,power_input_watts=900,power_output_watts=208,last_power_output_watts=98,line_input_voltage=204 1582114112000000000 -redfish_power_powersupplies,source=test-hostname,name=PS2\ Status,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" power_capacity_watts=750,power_input_watts=900,power_output_watts=194,last_power_output_watts=98,line_input_voltage=204 1582114112000000000 -redfish_power_voltages,source=test-hostname,name=CPU1\ MEM345\ VDDQ\ PG,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" voltage=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_power_voltages,source=test-hostname,name=CPU1\ MEM345\ VPP\ PG,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" voltage=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_power_voltages,source=test-hostname,name=CPU1\ MEM345\ VTT\ PG,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" voltage=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_power_voltages,source=test-hostname,name=PS1\ voltage\ 1,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" voltage=208,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_power_voltages,source=test-hostname,name=PS2\ voltage\ 2,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" voltage=208,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_power_voltages,source=test-hostname,name=System\ Board\ 3.3V\ A\ PG,source_ip=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled",severity="OK" voltage=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 - - +### Example Output ``` +redfish_thermal_temperatures,source=test-hostname,name=CPU1\ Temp,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_celsius=41,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_thermal_temperatures,source=test-hostname,name=CPU2\ Temp,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_celsius=51,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_thermal_temperatures,source=test-hostname,name=System\ Board\ Inlet\ Temp,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_celsius=23,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_thermal_temperatures,source=test-hostname,name=System\ Board\ Exhaust\ Temp,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_celsius=33,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_thermal_fans,source=test-hostname,name=System\ Board\ Fan1A,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading=17720,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_thermal_fans,source=test-hostname,name=System\ Board\ Fan1B,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading=17760,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_thermal_fans,source=test-hostname,name=System\ Board\ Fan2A,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading=17880,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_power_powersupplies,source=test-hostname,name=PS1\ Status,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" power_capacity_watts=750,power_input_watts=900,power_output_watts=208,last_power_output_watts=98,line_input_reading_volts=204 1582114112000000000 +redfish_power_powersupplies,source=test-hostname,name=PS2\ Status,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" power_capacity_watts=750,power_input_watts=900,power_output_watts=194,last_power_output_watts=98,line_input_reading_volts=204 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=CPU1\ MEM345\ VDDQ\ PG,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=CPU1\ MEM345\ VPP\ PG,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=CPU1\ MEM345\ VTT\ PG,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=PS1\ voltage\ 1,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=208,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=PS2\ voltage\ 2,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=208,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=System\ Board\ 3.3V\ A\ PG,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -### Example output if location details, voltage and power input/output data are not available in server APIs - -``` -redfish_thermal_temperatures,source=tpa_hostname,name=01-Inlet\ Ambient,source_ip=http://127.0.0.1,health="OK",state="Enabled",severity="OK" temperature=19,upper_threshold_critical=59,upper_threshold_fatal=64 1582612210000000000 -redfish_thermal_temperatures,source=tpa_hostname,name=02-CPU\ 1,source_ip=http://127.0.0.1,,health="OK",state="Enabled",severity="OK" temperature=40,upper_threshold_critical=59,upper_threshold_fatal=64 1582612210000000000 -redfish_thermal_fans,source=tpa_hostname,name=Fan\ 4,source_ip=http://127.0.0.1,health="OK",state="Enabled",severity="OK" fanspeed=23,upper_threshold_critical=59,upper_threshold_fatal=64 1582612210000000000 -redfish_thermal_fans,source=tpa_hostname,name=Fan\ 5,source_ip=http://127.0.0.1,health="OK",state="Enabled",severity="OK" fanspeed=28,upper_threshold_critical=59,upper_threshold_fatal=64 1582612210000000000 -redfish_power_powersupplies,source=tpa_hostname,name=HpeServerPowerSupply,source_ip=http://127.0.0.1,health="OK",state="Enabled" last_power_output_watts="109",line_input_voltage="206",power_capacity_watts="800" 1582612210000000000 -redfish_power_powersupplies,source=tpa_hostname,name=HpeServerPowerSupply,source_ip=http://127.0.0.1,health="OK",state="Enabled" last_power_output_watts="98",line_input_voltage="204",power_capacity_watts="800" 1582612210000000000 - ``` diff --git a/plugins/inputs/redfish/redfish.go b/plugins/inputs/redfish/redfish.go index 6348136fda8d5..0dba40da1f55a 100644 --- a/plugins/inputs/redfish/redfish.go +++ b/plugins/inputs/redfish/redfish.go @@ -8,9 +8,7 @@ import ( "github.com/influxdata/telegraf/internal/tls" "github.com/influxdata/telegraf/plugins/inputs" "io/ioutil" - "math" "net/http" - "strconv" ) type Cpu struct { @@ -81,13 +79,14 @@ type Placement struct { Row string } type Redfish struct { - Host string `toml:"host"` + Address string `toml:"address"` BasicAuthUsername string `toml:"username"` BasicAuthPassword string `toml:"password"` - Id string `toml:"id"` + ServerSystemId string `toml:"server_system_id"` client http.Client tls.ClientConfig Timeout internal.Duration `toml:"timeout"` + payload Payload } func (r *Redfish) Description() string { @@ -95,21 +94,21 @@ func (r *Redfish) Description() string { } var redfishConfig = ` - ##Server OOB-IP - host = "192.0.0.1" + ##Server url + address = "https://192.0.0.1" ##Username, Password for hardware server username = "test" password = "test" ##Resource Id for redfish APIs - id="System.Embedded.1" + server_system_id="System.Embedded.1" - ##Optional TLS Config, if not provided insecure skip verifies defaults to true + ##Optional TLS Config #tls_ca = "/etc/telegraf/ca.pem" #tls_cert = "/etc/telegraf/cert.pem" #tls_key = "/etc/telegraf/key.pem" - + #insecure_skip_verify = false ## Amount of time allowed to complete the HTTP request # timeout = "5s" @@ -120,17 +119,15 @@ func (r *Redfish) SampleConfig() string { } func (r *Redfish) Init() error { + if len(r.Address) == 0 || len(r.BasicAuthUsername) == 0 || len(r.BasicAuthPassword) == 0 { + return fmt.Errorf("Did not provide IP or username and password") + } + if len(r.ServerSystemId) == 0 { + return fmt.Errorf("Did not provide all the ID of the resource") + } tlsCfg, err := r.ClientConfig.TLSConfig() if err != nil { - return err - } - if (len(r.ClientConfig.TLSCA) == 0) || (len(r.ClientConfig.TLSCert) == 0 && len(r.ClientConfig.TLSKey) == 0) { - var insecuretls tls.ClientConfig - insecuretls.InsecureSkipVerify = true - tlsCfg, err = insecuretls.TLSConfig() - if err != nil { - return err - } + return fmt.Errorf("%v", err) } r.client = http.Client{ Transport: &http.Transport{ @@ -139,213 +136,198 @@ func (r *Redfish) Init() error { }, Timeout: r.Timeout.Duration, } + return nil } -func Severity(critical, fatal, val int) string { - severity := "NA" - if (critical != 0) || (fatal != 0) { - if (val >= fatal) && (fatal != 0) { - severity = "Fatal" - } else if (val >= critical) && (critical != 0) { - severity = "Critical" - } else { - severity = "OK" +func (r *Redfish) GetData(url string) error { + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return fmt.Errorf("%v", err) + } + req.SetBasicAuth(r.BasicAuthUsername, r.BasicAuthPassword) + req.Header.Set("Accept", "application/json") + req.Header.Set("Content-Type", "application/json") + resp, err := r.client.Do(req) + if err != nil { + return fmt.Errorf("%v", err) + } + defer resp.Body.Close() + if resp.StatusCode == 200 { + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return fmt.Errorf("%v", err) } + err = json.Unmarshal(body, &r.payload) + if err != nil { + return fmt.Errorf("error parsing input: %v", err) + } + + } else { + return fmt.Errorf("received status code %d (%s), expected 200", + resp.StatusCode, + http.StatusText(resp.StatusCode)) } - return severity + return nil } func (r *Redfish) Gather(acc telegraf.Accumulator) error { var url []string - var payload Payload - url = append(url, fmt.Sprint("https://", r.Host, "/redfish/v1/Chassis/", r.Id, "/Thermal"), fmt.Sprint("https://", r.Host, "/redfish/v1/Chassis/", r.Id, "/Power"), fmt.Sprint("https://", r.Host, "/redfish/v1/Systems/", r.Id), fmt.Sprint("https://", r.Host, "/redfish/v1/Chassis/", r.Id, "/")) - - if len(r.Host) == 0 || len(r.BasicAuthUsername) == 0 || len(r.BasicAuthPassword) == 0 { - return fmt.Errorf("Did not provide IP or username and password") - } - if len(r.Id) == 0 { - return fmt.Errorf("Did not provide all the ID of the resource") - } - + url = append(url, fmt.Sprint(r.Address, "/redfish/v1/Chassis/", r.ServerSystemId, "/Thermal"), fmt.Sprint(r.Address, "/redfish/v1/Chassis/", r.ServerSystemId, "/Power"), fmt.Sprint(r.Address, "/redfish/v1/Systems/", r.ServerSystemId), fmt.Sprint(r.Address, "/redfish/v1/Chassis/", r.ServerSystemId, "/")) for _, i := range url { - req, err := http.NewRequest("GET", i, nil) + err := r.GetData(i) if err != nil { - return err - } - req.SetBasicAuth(r.BasicAuthUsername, r.BasicAuthPassword) - req.Header.Set("Accept", "application/json") - req.Header.Set("Content-Type", "application/json") - resp, err := r.client.Do(req) - if err != nil { - return err - } - if resp.StatusCode == 200 { - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return fmt.Errorf("%v", err) - } - jsonErr := json.Unmarshal(body, &payload) - if jsonErr != nil { - return fmt.Errorf("error parsing input: %v", jsonErr) - } - - } else { - return fmt.Errorf("received status code %d (%s), expected 200", - resp.StatusCode, - http.StatusText(resp.StatusCode)) + return fmt.Errorf("%v", err) } } - if payload.Location != nil { - for _, j := range payload.Temperatures { + if r.payload.Location != nil { + for _, j := range r.payload.Temperatures { // Tags tags := map[string]string{} - tags["source_ip"] = r.Host + tags["address"] = r.Address tags["name"] = j.Name - tags["source"] = payload.Hostname + tags["source"] = r.payload.Hostname tags["state"] = j.Status.State tags["health"] = j.Status.Health - tags["datacenter"] = payload.Location.PostalAddress.DataCenter - tags["room"] = payload.Location.PostalAddress.Room - tags["rack"] = payload.Location.Placement.Rack - tags["row"] = payload.Location.Placement.Row - tags["severity"] = Severity(j.UpperThresholdCritical, j.UpperThresholdFatal, j.ReadingCelsius) + tags["datacenter"] = r.payload.Location.PostalAddress.DataCenter + tags["room"] = r.payload.Location.PostalAddress.Room + tags["rack"] = r.payload.Location.Placement.Rack + tags["row"] = r.payload.Location.Placement.Row // Fields fields := make(map[string]interface{}) - fields["temperature"] = j.ReadingCelsius + fields["reading_celsius"] = j.ReadingCelsius fields["upper_threshold_critical"] = j.UpperThresholdCritical fields["upper_threshold_fatal"] = j.UpperThresholdFatal acc.AddFields("redfish_thermal_temperatures", fields, tags) } - for _, j := range payload.Fans { + for _, j := range r.payload.Fans { // Tags tags := map[string]string{} fields := make(map[string]interface{}) - tags["source_ip"] = r.Host + tags["address"] = r.Address tags["name"] = j.Name - tags["source"] = payload.Hostname + tags["source"] = r.payload.Hostname tags["state"] = j.Status.State tags["health"] = j.Status.Health - tags["datacenter"] = payload.Location.PostalAddress.DataCenter - tags["room"] = payload.Location.PostalAddress.Room - tags["rack"] = payload.Location.Placement.Rack - tags["row"] = payload.Location.Placement.Row + tags["datacenter"] = r.payload.Location.PostalAddress.DataCenter + tags["room"] = r.payload.Location.PostalAddress.Room + tags["rack"] = r.payload.Location.Placement.Rack + tags["row"] = r.payload.Location.Placement.Row + + // Fields if j.ReadingUnits == "RPM" { - tags["severity"] = Severity(j.UpperThresholdCritical, j.UpperThresholdFatal, j.Reading) fields["upper_threshold_critical"] = j.UpperThresholdCritical fields["upper_threshold_fatal"] = j.UpperThresholdFatal + fields["reading_rpm"] = j.Reading + } else { + fields["reading_percent"] = j.Reading } - - // Fields - fields["fanspeed"] = j.Reading acc.AddFields("redfish_thermal_fans", fields, tags) } - for _, j := range payload.PowerSupplies { + for _, j := range r.payload.PowerSupplies { // Tags tags := map[string]string{} - tags["source_ip"] = r.Host + tags["address"] = r.Address tags["name"] = j.Name - tags["source"] = payload.Hostname + tags["source"] = r.payload.Hostname tags["state"] = j.Status.State tags["health"] = j.Status.Health - tags["datacenter"] = payload.Location.PostalAddress.DataCenter - tags["room"] = payload.Location.PostalAddress.Room - tags["rack"] = payload.Location.Placement.Rack - tags["row"] = payload.Location.Placement.Row + tags["datacenter"] = r.payload.Location.PostalAddress.DataCenter + tags["room"] = r.payload.Location.PostalAddress.Room + tags["rack"] = r.payload.Location.Placement.Rack + tags["row"] = r.payload.Location.Placement.Row // Fields fields := make(map[string]interface{}) - fields["power_input_watts"] = math.Round(j.PowerInputWatts*100) / 100 - fields["power_output_watts"] = math.Round(j.PowerOutputWatts*100) / 100 - fields["line_input_voltage"] = math.Round(j.LineInputVoltage*100) / 100 - fields["last_power_output_watts"] = math.Round(j.LastPowerOutputWatts*100) / 100 - fields["power_capacity_watts"] = math.Round(j.PowerCapacityWatts*100) / 100 + fields["power_input_watts"] = j.PowerInputWatts + fields["power_output_watts"] = j.PowerOutputWatts + fields["line_input_voltage"] = j.LineInputVoltage + fields["last_power_output_watts"] = j.LastPowerOutputWatts + fields["power_capacity_watts"] = j.PowerCapacityWatts acc.AddFields("redfish_power_powersupplies", fields, tags) } - for _, j := range payload.Voltages { + for _, j := range r.payload.Voltages { // Tags tags := map[string]string{} - tags["source_ip"] = r.Host + tags["address"] = r.Address tags["name"] = j.Name - tags["source"] = payload.Hostname + tags["source"] = r.payload.Hostname tags["state"] = j.Status.State tags["health"] = j.Status.Health - tags["datacenter"] = payload.Location.PostalAddress.DataCenter - tags["room"] = payload.Location.PostalAddress.Room - tags["rack"] = payload.Location.Placement.Rack - tags["row"] = payload.Location.Placement.Row - tags["severity"] = Severity(int(math.Round(j.UpperThresholdCritical)), int(math.Round(j.UpperThresholdFatal)), int(math.Round(j.ReadingVolts))) + tags["datacenter"] = r.payload.Location.PostalAddress.DataCenter + tags["room"] = r.payload.Location.PostalAddress.Room + tags["rack"] = r.payload.Location.Placement.Rack + tags["row"] = r.payload.Location.Placement.Row // Fields fields := make(map[string]interface{}) - fields["voltage"] = math.Round(j.ReadingVolts*100) / 100 - fields["upper_threshold_critical"] = math.Round(j.UpperThresholdCritical*100) / 100 - fields["upper_threshold_fatal"] = math.Round(j.UpperThresholdFatal*100) / 100 + fields["reading_volts"] = j.ReadingVolts + fields["upper_threshold_critical"] = j.UpperThresholdCritical + fields["upper_threshold_fatal"] = j.UpperThresholdFatal acc.AddFields("redfish_power_voltages", fields, tags) } } else { - for _, j := range payload.Temperatures { + for _, j := range r.payload.Temperatures { // Tags tags := map[string]string{} - tags["source_ip"] = r.Host + tags["address"] = r.Address tags["name"] = j.Name - tags["source"] = payload.Hostname + tags["source"] = r.payload.Hostname tags["state"] = j.Status.State tags["health"] = j.Status.Health - tags["severity"] = Severity(j.UpperThresholdCritical, j.UpperThresholdFatal, j.ReadingCelsius) // Fields fields := make(map[string]interface{}) - fields["temperature"] = j.ReadingCelsius + fields["reading_celsius"] = j.ReadingCelsius fields["upper_threshold_critical"] = j.UpperThresholdCritical fields["upper_threshold_fatal"] = j.UpperThresholdFatal acc.AddFields("redfish_thermal_temperatures", fields, tags) } - for _, j := range payload.Fans { + for _, j := range r.payload.Fans { // Tags tags := map[string]string{} fields := make(map[string]interface{}) - tags["source_ip"] = r.Host + tags["address"] = r.Address tags["name"] = j.Name - tags["source"] = payload.Hostname + tags["source"] = r.payload.Hostname tags["state"] = j.Status.State tags["health"] = j.Status.Health + // Fields if j.ReadingUnits == "RPM" { - tags["upper_threshold_critical"] = strconv.Itoa(j.UpperThresholdCritical) - fields["upper_threshold_fatal"] = strconv.Itoa(j.UpperThresholdFatal) - fields["severity"] = Severity(j.UpperThresholdCritical, j.UpperThresholdFatal, j.Reading) + fields["upper_threshold_critical"] = j.UpperThresholdCritical + fields["upper_threshold_fatal"] = j.UpperThresholdFatal + fields["reading_rpm"] = j.Reading + } else { + fields["reading_percent"] = j.Reading } - // Fields - fields["fanspeed"] = j.Reading acc.AddFields("redfish_thermal_fans", fields, tags) } - for _, j := range payload.PowerSupplies { + for _, j := range r.payload.PowerSupplies { // Tags tags := map[string]string{} - tags["source_ip"] = r.Host + tags["address"] = r.Address tags["name"] = j.Name //j.Name - tags["source"] = payload.Hostname + tags["source"] = r.payload.Hostname tags["state"] = j.Status.State tags["health"] = j.Status.Health // Fields fields := make(map[string]interface{}) - fields["line_input_voltage"] = math.Round(j.LineInputVoltage*100) / 100 - fields["last_power_output_watts"] = math.Round(j.LastPowerOutputWatts*100) / 100 - fields["power_capacity_watts"] = math.Round(j.PowerCapacityWatts*100) / 100 + fields["line_input_voltage"] = j.LineInputVoltage + fields["last_power_output_watts"] = j.LastPowerOutputWatts + fields["power_capacity_watts"] = j.PowerCapacityWatts acc.AddFields("redfish_power_powersupplies", fields, tags) } - for _, j := range payload.Voltages { + for _, j := range r.payload.Voltages { // Tags tags := map[string]string{} - tags["source_ip"] = r.Host + tags["address"] = r.Address tags["name"] = j.Name - tags["source"] = payload.Hostname + tags["source"] = r.payload.Hostname tags["state"] = j.Status.State tags["health"] = j.Status.Health - tags["severity"] = Severity(int(math.Round(j.UpperThresholdCritical)), int(math.Round(j.UpperThresholdFatal)), int(math.Round(j.ReadingVolts))) // Fields fields := make(map[string]interface{}) - fields["voltage"] = math.Round(j.ReadingVolts*100) / 100 - fields["upper_threshold_critical"] = math.Round(j.UpperThresholdCritical*100) / 100 - fields["upper_threshold_fatal"] = math.Round(j.UpperThresholdFatal*100) / 100 + fields["reading_volts"] = j.ReadingVolts + fields["upper_threshold_critical"] = j.UpperThresholdCritical + fields["upper_threshold_fatal"] = j.UpperThresholdFatal acc.AddFields("redfish_power_voltages", fields, tags) } } diff --git a/plugins/inputs/redfish/redfish_test.go b/plugins/inputs/redfish/redfish_test.go index 2656e330ec8d2..25cbb8f519c90 100644 --- a/plugins/inputs/redfish/redfish_test.go +++ b/plugins/inputs/redfish/redfish_test.go @@ -1,20 +1,19 @@ package redfish import ( - "net" + // "net" + "github.com/influxdata/telegraf" + "github.com/influxdata/telegraf/testutil" + "github.com/stretchr/testify/require" "net/http" "net/http/httptest" "testing" "time" - - "github.com/influxdata/telegraf" - "github.com/influxdata/telegraf/testutil" - "github.com/stretchr/testify/require" ) func TestApis(t *testing.T) { - ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if !checkAuth(r, "test", "test") { http.Error(w, "Unauthorized.", 401) @@ -27,15 +26,15 @@ func TestApis(t *testing.T) { case "/redfish/v1/Chassis/System.Embedded.1/Power": http.ServeFile(w, r, "testdata/dell_power.json") case "/redfish/v1/Chassis/System.Embedded.1/": - http.ServeFile(w, r, "testdata/dell_location.json") + http.ServeFile(w, r, "testdata/dell_chassis.json") case "/redfish/v1/Systems/System.Embedded.1": - http.ServeFile(w, r, "testdata/dell_hostname.json") + http.ServeFile(w, r, "testdata/dell_systems.json") case "/redfish/v1/Chassis/System.Embedded.2/Thermal": http.ServeFile(w, r, "testdata/hp_thermal.json") case "/redfish/v1/Chassis/System.Embedded.2/Power": http.ServeFile(w, r, "testdata/hp_power.json") case "/redfish/v1/Systems/System.Embedded.2": - http.ServeFile(w, r, "testdata/hp_hostname.json") + http.ServeFile(w, r, "testdata/hp_systems.json") case "/redfish/v1/Chassis/System.Embedded.2/": http.ServeFile(w, r, "testdata/hp_power.json") default: @@ -43,25 +42,20 @@ func TestApis(t *testing.T) { } })) - CUSTOM_URL := "127.0.0.1:3458" - l, _ := net.Listen("tcp", CUSTOM_URL) - ts.Listener = l - ts.StartTLS() defer ts.Close() expected_metrics_hp := []telegraf.Metric{ testutil.MustMetric( "redfish_thermal_temperatures", map[string]string{ - "name": "01-Inlet Ambient", - "source": "tpa-hostname", - "source_ip": CUSTOM_URL, - "health": "OK", - "state": "Enabled", - "severity": "OK", + "name": "01-Inlet Ambient", + "source": "tpa-hostname", + "address": ts.URL, + "health": "OK", + "state": "Enabled", }, map[string]interface{}{ - "temperature": 19, + "reading_celsius": 19, "upper_threshold_critical": 42, "upper_threshold_fatal": 47, }, @@ -70,15 +64,14 @@ func TestApis(t *testing.T) { testutil.MustMetric( "redfish_thermal_temperatures", map[string]string{ - "name": "44-P/S 2 Zone", - "source": "tpa-hostname", - "source_ip": CUSTOM_URL, - "health": "OK", - "state": "Enabled", - "severity": "OK", + "name": "44-P/S 2 Zone", + "source": "tpa-hostname", + "address": ts.URL, + "health": "OK", + "state": "Enabled", }, map[string]interface{}{ - "temperature": 34, + "reading_celsius": 34, "upper_threshold_critical": 75, "upper_threshold_fatal": 80, }, @@ -87,53 +80,53 @@ func TestApis(t *testing.T) { testutil.MustMetric( "redfish_thermal_fans", map[string]string{ - "source": "tpa-hostname", - "name": "Fan 1", - "source_ip": CUSTOM_URL, - "health": "OK", - "state": "Enabled", + "source": "tpa-hostname", + "name": "Fan 1", + "address": ts.URL, + "health": "OK", + "state": "Enabled", }, map[string]interface{}{ - "fanspeed": 23, + "reading_percent": 23, }, time.Unix(0, 0), ), testutil.MustMetric( "redfish_thermal_fans", map[string]string{ - "source": "tpa-hostname", - "name": "Fan 2", - "source_ip": CUSTOM_URL, - "health": "OK", - "state": "Enabled", + "source": "tpa-hostname", + "name": "Fan 2", + "address": ts.URL, + "health": "OK", + "state": "Enabled", }, map[string]interface{}{ - "fanspeed": 23, + "reading_percent": 23, }, time.Unix(0, 0), ), testutil.MustMetric( "redfish_thermal_fans", map[string]string{ - "source": "tpa-hostname", - "name": "Fan 3", - "source_ip": CUSTOM_URL, - "health": "OK", - "state": "Enabled", + "source": "tpa-hostname", + "name": "Fan 3", + "address": ts.URL, + "health": "OK", + "state": "Enabled", }, map[string]interface{}{ - "fanspeed": 23, + "reading_percent": 23, }, time.Unix(0, 0), ), testutil.MustMetric( "redfish_power_powersupplies", map[string]string{ - "source": "tpa-hostname", - "name": "HpeServerPowerSupply", - "source_ip": CUSTOM_URL, - "health": "OK", - "state": "Enabled", + "source": "tpa-hostname", + "name": "HpeServerPowerSupply", + "address": ts.URL, + "health": "OK", + "state": "Enabled", }, map[string]interface{}{ "power_capacity_watts": 800.0, @@ -145,11 +138,11 @@ func TestApis(t *testing.T) { testutil.MustMetric( "redfish_power_powersupplies", map[string]string{ - "source": "tpa-hostname", - "name": "HpeServerPowerSupply", - "source_ip": CUSTOM_URL, - "health": "OK", - "state": "Enabled", + "source": "tpa-hostname", + "name": "HpeServerPowerSupply", + "address": ts.URL, + "health": "OK", + "state": "Enabled", }, map[string]interface{}{ "power_capacity_watts": 800.0, @@ -166,17 +159,16 @@ func TestApis(t *testing.T) { map[string]string{ "name": "CPU1 Temp", "source": "tpa-hostname", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "severity": "OK", }, map[string]interface{}{ - "temperature": 40, + "reading_celsius": 40, "upper_threshold_critical": 93, "upper_threshold_fatal": 93, }, @@ -187,17 +179,16 @@ func TestApis(t *testing.T) { map[string]string{ "source": "tpa-hostname", "name": "System Board Fan1A", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "severity": "NA", }, map[string]interface{}{ - "fanspeed": 17760, + "reading_rpm": 17760, "upper_threshold_critical": 0, "upper_threshold_fatal": 0, }, @@ -208,17 +199,16 @@ func TestApis(t *testing.T) { map[string]string{ "source": "tpa-hostname", "name": "System Board Fan1B", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "severity": "NA", }, map[string]interface{}{ - "fanspeed": 15360, + "reading_rpm": 15360, "upper_threshold_critical": 0, "upper_threshold_fatal": 0, }, @@ -229,17 +219,16 @@ func TestApis(t *testing.T) { map[string]string{ "source": "tpa-hostname", "name": "System Board Fan2A", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "severity": "NA", }, map[string]interface{}{ - "fanspeed": 17880, + "reading_rpm": 17880, "upper_threshold_critical": 0, "upper_threshold_fatal": 0, }, @@ -250,17 +239,16 @@ func TestApis(t *testing.T) { map[string]string{ "source": "tpa-hostname", "name": "System Board Fan2B", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "severity": "NA", }, map[string]interface{}{ - "fanspeed": 15120, + "reading_rpm": 15120, "upper_threshold_critical": 0, "upper_threshold_fatal": 0, }, @@ -271,17 +259,16 @@ func TestApis(t *testing.T) { map[string]string{ "source": "tpa-hostname", "name": "System Board Fan3A", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "severity": "NA", }, map[string]interface{}{ - "fanspeed": 18000, + "reading_rpm": 18000, "upper_threshold_critical": 0, "upper_threshold_fatal": 0, }, @@ -292,17 +279,16 @@ func TestApis(t *testing.T) { map[string]string{ "source": "tpa-hostname", "name": "System Board Fan3B", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "severity": "NA", }, map[string]interface{}{ - "fanspeed": 15600, + "reading_rpm": 15600, "upper_threshold_critical": 0, "upper_threshold_fatal": 0, }, @@ -313,17 +299,16 @@ func TestApis(t *testing.T) { map[string]string{ "source": "tpa-hostname", "name": "System Board Fan4A", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "severity": "NA", }, map[string]interface{}{ - "fanspeed": 17280, + "reading_rpm": 17280, "upper_threshold_critical": 0, "upper_threshold_fatal": 0, }, @@ -334,17 +319,16 @@ func TestApis(t *testing.T) { map[string]string{ "source": "tpa-hostname", "name": "System Board Fan4B", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "severity": "NA", }, map[string]interface{}{ - "fanspeed": 15360, + "reading_rpm": 15360, "upper_threshold_critical": 0, "upper_threshold_fatal": 0, }, @@ -355,17 +339,16 @@ func TestApis(t *testing.T) { map[string]string{ "source": "tpa-hostname", "name": "System Board Fan5A", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "severity": "NA", }, map[string]interface{}{ - "fanspeed": 17640, + "reading_rpm": 17640, "upper_threshold_critical": 0, "upper_threshold_fatal": 0, }, @@ -376,17 +359,16 @@ func TestApis(t *testing.T) { map[string]string{ "source": "tpa-hostname", "name": "System Board Fan5B", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "severity": "NA", }, map[string]interface{}{ - "fanspeed": 15600, + "reading_rpm": 15600, "upper_threshold_critical": 0, "upper_threshold_fatal": 0, }, @@ -397,17 +379,16 @@ func TestApis(t *testing.T) { map[string]string{ "source": "tpa-hostname", "name": "System Board Fan6A", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "severity": "NA", }, map[string]interface{}{ - "fanspeed": 17760, + "reading_rpm": 17760, "upper_threshold_critical": 0, "upper_threshold_fatal": 0, }, @@ -418,17 +399,16 @@ func TestApis(t *testing.T) { map[string]string{ "source": "tpa-hostname", "name": "System Board Fan6B", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "severity": "NA", }, map[string]interface{}{ - "fanspeed": 15600, + "reading_rpm": 15600, "upper_threshold_critical": 0, "upper_threshold_fatal": 0, }, @@ -439,17 +419,16 @@ func TestApis(t *testing.T) { map[string]string{ "source": "tpa-hostname", "name": "System Board Fan7A", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "severity": "NA", }, map[string]interface{}{ - "fanspeed": 17400, + "reading_rpm": 17400, "upper_threshold_critical": 0, "upper_threshold_fatal": 0, }, @@ -460,17 +439,16 @@ func TestApis(t *testing.T) { map[string]string{ "source": "tpa-hostname", "name": "System Board Fan7B", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "severity": "NA", }, map[string]interface{}{ - "fanspeed": 15720, + "reading_rpm": 15720, "upper_threshold_critical": 0, "upper_threshold_fatal": 0, }, @@ -481,17 +459,16 @@ func TestApis(t *testing.T) { map[string]string{ "source": "tpa-hostname", "name": "System Board Fan8A", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "severity": "NA", }, map[string]interface{}{ - "fanspeed": 18000, + "reading_rpm": 18000, "upper_threshold_critical": 0, "upper_threshold_fatal": 0, }, @@ -502,17 +479,16 @@ func TestApis(t *testing.T) { map[string]string{ "source": "tpa-hostname", "name": "System Board Fan8B", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "severity": "NA", }, map[string]interface{}{ - "fanspeed": 15840, + "reading_rpm": 15840, "upper_threshold_critical": 0, "upper_threshold_fatal": 0, }, @@ -523,7 +499,7 @@ func TestApis(t *testing.T) { map[string]string{ "source": "tpa-hostname", "name": "PS1 Status", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", @@ -532,11 +508,11 @@ func TestApis(t *testing.T) { "state": "Enabled", }, map[string]interface{}{ - "power_capacity_watts": 750.0, + "power_capacity_watts": 750.00, "power_input_watts": 900.0, "power_output_watts": 203.0, "last_power_output_watts": 0.0, - "line_input_voltage": 206.0, + "line_input_voltage": 206.00, }, time.Unix(0, 0), ), @@ -545,17 +521,16 @@ func TestApis(t *testing.T) { map[string]string{ "source": "tpa-hostname", "name": "System Board DIMM PG", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "severity": "NA", }, map[string]interface{}{ - "voltage": 1.0, + "reading_volts": 1.0, "upper_threshold_critical": 0.0, "upper_threshold_fatal": 0.0, }, @@ -566,17 +541,16 @@ func TestApis(t *testing.T) { map[string]string{ "source": "tpa-hostname", "name": "System Board NDC PG", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "severity": "NA", }, map[string]interface{}{ - "voltage": 1.0, + "reading_volts": 1.0, "upper_threshold_critical": 0.0, "upper_threshold_fatal": 0.0, }, @@ -588,17 +562,16 @@ func TestApis(t *testing.T) { map[string]string{ "source": "tpa-hostname", "name": "System Board PS1 PG FAIL", - "source_ip": CUSTOM_URL, + "address": ts.URL, "datacenter": "", "health": "OK", "rack": "", "room": "", "row": "", "state": "Enabled", - "severity": "NA", }, map[string]interface{}{ - "voltage": 1.0, + "reading_volts": 1.0, "upper_threshold_critical": 0.0, "upper_threshold_fatal": 0.0, }, @@ -606,10 +579,10 @@ func TestApis(t *testing.T) { ), } plugin := &Redfish{ - Host: "127.0.0.1:3458", + Address: ts.URL, BasicAuthUsername: "test", BasicAuthPassword: "test", - Id: "System.Embedded.1", + ServerSystemId: "System.Embedded.1", } plugin.Init() var acc testutil.Accumulator @@ -621,10 +594,10 @@ func TestApis(t *testing.T) { testutil.IgnoreTime()) hp_plugin := &Redfish{ - Host: "127.0.0.1:3458", + Address: ts.URL, BasicAuthUsername: "test", BasicAuthPassword: "test", - Id: "System.Embedded.2", + ServerSystemId: "System.Embedded.2", } hp_plugin.Init() var hp_acc testutil.Accumulator @@ -647,16 +620,14 @@ func checkAuth(r *http.Request, username, password string) bool { func TestConnection(t *testing.T) { r := &Redfish{ - Host: "127.0.0.1", + Address: "http://127.0.0.1", BasicAuthUsername: "test", BasicAuthPassword: "test", - Id: "System.Embedded.1", + ServerSystemId: "System.Embedded.1", } var acc testutil.Accumulator - r.Init() - err := r.Gather(&acc) require.Error(t, err) require.Contains(t, err.Error(), "connect: connection refused") @@ -664,7 +635,7 @@ func TestConnection(t *testing.T) { func TestInvalidUsernameorPassword(t *testing.T) { - ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if !checkAuth(r, "testing", "testing") { http.Error(w, "Unauthorized.", 401) @@ -678,17 +649,13 @@ func TestInvalidUsernameorPassword(t *testing.T) { panic("Cannot handle request") } })) - CUSTOM_URL := "127.0.0.1:3458" - l, _ := net.Listen("tcp", CUSTOM_URL) - ts.Listener = l - ts.StartTLS() defer ts.Close() r := &Redfish{ - Host: CUSTOM_URL, + Address: ts.URL, BasicAuthUsername: "test", BasicAuthPassword: "test", - Id: "System.Embedded.1", + ServerSystemId: "System.Embedded.1", } var acc testutil.Accumulator @@ -699,7 +666,7 @@ func TestInvalidUsernameorPassword(t *testing.T) { } func TestNoUsernameorPasswordConfiguration(t *testing.T) { - ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if !checkAuth(r, "testing", "testing") { http.Error(w, "Unauthorized.", 401) @@ -713,20 +680,14 @@ func TestNoUsernameorPasswordConfiguration(t *testing.T) { panic("Cannot handle request") } })) - CUSTOM_URL := "127.0.0.1:3458" - l, _ := net.Listen("tcp", CUSTOM_URL) - ts.Listener = l - ts.StartTLS() defer ts.Close() r := &Redfish{ - Host: CUSTOM_URL, - Id: "System.Embedded.1", + Address: ts.URL, + ServerSystemId: "System.Embedded.1", } - var acc testutil.Accumulator - r.Init() - err := r.Gather(&acc) + err := r.Init() require.Error(t, err) require.EqualError(t, err, "Did not provide IP or username and password") } @@ -739,43 +700,38 @@ func TestInvalidDellJSON(t *testing.T) { powerfilename string locationfilename string hostnamefilename string - CUSTOM_URL string }{ { name: "check Thermal", thermalfilename: "testdata/dell_thermalinvalid.json", powerfilename: "testdata/dell_power.json", - locationfilename: "testdata/dell_location.json", - hostnamefilename: "testdata/dell_hostname.json", - CUSTOM_URL: "127.0.0.1:3459", + locationfilename: "testdata/dell_chassis.json", + hostnamefilename: "testdata/dell_systems.json", }, { name: "check Power", thermalfilename: "testdata/dell_thermal.json", powerfilename: "testdata/dell_powerinvalid.json", - locationfilename: "testdata/dell_location.json", - hostnamefilename: "testdata/dell_hostname.json", - CUSTOM_URL: "127.0.0.1:3451", + locationfilename: "testdata/dell_chassis.json", + hostnamefilename: "testdata/dell_systems.json", }, { name: "check Location", thermalfilename: "testdata/dell_thermal.json", powerfilename: "testdata/dell_power.json", - locationfilename: "testdata/dell_locationinvalid.json", - hostnamefilename: "testdata/dell_hostname.json", - CUSTOM_URL: "127.0.0.1:3452", + locationfilename: "testdata/dell_chassisinvalid.json", + hostnamefilename: "testdata/dell_systems.json", }, { name: "check Hostname", thermalfilename: "testdata/dell_thermal.json", powerfilename: "testdata/dell_power.json", - locationfilename: "testdata/dell_location.json", - hostnamefilename: "testdata/dell_hostnameinvalid.json", - CUSTOM_URL: "127.0.0.1:3453", + locationfilename: "testdata/dell_chassis.json", + hostnamefilename: "testdata/dell_systemsinvalid.json", }, } for _, tt := range tests { - ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if !checkAuth(r, "test", "test") { http.Error(w, "Unauthorized.", 401) @@ -795,16 +751,13 @@ func TestInvalidDellJSON(t *testing.T) { panic("Cannot handle request") } })) - l, _ := net.Listen("tcp", tt.CUSTOM_URL) - ts.Listener = l - ts.StartTLS() defer ts.Close() plugin := &Redfish{ - Host: tt.CUSTOM_URL, + Address: ts.URL, BasicAuthUsername: "test", BasicAuthPassword: "test", - Id: "System.Embedded.1", + ServerSystemId: "System.Embedded.1", } plugin.Init() @@ -823,32 +776,28 @@ func TestInvalidHPJSON(t *testing.T) { thermalfilename string powerfilename string hostnamefilename string - CUSTOM_URL string }{ { name: "check Thermal", thermalfilename: "testdata/hp_thermalinvalid.json", powerfilename: "testdata/hp_power.json", - hostnamefilename: "testdata/hp_hostname.json", - CUSTOM_URL: "127.0.0.1:3278", + hostnamefilename: "testdata/hp_systems.json", }, { name: "check Power", thermalfilename: "testdata/hp_thermal.json", powerfilename: "testdata/hp_powerinvalid.json", - hostnamefilename: "testdata/hp_hostname.json", - CUSTOM_URL: "127.0.0.1:3289", + hostnamefilename: "testdata/hp_systems.json", }, { name: "check Hostname", thermalfilename: "testdata/hp_thermal.json", powerfilename: "testdata/hp_power.json", - hostnamefilename: "testdata/hp_hostnameinvalid.json", - CUSTOM_URL: "127.0.0.1:3290", + hostnamefilename: "testdata/hp_systemsinvalid.json", }, } for _, tt := range tests { - ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if !checkAuth(r, "test", "test") { http.Error(w, "Unauthorized.", 401) @@ -866,16 +815,13 @@ func TestInvalidHPJSON(t *testing.T) { panic("Cannot handle request") } })) - l, _ := net.Listen("tcp", tt.CUSTOM_URL) - ts.Listener = l - ts.StartTLS() defer ts.Close() plugin := &Redfish{ - Host: tt.CUSTOM_URL, + Address: ts.URL, BasicAuthUsername: "test", BasicAuthPassword: "test", - Id: "System.Embedded.2", + ServerSystemId: "System.Embedded.2", } plugin.Init() diff --git a/plugins/inputs/redfish/testdata/dell_location.json b/plugins/inputs/redfish/testdata/dell_chassis.json similarity index 100% rename from plugins/inputs/redfish/testdata/dell_location.json rename to plugins/inputs/redfish/testdata/dell_chassis.json diff --git a/plugins/inputs/redfish/testdata/dell_locationinvalid.json b/plugins/inputs/redfish/testdata/dell_chassisinvalid.json similarity index 100% rename from plugins/inputs/redfish/testdata/dell_locationinvalid.json rename to plugins/inputs/redfish/testdata/dell_chassisinvalid.json diff --git a/plugins/inputs/redfish/testdata/dell_hostname.json b/plugins/inputs/redfish/testdata/dell_systems.json similarity index 100% rename from plugins/inputs/redfish/testdata/dell_hostname.json rename to plugins/inputs/redfish/testdata/dell_systems.json diff --git a/plugins/inputs/redfish/testdata/dell_hostnameinvalid.json b/plugins/inputs/redfish/testdata/dell_systemsinvalid.json similarity index 100% rename from plugins/inputs/redfish/testdata/dell_hostnameinvalid.json rename to plugins/inputs/redfish/testdata/dell_systemsinvalid.json diff --git a/plugins/inputs/redfish/testdata/hp_hostname.json b/plugins/inputs/redfish/testdata/hp_systems.json similarity index 100% rename from plugins/inputs/redfish/testdata/hp_hostname.json rename to plugins/inputs/redfish/testdata/hp_systems.json diff --git a/plugins/inputs/redfish/testdata/hp_hostnameinvalid.json b/plugins/inputs/redfish/testdata/hp_systemsinvalid.json similarity index 100% rename from plugins/inputs/redfish/testdata/hp_hostnameinvalid.json rename to plugins/inputs/redfish/testdata/hp_systemsinvalid.json From c18917ab35189f781efff8ca16880f967137e421 Mon Sep 17 00:00:00 2001 From: sarvanikonda Date: Thu, 11 Jun 2020 11:05:19 +0530 Subject: [PATCH 12/12] updated README.md and redfish.go --- plugins/inputs/redfish/README.md | 159 +++++++++++++------------ plugins/inputs/redfish/redfish.go | 25 ++-- plugins/inputs/redfish/redfish_test.go | 19 ++- 3 files changed, 104 insertions(+), 99 deletions(-) diff --git a/plugins/inputs/redfish/README.md b/plugins/inputs/redfish/README.md index 7593761a997c1..767c342820127 100644 --- a/plugins/inputs/redfish/README.md +++ b/plugins/inputs/redfish/README.md @@ -15,103 +15,108 @@ The `redfish` plugin gathers metrics and status information about CPU temperatu password = "test" ## Resource Id for redfish APIs - id="System.Embedded.1" + computer_system_id = "System.Embedded.1" - ## Optional TLS Config + ## Optional TLS Config # tls_ca = "/etc/telegraf/ca.pem" # tls_cert = "/etc/telegraf/cert.pem" # tls_key = "/etc/telegraf/key.pem" + ## Use TLS but skip chain & host verification # insecure_skip_verify = false ## Amount of time allowed to complete the HTTP request # timeout = "5s" ``` -### Metrics +### Metrics -- redfish_power_powersupplies - - tags: - - address - - name - - datacenter (available only if location data is found) - - rack (available only if location data is found) - - room (available only if location data is found) - - row (available only if location data is found) - - state - - health - - Fields: - - last_power_output_watts - - line_input_voltage - - power_capacity_watts - - power_input_watts - - power_output_watts - -- redfish_power_voltages (available only if voltage data is found) - - tags: - - address - - name - - datacenter (available only if location data is found) - - rack (available only if location data is found) - - room (available only if location data is found) - - row (available only if location data is found) - - state - - health - - Fields: - - reading_volts - - upper_threshold_critical - - upper_threshold_fatal +- redfish_thermal_temperatures + - tags: + - source + - address + - name + - datacenter (available only if location data is found) + - rack (available only if location data is found) + - room (available only if location data is found) + - row (available only if location data is found) + - state + - health + - Fields: + - reading_celsius + - upper_threshold_critical + - upper_threshold_fatal - redfish_thermal_fans - - tags: - - address - - name - - datacenter (available only if location data is found) - - rack (available only if location data is found) - - room (available only if location data is found) - - row (available only if location data is found) - - state - - health - - Fields: - - reading_rpm (or) reading_percent - - upper_threshold_critical - - upper_threshold_fatal + - tags: + - source + - address + - name + - datacenter (available only if location data is found) + - rack (available only if location data is found) + - room (available only if location data is found) + - row (available only if location data is found) + - state + - health + - Fields: + - reading_rpm (or) reading_percent + - upper_threshold_critical + - upper_threshold_fatal -- redfish_thermal_temperatures - - tags: - - address - - name - - datacenter (available only if location data is found) - - rack (available only if location data is found) - - room (available only if location data is found) - - row (available only if location data is found) - - state - - health - - Fields: - - reading_celsius - - upper_threshold_critical - - upper_threshold_fatal +- redfish_power_powersupplies + - tags: + - source + - address + - name + - datacenter (available only if location data is found) + - rack (available only if location data is found) + - room (available only if location data is found) + - row (available only if location data is found) + - state + - health + - Fields: + - last_power_output_watts + - line_input_voltage + - power_capacity_watts + - power_input_watts + - power_output_watts +- redfish_power_voltages (available only if voltage data is found) + - tags: + - source + - address + - name + - datacenter (available only if location data is found) + - rack (available only if location data is found) + - room (available only if location data is found) + - row (available only if location data is found) + - state + - health + - Fields: + - reading_volts + - upper_threshold_critical + - upper_threshold_fatal + ### Example Output -``` -redfish_thermal_temperatures,source=test-hostname,name=CPU1\ Temp,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_celsius=41,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_thermal_temperatures,source=test-hostname,name=CPU2\ Temp,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_celsius=51,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_thermal_temperatures,source=test-hostname,name=System\ Board\ Inlet\ Temp,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_celsius=23,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_thermal_temperatures,source=test-hostname,name=System\ Board\ Exhaust\ Temp,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_celsius=33,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_thermal_fans,source=test-hostname,name=System\ Board\ Fan1A,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading=17720,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_thermal_fans,source=test-hostname,name=System\ Board\ Fan1B,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading=17760,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_thermal_fans,source=test-hostname,name=System\ Board\ Fan2A,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading=17880,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_power_powersupplies,source=test-hostname,name=PS1\ Status,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" power_capacity_watts=750,power_input_watts=900,power_output_watts=208,last_power_output_watts=98,line_input_reading_volts=204 1582114112000000000 -redfish_power_powersupplies,source=test-hostname,name=PS2\ Status,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" power_capacity_watts=750,power_input_watts=900,power_output_watts=194,last_power_output_watts=98,line_input_reading_volts=204 1582114112000000000 -redfish_power_voltages,source=test-hostname,name=CPU1\ MEM345\ VDDQ\ PG,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_power_voltages,source=test-hostname,name=CPU1\ MEM345\ VPP\ PG,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_power_voltages,source=test-hostname,name=CPU1\ MEM345\ VTT\ PG,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_power_voltages,source=test-hostname,name=PS1\ voltage\ 1,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=208,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_power_voltages,source=test-hostname,name=PS2\ voltage\ 2,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=208,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 -redfish_power_voltages,source=test-hostname,name=System\ Board\ 3.3V\ A\ PG,address=http://190.0.0.1,host=test-telegraf,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +``` +redfish_thermal_temperatures,source=test-hostname,name=CPU1,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_celsius=41,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_thermal_temperatures,source=test-hostname,name=CPU2,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_celsius=51,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_thermal_temperatures,source=test-hostname,name=SystemBoardInlet,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_celsius=23,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_thermal_temperatures,source=test-hostname,name=SystemBoardExhaust,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_celsius=33,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_thermal_fans,source=test-hostname,name=SystemBoardFan1A,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_rpm=17720,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_thermal_fans,source=test-hostname,name=SystemBoardFan1B,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_rpm=17760,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_thermal_fans,source=test-hostname,name=SystemBoardFan2A,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_rpm=17880,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_power_powersupplies,source=test-hostname,name=PS1Status,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" power_capacity_watts=750,power_input_watts=900,power_output_watts=208,last_power_output_watts=98,line_input_reading_volts=204 1582114112000000000 +redfish_power_powersupplies,source=test-hostname,name=PS2Status,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" power_capacity_watts=750,power_input_watts=900,power_output_watts=194,last_power_output_watts=98,line_input_reading_volts=204 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=CPU1MEM345,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=CPU1MEM345,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=CPU1MEM347,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=1,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 +redfish_power_voltages,source=test-hostname,name=PS1voltage1,address=http://190.0.0.1,datacenter="Tampa",health="OK",rack="12",room="tbc",row="3",state="Enabled" reading_volts=208,upper_threshold_critical=59,upper_threshold_fatal=64 1582114112000000000 ``` + + diff --git a/plugins/inputs/redfish/redfish.go b/plugins/inputs/redfish/redfish.go index 0dba40da1f55a..9905b75af7eca 100644 --- a/plugins/inputs/redfish/redfish.go +++ b/plugins/inputs/redfish/redfish.go @@ -82,7 +82,7 @@ type Redfish struct { Address string `toml:"address"` BasicAuthUsername string `toml:"username"` BasicAuthPassword string `toml:"password"` - ServerSystemId string `toml:"server_system_id"` + ComputerSystemId string `toml:"computer_system_id"` client http.Client tls.ClientConfig Timeout internal.Duration `toml:"timeout"` @@ -90,7 +90,7 @@ type Redfish struct { } func (r *Redfish) Description() string { - return "Read CPU, Fans, Powersupply and Voltage metrics of Dell/HP hardware server through redfish APIs" + return "Read CPU, Fans, Powersupply and Voltage metrics of hardware server through redfish APIs" } var redfishConfig = ` @@ -102,12 +102,13 @@ var redfishConfig = ` password = "test" ##Resource Id for redfish APIs - server_system_id="System.Embedded.1" + computer_system_id="System.Embedded.1" ##Optional TLS Config #tls_ca = "/etc/telegraf/ca.pem" #tls_cert = "/etc/telegraf/cert.pem" #tls_key = "/etc/telegraf/key.pem" + ## Use TLS but skip chain & host verification #insecure_skip_verify = false ## Amount of time allowed to complete the HTTP request @@ -120,14 +121,14 @@ func (r *Redfish) SampleConfig() string { func (r *Redfish) Init() error { if len(r.Address) == 0 || len(r.BasicAuthUsername) == 0 || len(r.BasicAuthPassword) == 0 { - return fmt.Errorf("Did not provide IP or username and password") + return fmt.Errorf("did not provide IP or username and password") } - if len(r.ServerSystemId) == 0 { - return fmt.Errorf("Did not provide all the ID of the resource") + if len(r.ComputerSystemId) == 0 { + return fmt.Errorf("did not provide the computer system ID of the resource") } tlsCfg, err := r.ClientConfig.TLSConfig() if err != nil { - return fmt.Errorf("%v", err) + return err } r.client = http.Client{ Transport: &http.Transport{ @@ -143,20 +144,20 @@ func (r *Redfish) Init() error { func (r *Redfish) GetData(url string) error { req, err := http.NewRequest("GET", url, nil) if err != nil { - return fmt.Errorf("%v", err) + return err } req.SetBasicAuth(r.BasicAuthUsername, r.BasicAuthPassword) req.Header.Set("Accept", "application/json") req.Header.Set("Content-Type", "application/json") resp, err := r.client.Do(req) if err != nil { - return fmt.Errorf("%v", err) + return err } defer resp.Body.Close() if resp.StatusCode == 200 { body, err := ioutil.ReadAll(resp.Body) if err != nil { - return fmt.Errorf("%v", err) + return err } err = json.Unmarshal(body, &r.payload) if err != nil { @@ -173,11 +174,11 @@ func (r *Redfish) GetData(url string) error { func (r *Redfish) Gather(acc telegraf.Accumulator) error { var url []string - url = append(url, fmt.Sprint(r.Address, "/redfish/v1/Chassis/", r.ServerSystemId, "/Thermal"), fmt.Sprint(r.Address, "/redfish/v1/Chassis/", r.ServerSystemId, "/Power"), fmt.Sprint(r.Address, "/redfish/v1/Systems/", r.ServerSystemId), fmt.Sprint(r.Address, "/redfish/v1/Chassis/", r.ServerSystemId, "/")) + url = append(url, fmt.Sprint(r.Address, "/redfish/v1/Chassis/", r.ComputerSystemId, "/Thermal"), fmt.Sprint(r.Address, "/redfish/v1/Chassis/", r.ComputerSystemId, "/Power"), fmt.Sprint(r.Address, "/redfish/v1/Systems/", r.ComputerSystemId), fmt.Sprint(r.Address, "/redfish/v1/Chassis/", r.ComputerSystemId, "/")) for _, i := range url { err := r.GetData(i) if err != nil { - return fmt.Errorf("%v", err) + return err } } if r.payload.Location != nil { diff --git a/plugins/inputs/redfish/redfish_test.go b/plugins/inputs/redfish/redfish_test.go index 25cbb8f519c90..86f9012947c7a 100644 --- a/plugins/inputs/redfish/redfish_test.go +++ b/plugins/inputs/redfish/redfish_test.go @@ -1,7 +1,6 @@ package redfish import ( - // "net" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/testutil" "github.com/stretchr/testify/require" @@ -582,7 +581,7 @@ func TestApis(t *testing.T) { Address: ts.URL, BasicAuthUsername: "test", BasicAuthPassword: "test", - ServerSystemId: "System.Embedded.1", + ComputerSystemId: "System.Embedded.1", } plugin.Init() var acc testutil.Accumulator @@ -597,7 +596,7 @@ func TestApis(t *testing.T) { Address: ts.URL, BasicAuthUsername: "test", BasicAuthPassword: "test", - ServerSystemId: "System.Embedded.2", + ComputerSystemId: "System.Embedded.2", } hp_plugin.Init() var hp_acc testutil.Accumulator @@ -623,7 +622,7 @@ func TestConnection(t *testing.T) { Address: "http://127.0.0.1", BasicAuthUsername: "test", BasicAuthPassword: "test", - ServerSystemId: "System.Embedded.1", + ComputerSystemId: "System.Embedded.1", } var acc testutil.Accumulator @@ -655,7 +654,7 @@ func TestInvalidUsernameorPassword(t *testing.T) { Address: ts.URL, BasicAuthUsername: "test", BasicAuthPassword: "test", - ServerSystemId: "System.Embedded.1", + ComputerSystemId: "System.Embedded.1", } var acc testutil.Accumulator @@ -683,13 +682,13 @@ func TestNoUsernameorPasswordConfiguration(t *testing.T) { defer ts.Close() r := &Redfish{ - Address: ts.URL, - ServerSystemId: "System.Embedded.1", + Address: ts.URL, + ComputerSystemId: "System.Embedded.1", } err := r.Init() require.Error(t, err) - require.EqualError(t, err, "Did not provide IP or username and password") + require.EqualError(t, err, "did not provide IP or username and password") } func TestInvalidDellJSON(t *testing.T) { @@ -757,7 +756,7 @@ func TestInvalidDellJSON(t *testing.T) { Address: ts.URL, BasicAuthUsername: "test", BasicAuthPassword: "test", - ServerSystemId: "System.Embedded.1", + ComputerSystemId: "System.Embedded.1", } plugin.Init() @@ -821,7 +820,7 @@ func TestInvalidHPJSON(t *testing.T) { Address: ts.URL, BasicAuthUsername: "test", BasicAuthPassword: "test", - ServerSystemId: "System.Embedded.2", + ComputerSystemId: "System.Embedded.2", } plugin.Init()