mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-24 14:49:05 +01:00
Use package hostlist to expand a host list
This commit is contained in:
parent
6f1f33f3a5
commit
31a8e63d72
@ -7,23 +7,23 @@
|
||||
},
|
||||
"redfish_recv": {
|
||||
"type": "redfish",
|
||||
"endpoint": "https://%h-bmc",
|
||||
"client_config": [
|
||||
{
|
||||
"hostname": "my-host-1",
|
||||
"host_list": "my-host-1-[1-2]",
|
||||
"username": "username-1",
|
||||
"password": "password-1",
|
||||
"endpoint": "https://my-endpoint-1"
|
||||
"password": "password-1"
|
||||
},
|
||||
{
|
||||
"hostname": "my-host-2",
|
||||
"host_list": "my-host-2-[1,2]",
|
||||
"username": "username-2",
|
||||
"password": "password-2",
|
||||
"endpoint": "https://my-endpoint-2"
|
||||
"password": "password-2"
|
||||
}
|
||||
]
|
||||
},
|
||||
"ipmi_recv": {
|
||||
"type": "ipmi",
|
||||
"endpoint": "ipmi-sensors://%h-ipmi",
|
||||
"exclude_metrics": [
|
||||
"fan_speed",
|
||||
"voltage"
|
||||
@ -32,15 +32,13 @@
|
||||
{
|
||||
"username": "username-1",
|
||||
"password": "password-1",
|
||||
"endpoint": "ipmi-sensors://%h-ipmi",
|
||||
"host_list": "my-host-1-[1-2]"
|
||||
},
|
||||
{
|
||||
"username": "username-2",
|
||||
"password": "password-2",
|
||||
"endpoint": "ipmi-sensors://%h-ipmi",
|
||||
"host_list": "my-host-2-[1,2]"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ The IPMI Receiver uses `ipmi-sensors` from the [FreeIPMI](https://www.gnu.org/so
|
||||
"fanout": 256,
|
||||
"username": "<Username>",
|
||||
"password": "<Password>",
|
||||
"endpoint": "ipmi-sensors://%h-p",
|
||||
"endpoint": "ipmi-sensors://%h-bmc",
|
||||
"exclude_metrics": [ "fan_speed", "voltage" ],
|
||||
"client_config": [
|
||||
{
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
|
||||
cclog "github.com/ClusterCockpit/cc-metric-collector/pkg/ccLogger"
|
||||
lp "github.com/ClusterCockpit/cc-metric-collector/pkg/ccMetric"
|
||||
"github.com/ClusterCockpit/cc-metric-collector/pkg/hostlist"
|
||||
|
||||
// See: https://pkg.go.dev/github.com/stmcginnis/gofish
|
||||
"github.com/stmcginnis/gofish"
|
||||
@ -630,10 +631,10 @@ func NewRedfishReceiver(name string, config json.RawMessage) (Receiver, error) {
|
||||
ExcludeMetrics []string `json:"exclude_metrics,omitempty"`
|
||||
|
||||
ClientConfigs []struct {
|
||||
HostList []string `json:"host_list"` // List of hosts with the same client configuration
|
||||
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
|
||||
HostList string `json:"host_list"` // List of hosts with the same client configuration
|
||||
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
|
||||
|
||||
// Per client disable collection of power,processor or thermal metrics
|
||||
DisablePowerMetrics bool `json:"disable_power_metrics"`
|
||||
@ -763,7 +764,14 @@ func NewRedfishReceiver(name string, config json.RawMessage) (Receiver, error) {
|
||||
isExcluded[key] = true
|
||||
}
|
||||
|
||||
for _, host := range clientConfigJSON.HostList {
|
||||
hostList, err := hostlist.Expand(clientConfigJSON.HostList)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("client config number %d failed to parse host list %s: %v",
|
||||
i, clientConfigJSON.HostList, err)
|
||||
cclog.ComponentError(r.name, err)
|
||||
return nil, err
|
||||
}
|
||||
for _, host := range hostList {
|
||||
|
||||
// Endpoint of the redfish service
|
||||
endpoint := strings.Replace(endpoint_pattern, "%h", host, -1)
|
||||
|
@ -8,22 +8,22 @@ The Redfish receiver uses the [Redfish (specification)](https://www.dmtf.org/sta
|
||||
{
|
||||
"<redfish receiver name>": {
|
||||
"type": "redfish",
|
||||
"username": "<user A>",
|
||||
"password": "<password A>",
|
||||
"username": "<Username>",
|
||||
"password": "<Password>",
|
||||
"endpoint": "https://%h-bmc",
|
||||
"exclude_metrics": [ "min_consumed_watts" ],
|
||||
"client_config": [
|
||||
{
|
||||
"host_list": [ "<host 1>", "<host 2>" ]
|
||||
"host_list": "n[1,2-4]"
|
||||
},
|
||||
{
|
||||
"host_list": [ "<host 3>", "<host 4>" ]
|
||||
"host_list": "n5"
|
||||
"disable_power_metrics": true
|
||||
},
|
||||
{
|
||||
"host_list": [ "<host 5>" ],
|
||||
"username": "<user B>",
|
||||
"password": "<password B>",
|
||||
"host_list": "n6" ],
|
||||
"username": "<Username 2>",
|
||||
"password": "<Password 2>",
|
||||
"endpoint": "https://%h-BMC",
|
||||
"disable_thermal_metrics": true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user