mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-25 15:09:05 +01:00
Allow global configuration for redfish devices username, password and endpoint.
This commit is contained in:
parent
60ef0ed116
commit
7ccbf1ebe2
@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -615,6 +616,11 @@ func NewRedfishReceiver(name string, config json.RawMessage) (Receiver, error) {
|
||||
// Time limit for requests made by this HTTP client (default: 10 s)
|
||||
HttpTimeoutString string `json:"http_timeout,omitempty"`
|
||||
|
||||
// Default client username, password and endpoint
|
||||
Username *string `json:"username"` // User name to authenticate with
|
||||
Password *string `json:"password"` // Password to use for authentication
|
||||
Endpoint *string `json:"endpoint"` // URL of the redfish service
|
||||
|
||||
// Globally disable collection of power, processor or thermal metrics
|
||||
DisablePowerMetrics bool `json:"disable_power_metrics"`
|
||||
DisableProcessorMetrics bool `json:"disable_processor_metrics"`
|
||||
@ -719,26 +725,37 @@ func NewRedfishReceiver(name string, config json.RawMessage) (Receiver, error) {
|
||||
}
|
||||
clientConfig.Hostname = *clientConfigJSON.Hostname
|
||||
|
||||
if clientConfigJSON.Endpoint == nil {
|
||||
var endpoint string
|
||||
if clientConfigJSON.Endpoint != nil {
|
||||
endpoint = *clientConfigJSON.Endpoint
|
||||
} else if configJSON.Endpoint != nil {
|
||||
endpoint = *configJSON.Endpoint
|
||||
} else {
|
||||
err := fmt.Errorf("client config number %v requires endpoint", i)
|
||||
cclog.ComponentError(r.name, err)
|
||||
return nil, err
|
||||
}
|
||||
gofishConfig.Endpoint = *clientConfigJSON.Endpoint
|
||||
gofishConfig.Endpoint = strings.Replace(endpoint, "%h", clientConfig.Hostname, -1)
|
||||
|
||||
if clientConfigJSON.Username == nil {
|
||||
if clientConfigJSON.Username != nil {
|
||||
gofishConfig.Username = *clientConfigJSON.Username
|
||||
} else if configJSON.Username != nil {
|
||||
gofishConfig.Username = *configJSON.Username
|
||||
} else {
|
||||
err := fmt.Errorf("client config number %v requires username", i)
|
||||
cclog.ComponentError(r.name, err)
|
||||
return nil, err
|
||||
}
|
||||
gofishConfig.Username = *clientConfigJSON.Username
|
||||
|
||||
if clientConfigJSON.Password == nil {
|
||||
if clientConfigJSON.Password != nil {
|
||||
gofishConfig.Password = *clientConfigJSON.Password
|
||||
} else if configJSON.Password != nil {
|
||||
gofishConfig.Password = *configJSON.Password
|
||||
} else {
|
||||
err := fmt.Errorf("client config number %v requires password", i)
|
||||
cclog.ComponentError(r.name, err)
|
||||
return nil, err
|
||||
}
|
||||
gofishConfig.Password = *clientConfigJSON.Password
|
||||
|
||||
// Reuse existing http client
|
||||
gofishConfig.HTTPClient = httpClient
|
||||
|
@ -8,26 +8,23 @@ The Redfish receiver uses the [Redfish (specification)](https://www.dmtf.org/sta
|
||||
{
|
||||
"<redfish receiver name>": {
|
||||
"type": "redfish",
|
||||
"username": "<user A>",
|
||||
"password": "<password A>",
|
||||
"endpoint": "https://%h-bmc",
|
||||
"exclude_metrics": [ "min_consumed_watts" ],
|
||||
"client_config": [
|
||||
{
|
||||
"hostname": "<host 1>",
|
||||
"username": "<user 1>",
|
||||
"password": "<password 1>",
|
||||
"endpoint": "https://<endpoint 1>"
|
||||
"hostname": "<host 1>"
|
||||
},
|
||||
{
|
||||
"hostname": "<host 2>",
|
||||
"username": "<user 2>",
|
||||
"password": "<password 2>",
|
||||
"endpoint": "https://<endpoint 2>",
|
||||
"disable_power_metrics": true
|
||||
},
|
||||
{
|
||||
"hostname": "<host 3>",
|
||||
"username": "<user 3>",
|
||||
"password": "<password 3>",
|
||||
"endpoint": "https://<endpoint 3>",
|
||||
"username": "<user B>",
|
||||
"password": "<password B>",
|
||||
"endpoint": "https://%h-BMC",
|
||||
"disable_thermal_metrics": true
|
||||
}
|
||||
]
|
||||
@ -42,15 +39,15 @@ Global settings:
|
||||
- `http_insecure`: Control whether a client verifies the server's certificate (default: true == do not verify server's certificate)
|
||||
- `http_timeout`: Time limit for requests made by this HTTP client (default: 10 s)
|
||||
|
||||
Global and per redfish device settings:
|
||||
Global and per redfish device settings (per redfish device settings overwrite the global settings):
|
||||
|
||||
- `disable_power_metrics`: disable collection of power metrics
|
||||
- `disable_thermal_metrics`: disable collection of thermal metrics
|
||||
- `exclude_metrics`: list of excluded metrics
|
||||
- `username`: User name to authenticate with
|
||||
- `password`: Password to use for authentication
|
||||
- `endpoint`: URL of the redfish service (placeholder `%h` gets replaced by the hostname)
|
||||
|
||||
Per redfish device settings:
|
||||
|
||||
- `hostname`: hostname the redfish service belongs to
|
||||
- `username`: User name to authenticate with
|
||||
- `password`: Password to use for authentication
|
||||
- `endpoint`: URL of the redfish service
|
||||
|
Loading…
Reference in New Issue
Block a user